Upgrade to Pro — share decks privately, control downloads, hide ads and more …

(PROMISE[JAVA8] => SCALA)

(PROMISE[JAVA8] => SCALA)

A short 30min talk for Malaga Scala Meetup about why Java8 is not enough.

Avatar for Sergio Tudela Romero

Sergio Tudela Romero

July 15, 2015
Tweet

Other Decks in Programming

Transcript

  1. ABOUT ME aboutMe map(java) map(scala) What...? •  Java •  Measurements

    collector •  Gambling industry •  other boring stories… •  Scala •  BigData projects •  Log aggregation •  other interesting stories… @sergiotudela
  2. LAMBDA EXPRESSIONS – PART 3 Cool! basically there is no

    difference… wait! SCALA Lambda expressions in Java are syntactic sugar over anonymous classes that have access to the final objects of a context only. But in Scala, they are full-on closures that have the full access to the context.
  3. LAMBDA EXPRESSIONS – PART 4 Well, It's not such a

    big deal anyway. Ok, let’s talk ‘lambda declaration’... SCALA JAVA java: illegal start of type / Are you kidding me?
  4. LAMBDA EXPRESSIONS – PART 5 And now, calling to that

    lambda… SCALA JAVA java: cannot find symbol / Are you kidding me?
  5. TRAIT – PART 2 Inherit? Java has an answer for

    you: java: class Clazz inherits unrelated defaults for draw() from types SayHello and SayGoodbye SCALA OUTPUT Diamond problem? Scala considers the order in which traits are inherited
  6. OBJECT Briefly: keyword as creating a singleton object of a

    class that is defined implicitly. SCALA JAVA
  7. IMPLICITS – PART 1 SCALA A method with implicit parameters

    can be applied to arguments just like a normal method. In this case the implicit label has no effect. However, if such a method misses arguments for its implicit parameters, such arguments will be automatically provided.
  8. MORE, MORE AND MORE… •  “For” comprehension •  Lazy variables

    (not so easy to implement in Java…) •  Most complex yet most powerful type system in any language I know of •  Type inference •  Let’s not forget pass by name arguments and the ability to construct a DSL •  Much better and more elegant futures / promises •  Macros! •  …
  9. LIBRARIES TO THE RESCUE Modular extensions for Java8 •  https://github.com/aol/cyclops

    More control, less code. Functional component library for java8 •  http://javaslang.com/ Functional Java is an open source library facilitating functional programming in Java •  http://www.functionaljava.org/ Backport of Java 8's lambda expressions to Java 7, 6 and 5 •  https://github.com/orfjackal/retrolambda