SlideShare a Scribd company logo
2013  overview	
              Sagie Davidovich
           singularityworld.com
        linkedin.com/in/sagied
2013  JVM  Languages  Landscape	
                    Static	




                                    Object  Oriented	
Functional	




                  Dynamic
Who’s  using  scala
Performance  study  by  
       Google

Recommended for you

Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala

The Scala programming language has been gaining momentum recently as an alternative (and some might say successor) to Java on the JVM. This talk will start with an introduction to basic Scala syntax and concepts, then delve into some of Scala's more interesting and unique features. At the end we'll show a brief example of how Scala is used by the Lift web framework to simplify dynamic web apps.

developerday
Hello, Guava !
Hello, Guava !Hello, Guava !
Hello, Guava !

Guava is Java libraries by Google. This is Introduction of Guava with some API and sample codes. Its samples are here. http://www.slideshare.net/akirakoyasu/hello-guava-samples

guavagoogle-codejava
Demystifying functional programming with Scala
Demystifying functional programming with ScalaDemystifying functional programming with Scala
Demystifying functional programming with Scala

The Scala programming language, its history, design choices, syntax basics, functional concepts, monads

scalamonadfunctional programming
Exponential  growth  in  
      demand
Thoughtworks  
         Technology  Radar  2012	


Evaluate	




Consider	



    Hold
Language  Design  
      Trade-­‐‑offs	
Expressiveness	
                   Performance	




          Complexity
Positioning	

          Object  
         Oriented	
    JVM	



Statically  
 Typed	
                Functional

Recommended for you

Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API

This document summarizes a talk given about Nokia's migration to Scala for its Places API. The key points are: 1) Nokia migrated its Places API codebase to Scala to take advantage of Scala's features like its powerful type system, immutable data structures, and functional programming capabilities. 2) The migration was done gradually over time while continuing to develop new features. They discovered many benefits of Scala along the way like improved test readability and JSON parsing capabilities. 3) Nokia uses Scala features like case classes, options, and functions to model data and add type safety to its codebase. This uncovered bugs that would have been hard to find in Java.

nokiaapiscala
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet

This document provides a dictionary of scala programming concepts including definitions of common jargon like ADT, typeclasses, extension methods, and call-by semantics. It defines ADT as algebraic data types, which were introduced in languages like Algol 60 and ML, and pattern matching which allows decomposing ADT values. Typeclasses are defined as rules for types like equality, with instances providing implementations. Extension methods and implicit conversions add methods to types via implicit parameters. Call-by-name and call-by-need semantics are discussed in relation to lazy evaluation.

scala
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes

Some notes about programming in Scala: it covers Scala syntax and semantics, programming techniques, idioms, patterns. Many Scala features are introduced, from basic to intermediate and advanced. These are not introductory notes, but they assume a working knowledge with some other programming language (Java, C#, C++), object-oriented programming (OOP) concepts, and functional programming (FP) concepts.

scalaprogrammingfunctional programming
Prof.  Martin  Odersky	
•    Designer of Java Generics
•    Creator of JavaC
•    Prof. at EPFL
•    ACM Fellow
•    Founder of
Class  Employee  -­‐‑  Java	
public class Employee implements Serializable {             public boolean equals(Object o) {
  private final String firstName;                             if (this == o) {
  private final String lastName;                                  return true;
                                                              }
  public Employee (String firstName, String lastName) {       if (o == null || getClass() != o.getClass()) {
     this.firstName = firstName;                                  return false;
     this.lastName = lastName;                                }
  }                                                           Employee employee = (Employee) o;
                                                              if (firstName != null ? !firstName.equals(employee.firstName) :
  public String getFirstName() {                          person.firstName != null) {
     return lastName;                                            return false;
  }                                                            }
                                                               if (lastName != null ? !lastName.equals(employee.lastName) :
                                                          employee.lastName != null) {
  public String getLastName() {
                                                                   return true;
     return firstName;

 
  }                                                            }
                                                               return true;
                                                                                 Oops,  should  be  false  
  public Employee withFirstName(String firstName) {
                                                           
                                                             }                     Anyone  noticed?	
     return new Employee (firstName, lastName);
  }                                                          public int hashCode() {
                                                               int result = firstName != null ? firstName.hashCode() : 0;
 
                                                               result = 31 * result + (lastName != null ?
  public Employee withLastName(String lastName) {
                                                          lastName.hashCode() : 0);
     return new Employee (firstName, lastName);
                                                               return result;
  }
                                                             }
 
                                                           
                                                             public String toString() {
                                                               return "Employee(" + firstName + "," + lastName + ")";
                                                             }
                                                          }
Class  Employee  -­‐‑  Scala	

case class Employee(firstName: String, lastName: String)!


 •    Constructor	
 •    Copy  constructors	
 •    Fields	
 •    GeVers  /  (seVers)	
 •    equals	
 •    hashCode	
 •    toString	
 •    Recursive  decomposition	
 •    Companion  object
Singletons	
Java
public class OneAndOnly {
  private final static OneAndOnly INSTANCE = new OneAndOnly();

    private OneAndOnly() {}

    public static OneAndOnly getInstance() { return OneAndOnly.INSTANCE; }
}



Scala
object OneAndOnly

Recommended for you

All about scala
All about scalaAll about scala
All about scala

The document is a slide presentation on Scala that provides an introduction to the language in 90 minutes or less. It covers Scala basics like being object oriented and functional, static typing, compilation to JVM bytecode, and interoperability with Java. It also discusses Scala tools, its use in open source projects and industry, recommended books, and jobs involving Scala. Code examples are provided to demonstrate Hello World programs, variables, methods, conditionals, sequences, and closures in Scala.

scala
Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008

This document provides an introduction to the Scala programming language. It begins with an overview of Scala's motivation and history. It then covers the basics of Scala including simple data structures, loops, objects, types and generics. More advanced topics such as traits, mixins, implicit conversions and sealed classes are also discussed. The document concludes with references for further reading.

scala
Scala Intro
Scala IntroScala Intro
Scala Intro

Scala Intro training @ Lohika, Odessa, UA. This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.

introtrainingbasics
Everything  is  an  object	


       1.+(2)
        Same as

        1+2
Every  block  returns  a  value  
 (no  statements,  only  expressions)	
def add (x:Int, y:Int) = x + {val tmp = y; tmp * 3}!
!
if (x > 2) 3 else 4!
!
val doubled = for(i <- (1 to 10)) yield i * 2!
Type  inference	
scala> val x = 3
x: Int = 3


scala> def x(y:Int) = y * 9
x: (y: Int)Int


scala> def x(y:Int) =
       if (y == 1) List(y) else Set(y)
x: (y: Int) Iterable[Int]
Higher  order  functions	
List(1, 2, 3).map((x: Int) => x + 1)

                          =
List(1, 2, 3).map(x => x + 1)     // type is inferred

                          =
List(1, 2, 3).map(_ + 1) // placeholder notation

Recommended for you

Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes

Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases. A talk given at the Underscore meetup on 19 August, 2014.

underscorescalatype classes
Scala cheatsheet
Scala cheatsheetScala cheatsheet
Scala cheatsheet

This document provides a cheat sheet overview of Scala concepts including packages, imports, variables, constants, classes, traits, generics, methods, functions, operators, arrays, main methods, annotations, assignments, selection, iteration and references. Key points are that Scala uses packages similarly to Java but with curly brace delimiters, imports can be used anywhere in a file, variables use 'var', constants use 'val', classes inherit from Any and can use traits for mixins, generics are defined with type parameters, functions are objects, operators are methods, arrays are classes, main returns Unit, and assignments use = while iteration prefers recursion over loops.

arduino aficionado
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?

Scala er et Java-relateret, statisk typet programmeringssprog i hastig fremmarch. Sproget kombinerer aspekter fra objekt- og funktionsorienterede sprog og fokuserer på skalerbarhed og effektivitet, både på det kodemæssige og afviklingsmæssige niveau. Syntaksen er elegant og koncis. Samtidig indeholder sproget stærke konstruktioner til understøttelse af parallelle applikationer, der udnytter fremtidens hardwarearkitekturer.

scalajavadanish
Universal  access  principle  	
import System._!
!
class Clz {!
   def w = currentTimeMillis / 1000!
   val x = currentTimeMillis / 1000!
   var y = currentTimeMillis / 1000!
   lazy val z = currentTimeMillis / 1000!
}!
Default  methods  
       apply  and  unapply	
object Square{
  def apply(d: Double) = d * d
  def unapply(d: Double) = Some(math.sqrt(d))
}

//apply
val s = Square(3)                  // 9

// unaply
16 match { case Square(x) => x }   // 4
Curried  functions	
•  Add new flow control and language constructs!
    def loop(n: Int)(body: => Any) {!
        (0 until n) foreach (n => body)!
    }!
   !

    loop(2) {!
       println("IM IN YR LOOP!")!
    }!
•  Multiple varargs lists are possible!!
    def crossProduct[L,R](left: L*)(right: R*) =

    for (l <- left; r <- right) yield (l,r)!
    crossProduct(1,2,3)(‘a’,’b’,’c’)!

•  Partially applied functions!
    !
Multiple  inheritance  without  
  the  diamond  problem

Recommended for you

A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming

This document provides a skeptical guide to functional programming through a series of slides presented at a BASH event. It begins by acknowledging that the presenter likes FP but is skeptical of FP programmers. It then discusses some functional programming languages like Lisp, Haskell, and Scala. It explores the differences between pure and hybrid languages. Several slides provide examples of code in languages like Clojure and Scala to demonstrate functional concepts. The presentation questions whether the language itself matters and argues the audience may already be using FP techniques without realizing it.

c#javaclojure
Intro to Functional Programming in Scala
Intro to Functional Programming in ScalaIntro to Functional Programming in Scala
Intro to Functional Programming in Scala

Scala is a functional and object-oriented programming language that runs on the Java Virtual Machine. It features type inference, immutable collections, pattern matching, and functions as first-class values. The document provides an overview of Scala's features such as its static typing, traits for multiple inheritance, and case classes for value objects. It also demonstrates Scala's collections API and use of functions and pattern matching.

scalafunctional programming
Scala Intro
Scala IntroScala Intro
Scala Intro

This document summarizes key features of the Scala programming language. Some key points include: - Scala runs on the Java Virtual Machine (JVM) and allows for type inference, immutable values, functional programming patterns like pattern matching, and object-oriented features like traits for inheritance. - Scala favors immutable values over mutable variables for scalability. Features like actors allow for concurrency without shared mutable state. - Scala code can be compiled to JavaScript using Scala.js, allowing full-stack development in a single language. - Traits provide a powerful way to do multiple inheritance by combining traits and classes at runtime.

scala meetup torino agilelab
Type  system
Type  system	

          Strong	
              Explicit  +  Inferred	
                     Traits	
    Self  types	
                  Static  +  Dynamic	
                      Functional	
                                                     Erasure	
Nominal  +  Structural	
                                                Type  aliases	
             Nonnullable	
                                          Monads	
Implicit	
               Co/Contra-­‐‑variant	
   Existential	
    Value  +  Reference	
                   Case  classes	
                Path  dependent	
                               Anonymous
Type  safety  (Java  example)	
// compiles fine in Java (arrays are co-variant!!)

int[] ints = {3};
Object[] objects = ints;

// ArrayStoreException in runtime

objects[0] = new Object();
Structural  types	
object Closer {
  def using(closeable: { def close(): Unit }, f: => Unit) {
    try {
      f
    } finally { closeable.close }
  }
}

Recommended for you

1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics

This document summarizes some of the key differences between Scala and Java syntax. It covers topics like type definitions, variables, methods, classes, traits, collections, exceptions, control flow, and packages. Overall, the document shows that Scala code is more concise and expressive than equivalent Java code for many common programming constructs.

Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes

Slides for mini-tutorial at the International Conference on Sofware Language Engineering (SLE 2012) in Dresden, Germany, September 27, 2012.

grammartransformationrewriting
Akka -- Scalability in Scala and Java
Akka -- Scalability in Scala and JavaAkka -- Scalability in Scala and Java
Akka -- Scalability in Scala and Java

Akka, an actor framework written in Scala (that also supports Java) provides you with all the benefits commonly found in actor frameworks, but without the kinks. This presentation will explore actor based concurrency using Akka, and dwell on some of Akka's stregths, culminating in the equation "Transactional Memory + Actors = Transactors".

akkajavascala
Immutable  Collections
Mutable  Collections
Simpler  is  safer  
                  Indexing  by  first  character	
Java
List<String> keywords = Arrays.asList("Apple", "Banana", "Beer");
Map<Character, List<String>> result = new HashMap<Character, List<String>>();
for(String k : keywords) {
  char firstChar = k.charAt(1);                   Oops,  here’s  a  bug.  
  if(!result.containsKey(firstChar)) {
                                                  Anyone  noticed?	
    result.put(firstChar, new ArrayList<String>());
  }
  result.get(firstChar).add(k);
}
for (List<String> list : result.values()) {
  Collections.sort(list);
}

Scala
val keywords = List("Apple", "Banana", "Beer”)
val result = keywords.sorted.groupBy(_.head)
Another  example	
!
Java!
public List<String> empNames(ArrayList<Employee> employees) {!
      !ArrayList<String> result = new ArrayList<String>();!
      !for (Employee emp: employees) {!
      !       !result.add(emp.getName());!
      !}!
      !return result;!
}!
!
!
!
Scala!
def empNames(employees: List[Employee]) = employees map getName!

Recommended for you

Concurrency in Scala - the Akka way
Concurrency in Scala - the Akka wayConcurrency in Scala - the Akka way
Concurrency in Scala - the Akka way

This document discusses using Akka and actors for building scalable and concurrent applications in Scala. It introduces actors as fundamental units of computation that communicate asynchronously via message passing. Akka provides tools for creating actor systems and hierarchies. The document uses a monitoring application called Scotchdog as an example, with actors to represent services that are monitored by a watchdog actor. It describes how messages are used to start, stop and check services, and how the watchdog can aggregate status from child actors. The document also briefly mentions using Akka's scheduler and finite state machines to implement more complex actor behaviors.

The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter

A presentation at Twitter's official developer conference, Chirp, about why we use the Scala programming language and how we build services in it. Provides a tour of a number of libraries and tools, both developed at Twitter and otherwise.

configgyspecsostrich
Comparing JVM Web Frameworks - Devoxx France 2013
Comparing JVM Web Frameworks - Devoxx France 2013Comparing JVM Web Frameworks - Devoxx France 2013
Comparing JVM Web Frameworks - Devoxx France 2013

A comparison on JVM Web Frameworks. Includes strategies for choosing and results from research by InfoQ and devrates.com. Also, lots of pretty graphs. See blog post about this presentation at http://raibledesigns.com/rd/entry/devoxx_france_a_great_conference and video recording at http://raibledesigns.com/rd/entry/video_of_comparing_jvm_web

jvmwebframeworkscomparison
Map  combinator  paVern	
!
Java!
public List<String> empNames(ArrayList<Employee> employees) {!
      !ArrayList<String> res = new ArrayList<String>();!
      !for (Employee emp: employees) {!
      !       !res.add(emp.getName());!
      !}!
      !return res;!
}!
!
!
!                                        Really  need  to  encapsulate??	
Scala!
def empNames(employees: List[Employee]) = employees map getName!
Another  example	
!
Java!
public static int factorial(int n) {!
        int res = 1;!
        for (int i = 1; i <= n; i++) {!
            res *= i;!
        }!
        return res;!
    }!
!
!

Scala!
def factorial(n: Int) = (1 to n).reduce(_*_)!
Reduce  combinator  paVern	
!
Java!
public static int factorial(int n) {!
        int res = 1;!
        for (int i = 1; i <= n; i++) {!
            res *= i;!
        }!
        return res;!
    }!
!
!

Scala!
def factorial(n: Int) = (1 to n).reduce(_ * _)!
Combinatorics	
o  (1 to 5) combinations 2

  List(Vector(1, 2), Vector(1, 3), Vector(1, 4), Vector(1, 5), Vector(2,
  3), Vector(2, 4), Vector(2, 5), Vector(3, 4), Vector(3, 5), Vector(4,
  5))

o  (1 to 5).permutations

  "George W. Bush".split(" ").permutations

  List(Array(George, W., Bush), Array(George, Bush, W.), Array(W.,
  George, Bush), Array(W., Bush, George), Array(Bush, George,
  W.), Array(Bush, W., George))


o  "George W. Bush".split(" ").toSet.subsets

  List(Set(), Set(George), Set(W.), Set(Bush), Set(George, W.),
  Set(George, Bush), Set(W., Bush), Set(George, W., Bush))

Recommended for you

Emotiv epoc
Emotiv epocEmotiv epoc
Emotiv epoc

This document discusses the Emotiv EPOC neuroheadset. It is a 14 sensor wireless headset that detects thoughts, feelings, and expressions. It can detect mental commands like object manipulation and emotional states. The headset comes with demo games and software to control devices. While it has advantages for research and assisting handicaps, the technology is still in early stages with many beta applications and limitations to overcome. Further development could vastly improve detection and expand its uses.

Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala

This document discusses asynchronous I/O in Java and Scala using the Play Framework. It describes how LinkedIn uses a service-oriented architecture with hundreds of services making requests to each other. It then covers how Play supports non-blocking I/O using asynchronous code, promises, and futures to allow parallel requests without blocking threads. Key points covered include using map and flatMap to transform promises and futures, handling errors and timeouts, and the benefits of non-blocking I/O for scalability.

play frameworkjavalinkedin
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka

Slides for my talk event-sourced architectures with Akka. Discusses Akka Persistence as mechanism to do event-sourcing. Presented at Javaone 2014 and Jfokus 2015.

akkaakka persistencejava
++
            Collection  framework	
                     ++:             +:                 /:                /:                !
:+                   ::              :::                :                addString          !
aggregate            andThen         apply              applyOrElse       asInstanceOf       !
canEqual             collect         collectFirst       combinations      companion          !
compose              contains        containsSlice      copyToArray       copyToBuffer       !
corresponds          count           diff               distinct          drop               !
dropRight            dropWhile       endsWith           exists            filter             !
filterNot            find            flatMap            flatten           fold               !
foldLeft             foldRight       forall             foreach           genericBuilder     !
groupBy              grouped         hasDefiniteSize    head              headOption         !
indexOf              indexOfSlice    indexWhere         indices           init               !
inits                intersect       isDefinedAt        isEmpty           isInstanceOf       !
isTraversableAgain   iterator        last               lastIndexOf       lastIndexOfSlice   !
lastIndexWhere       lastOption      length             lengthCompare     lift               !
map                  mapConserve     max                maxBy             min                !
minBy                mkString        nonEmpty           orElse            padTo              !
par                  partition       patch              permutations      prefixLength       !
product              productArity    productElement     productIterator   productPrefix      !
reduce               reduceLeft      reduceLeftOption   reduceOption      reduceRight        !
reduceRightOption    repr            reverse            reverseIterator   reverseMap         !
reverse_:::          runWith         sameElements       scan              scanLeft           !
scanRight            segmentLength   seq                size              slice              !
sliding              sortBy          sortWith           sorted            span               !
splitAt              startsWith      stringPrefix       sum               tail               !
tails                take            takeRight          takeWhile         to                 !
toArray              toBuffer        toIndexedSeq       toIterable        toIterator         !
toList               toMap           toSeq              toSet             toStream           !
toString             toTraversable   toVector           transpose         union              !
unzip                unzip3          updated            view              withFilter         !
zip                  zipAll          zipWithIndex !
Placeholder  syntax  for  
    anonymous  functions	
Placeholder	
     Regular	
_ + 1             x => x + 1
_ * _             (x1, x2) => x1 * x2
(_: Int) * 2      (x: Int) => x * 2
if (_) x else y   z => if (z) x else y
_.map(f)          x => x.map(f)
_.map(_ + 1)      x => x.map(y => y + 1)
Distributed  &  multicore  
                            computing	
Core	

               •    Parallel collections (myList.par.sum)
               •    Futures & promises
               •    Actors
               •    STM – makes Java heap ACID compatible
3rd  Party	




               •    Hadoop
               •    Spark & Storm
               •    Plain old Java threads
               •    Scalding – Twitter’s Scala based MapReduce
                    implementation
Calling  Hadoop  from  
                   Scala	
Java
public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable>
output, Reporter reporter) throws IOException {
  String line = value.toString();
  StringTokenizer tokenizer = new StringTokenizer(line);
  while (tokenizer.hasMoreTokens()) {
    word.set(tokenizer.nextToken());
    output.collect(word, one);
  }
}


Scala
def map(key: LongWritable, value: Text, output: OutputCollector[Text,
IntWritable], reporter: Reporter) =
value split " " foreach (output collect (_, one))

Recommended for you

Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akka

Akka is using the Actors together with STM to create a unified runtime and programming model for scaling both UP (multi-core) and OUT (grid/cloud). Akka provides location transparency by abstracting away both these tangents of scalability by turning them into an ops task. This gives the Akka runtime freedom to do adaptive automatic load-balancing, cluster rebalancing, replication & partitioning

actorsconcurrencyakka
2.1 recap from-day_one
2.1 recap from-day_one2.1 recap from-day_one
2.1 recap from-day_one

This document provides a recap of concepts covered on day 1 of a Scala training, including: - How variables, methods, classes, tuples, and the Option type work differently in Scala compared to Java. - Key Scala features like first class functions, closures, pattern matching, and traits. - An overview of the schedule for day 1 which includes higher order functions, implicit conversions, XML support, and building a quiz game task.

Scala taxonomy
Scala taxonomyScala taxonomy
Scala taxonomy

The document provides an overview of Scala concepts for Java programmers, including object-oriented features, pattern matching, functional programming constructs like immutability and higher-order functions, actors and futures for concurrency, and implicits. Key concepts covered include case classes, lazy evaluation, parallel collections, currying, partial functions, and implicit parameters.

scala java taxonomy
Futures	

val from1 = future {conn1.fetch}
val from2 = future {conn2.fetch}
 
from1 either from2 onSuccess println
Parallel  collections	
List(1, 2, 3, 4, 5).par filter (_ % 2 == 0)
// ParVector(2, 4)
Spark	
val file = spark textFile "hdfs://...”

!
file.flatMap(_ split " ")

    .map(word => (word, 1))

    .reduceByKey(_ + _)!
!
Tail  recursion  optimization	
Recursion in Java has an Achilles’ heel:
the call stack

def factorial(n: Int, res: Long = 1): Long =
  if(n == 0) res
  else factorial(n - 1, (res * n))

Recommended for you

Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World

Scala is becoming the language of choice for many development teams. This talk highlights how Scala excels in the world of multi-core processing and explores how it compares to Java 8. Video Presentation: http://youtu.be/8vxTowBXJSg

bti360java 8scala
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics

This document summarizes key similarities and differences between Scala and Java types, variables, methods, classes, collections, control structures, and other language features. Some of the main points covered include: - Type definitions, variables, and methods are defined similarly but with different syntax in Scala vs Java - Classes and traits in Scala are like classes and interfaces in Java - Scala avoids static methods and instead uses singleton objects - Control structures like if/else, for loops, and exceptions work similarly - Scala supports features like tuples, pattern matching, and expression-oriented programming that have no direct equivalent in Java

Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?

Scala er et Java-relateret, statisk typet programmeringssprog i hastig fremmarch. Sproget kombinerer aspekter fra objekt- og funktionsorienterede sprog og fokuserer på skalerbarhed og effektivitet, både på det kodemæssige og afviklingsmæssige niveau. Syntaksen er elegant og koncis. Samtidig indeholder sproget stærke konstruktioner til understøttelse af parallelle applikationer, der udnytter fremtidens hardwarearkitekturer. Java som sprog har ikke bevæget sig meget de seneste år. Vi har stadig ikke closures eller funktionelle aspekter som f.eks. C# har haft siden version 3. Er Scala svaret på enhver Javaudviklers bønner eller er sproget kun interessant for tågehoveder som mig, som begynder at synes bedre og bedre om funktionsorientering? Er den store portion syntaktisk sukker, Scala bringer på bordet, bare tomme kalorier?

java scala danish cd10
Safer  string  composition	
•  Standard string composition:
 “I’m “ + name + “, “ + age + “ years old”


•  Formatted:
 “I’m %s, %d years old”.format(name, age)
 java.util.IllegalFormatConversionException



•  Interpolated:
 s“I’m $name, $age years old”
Create  your  own  
         interpolations	
xml”””<body>
         <a href = “http://…”> $text</a>
      </body> ”””
Expression  simplification  –  Java	
public Expr simplify(Expr expr) {
  if (expr instanceof UnOp) {
      UnOp unOp = (UnOp) expr;
      if (unOp.getOperator().equals("-")) {
          if (unOp.getArg() instanceof UnOp) {
              UnOp arg = (UnOp) unOp.getArg();
              if (arg.getOperator().equals("-"))
                  return arg.getArg();
          }
      }
  }
  if (expr instanceof BinOp) {
      BinOp binOp = (BinOp) expr;
      if (binOp.getRight() instanceof Number) {
          Number arg = (Number) binOp.getRight();
          if (binOp.getOperator().equals("+") && arg.getNum() == 0)
              return binOp.getLeft();
      }
  }
  return expr;
}
PaVern  matching  
     Expression  simplification  -­‐‑  Scala	


def simplify(expr: Expr): Expr = expr match {!
    case UnOp("-", UnOp("-", e)) => simplify(e)!
    case BinOp("+", e, Number(0)) => simplify(e)!
    case _ => expr!
}!

Recommended for you

Scala
ScalaScala
Scala

Scala is a programming language that runs on the Java Virtual Machine (JVM) and is designed to express common programming patterns in a concise, elegant, and type-safe way. Some key points about Scala include that it is functional and object-oriented, statically typed, and allows seamless integration with Java. Scala code is often more concise than equivalent Java code through features like pattern matching and immutable data structures. Functional programming principles like pure functions, recursion, and avoiding side effects are emphasized in Scala.

Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala

An overview of the Scala programming language, focusing on differences with Java and in language novelties (in Italian)

scala java introduction trenta3dev
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin

The benefits of Kotlin compared to Java development and how to get started, by Iskuhi Sargsyan @ 0+X.

kotlinjava
Value  classes	
            Extensibility minus boxing overhead!
!
class Meter(val v: Double) extends AnyVal {!
     def plus (that: Meter) = new Meter(v + that.v) !
}!
!
Compiler generates!

object Meter {!
     def plus(this: Meter, that: Meter) = new Meter(v + that.v)!
}!
Compile-­‐‑time  
        Meta-­‐‑programming	
•  Language virtualization (overloading/overriding
   semantics of the original programming language to
   enable deep embedding of DSLs),

•  Program reification (providing programs with means to
   inspect their own code),

•  Self-optimization (self-application of domain-specific
   optimizations based on program reification),

•  Algorithmic program construction (generation of
   code that is tedious to write with the abstractions
   supported by a programming language).
Meta  programming	
                    Language	
 Operate  on	
               Type     Expressive Runtime  
                                                           safe	
   ness	
     Performance  
                                                                               overhead	
Textual             C,  Scala	
      Text	
                ✗	
      Low	
      No	
preprocessors	
Template            C++	
            Text	
                ✗	
      Low	
      No	
systems	
Compile-­‐‑time     Haskell,         Abstract  (typed)     ✔	
      High	
     No	
meta-­‐‑            Scala  2.10,     Syntax  trees	
                	
programming  	
     Nemerle	
Byte  code          Java,  Scala	
 byte-­‐‑code	
          ✗	
      Medium	
   No	
manipulation	
“Dynamic”           Ruby,  Scala	
 objects	
               ✗	
      High	
     Yes	
reflection	
Run-­‐‑time         Java,  Scala	
 objects	
               ✗	
      High	
     Yes	
reflection
Scala  macros	
•  Full blown compile time meta-
   programming
•  Access to the compiler API
•  Written in Scala
•  Hygienic
•  Type-safe

Recommended for you

CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy

This document provides an introduction to Groovy for Java developers. It discusses Groovy's features such as closures, optional typing and syntax, and how it compiles to Java bytecode. It then provides examples of writing a simple Groovy script to generate XML, using closures, mocking objects in tests, and building projects with Ant.

groovy
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala

The document introduces Scala and provides an overview of Scala basics including variables, functions, objects, classes, traits, pattern matching, for-comprehensions and more. It also discusses Scala's capabilities for generic programming, lazy evaluation, and integration with Java. Examples are provided throughout to demonstrate Scala concepts.

sdc2011scala
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)

The document discusses code generation and abstract syntax tree (AST) transformations. It provides an overview of Project Lombok, a Java library that generates boilerplate code through annotation processing and AST transformations. It also discusses how to analyze and transform code by visiting and rewriting AST nodes, giving examples of checking for null checks and instanceof expressions.

astgreachgroovy
Macros  –  safe  printf	
printf(format: String, params: Any*)!
printf(“value is %d”, “boom”)!
// runtime exception!
java.util.IllegalFormatConversionException: d != java.lang.String!
!
!




Macro implementation!
def printf(format: String, params: Any*): Unit = macro printf_impl!
def printf_impl(c: Context)(format: c.Expr[String], params:
c.Expr[Any]*): c.Expr[Unit] = ...!
Efficient  Assert	

assert(2 + 2 == 4, "weird arithmetic")

// 2 + 2 == 4 will be evaluated only if
assertions were enabled
Macros  –  units  of  measure	
val gravityOnEarth = u(9.81, "m/s^2")!
!
val heightOfMyOfficeWindow = u(3.5, "m")!
!
val speedOfImpact =

    sqrt(2.0 * gravityOnEarth * heightOfMyOfficeWindow)!
!
val monthsInAYear = 10b12!




    hVp://scalamacros.org/usecases/units-­‐‑of-­‐‑measure.html
Macros  –  type  providers	


type MySqlDb(connString: String) = macro ...!
type MyDb = Base with MySqlDb("Server=127.0.0.1;Database=Foo;”)!
val products = new MyDb().products!
products.filter(p => p.name.startsWith("foo"))!
 !


!
!
!
!


     http://scalamacros.org/usecases/type-providers.html!
     Inspired by F# type providers!

Recommended for you

ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う

The document discusses Scala programming concepts including object-oriented programming, functional programming, collections, pattern matching, and more. It provides code examples of defining objects and classes, functions, for expressions, match expressions, case classes, traits, generics, and collections like List and Map.

scalabpstudy
Groovy intro for OUDL
Groovy intro for OUDLGroovy intro for OUDL
Groovy intro for OUDL

The document provides an introduction to Groovy, including: - The presenter's background in programming languages including Java since 1996 and using Groovy since 2009. - The presentation objectives are to recognize Groovy code, get interested in Groovy coding, and introduce some key Groovy concepts without focusing on Grails, Geb, or Spock yet. - Groovy is a dynamic language that extends Java with features like closures, GStrings, and optional semicolons to enable less code and more clarity while compiling to Java classes for seamless integration.

groovy java programming
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala

This document provides an introduction to the Scala programming language. It discusses that Scala is a hybrid language that is both object-oriented and functional, runs on the JVM, and provides seamless interoperability with Java. It highlights features of Scala such as pattern matching, traits, case classes, immutable data structures, lazy evaluation, and actors for concurrency.

scalafunctional programmingintroduction
Type  macros  
            Injecting  async  methods	
class D extends Lifter {!
    !def x = 2!
    !// def asyncX = future { 2 }!
}!
!
val d = new D!
d.asyncX onComplete {!
    !case Success(x) => println(x)!
    !case Failure(_) => println("failed")!
}!

  hVp://scalamacros.org/talks/2012-­‐‑12-­‐‑18-­‐‑MacroParadise.pdf
More  uses  of  macros	
•    Ad-hoc code style and code-smell detector
•    Advanced domain-specific languages
•    Logging with minimal overhead
•    Pre-compiled SQL queries
•    GPU optimized code (see Scalaxy, ScalaCL)
•    Macro annotations
     o  @Cached
Macro  annotations	
class atomic extends MacroAnnotation {
  def complete(defn: _) = macro(“backing field”)
  def typeCheck(defn: _) = macro("return defn itself”)
}

@atomic var fld: Int
GPU  compilation	
•  Enablers: Immutability, Macros
•  ScalaCL Collections
   OpenCL-backed collections that look and behave
   like standard Scala collections (work in progress).

•  ScalaCL Compiler Plugin
   optimizes Scala programs at compile-time,
   transforming regular Scala loops into faster code
   and transforming Scala functions given to ScalaCL
   Collections into OpenCL kernels.

Recommended for you

Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy

My talk about Functional Programming with Groovy at Greach Greach http://greach.es/ the Groovy spanish conf Date: 04-11-2011

groovyfunctional programming
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec

This document provides an introduction to the Scala programming language. It discusses how Scala runs on the Java Virtual Machine, supports both object-oriented and functional programming paradigms, and provides features like pattern matching, immutable data structures, lazy evaluation, and parallel collections. Scala aims to be concise, expressive, and extensible.

scala
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3

The document discusses several Kotlin advanced topics including delegated properties, lazy properties, objects, higher-order functions, lambdas, inline functions, and standard library functions like apply, also, let. It explains concepts like lazy initialization with lazy properties, property delegation, object expressions and declarations, functional programming with higher-order functions and lambdas, and inline functions for performance. It also covers utility functions in the standard library for working with objects and collections.

kotlinjava
An  extremely  hack-­‐‑able  compiler	
> scala -Xshow-phases!
    phase name id description!
    ---------- -- -----------!
        parser   1 parse source into ASTs, perform simple desugaring!
         namer   2 resolve names, attach symbols to named trees!
packageobjects   3 load package objects!
         typer   4 the meat and potatoes: type the trees!
        patmat   5 translate match expressions!
superaccessors   6 add super accessors in traits and nested classes!
    extmethods   7 add extension methods for inline classes!
       pickler   8 serialize symbol tables!
     refchecks   9 reference/override checking, translate nested objects!
  selectiveanf 10 ANF pre-transform for @cps!
  selectivecps 11 @cps-driven transform of selectiveanf assignments!
       uncurry 12 uncurry, translate function values to anonymous classes!
     tailcalls 13 replace tail calls by jumps!
    specialize 14 @specialized-driven class and method specialization!
 explicitouter 15 this refs to outer pointers, translate patterns!
       erasure 16 erase types, add interfaces for traits!
   posterasure 17 clean up erased inline classes!
      lazyvals 18 allocate bitmaps, translate lazy vals into lazified defs!
    lambdalift 19 move nested functions to top level!
  constructors 20 move field definitions into constructors!
       flatten 21 eliminate inner classes!
         mixin 22 mixin composition!
       cleanup 23 platform-specific cleanups, generate reflective calls!
         icode 24 generate portable intermediate code!
       inliner 25 optimization: do inlining!
inlinehandlers 26 optimization: inline exception handlers!
      closelim 27 optimization: eliminate uncalled closures!
           dce 28 optimization: eliminate dead code!
           jvm 29 generate JVM bytecode!
      terminal 30 The last phase in the compiler chain!
Type-­‐‑safe  failures	
try { 2 / x } catch { case e:Throwable => 0}



    in 2.10:
Try (2 / 0) // returns Failure
Try (2 / 1) // returns Success

Try (2 / x) getOrElse (0)
List(0,1,0,2).map (x=> Try(2 / x)) filter(_.isSuccess)
// List(Success(2), Success(1))
Implicit  parameters	
implicit val db = getDB!
def store(employee: Employee)(implicit db: DB)!
!
store(emp1oyee1) //db is passed implicitly!
Implicit  methods	
implicit def toEuro(x: Currency): Euro = …!
!
def transfer(amount: Euro) {!
       println(”transferred” + amount)!
}!
!
// dollar is automatically converter to euro!
transfer(Dollar(3.0))!
transferred 2.25 Euros!

Recommended for you

What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7

A lap around the new features in C# 7. For a better experience, go to https://docs.com/paulo-morgado/9635/what-s-new-in-c-7

c#c# 7programar2017
Ast transformations
Ast transformationsAst transformations
Ast transformations

The document discusses abstract syntax tree (AST) transformations in Groovy and Java. It covers several tools and techniques for AST transformations including Lombok, Groovy, CodeNarc, IntelliJ IDEA, Mirah macros, and how they allow generating code, performing static analysis, and rewriting code at compile time through analyzing and modifying the AST. The key topics are how these tools work by compiling code to an AST, analyzing and modifying the AST nodes, and sometimes generating source code from the transformed AST.

ast transformationslombokast
Spring and dependency injection
Spring and dependency injectionSpring and dependency injection
Spring and dependency injection

The document contains code examples of using the Spring framework for Java applications. It includes code for a basic "Hello World" example using Spring and EJB. It also includes code examples of implementing data access using JDBC templates in Spring to avoid boilerplate JDBC code. The document lists some key features of Spring like its AOP framework, boilerplate reduction through templates, and IOC container. It also includes a YouTube link about Spring AOP.

springdependency injection
Implicit  classes	
!
implicit class StringExtensions(s: String) {!
   def words = s split " "!
}!
!
!
“hello world”.words   // Array(hello, world)!
Environments	
               -­‐‑  Currently  the  most  mature	


               -­‐‑  Formally  supported  by  TypeSafe	




  ublime	
     -­‐‑  Through  Ensime	




  Scala  REPL
DSLs  (accounting)	
Rules to calculate an employee's paycheck:!
  employee's gross salary for 2 weeks!
  minus deductions for!
    federalIncomeTax, which is 25% of gross!
    stateIncomeTax,     which is 5% of gross!
    insurancePremiums, which are 500 in gross’s currency!
    retirementFundContributions are 10% of gross!
!




   hVp://ofps.oreilly.com/titles/9780596155957/DomainSpecificLanguages.html
DSLs  (JSON)	
("person" ->!
   ("name" -> "Joe") ~!
   ("age" -> 35) ~!
   ("spouse" ->!
      ("person" ->!
         ("name" -> "Marilyn") ~!
         ("age" -> 33)!
      )!
   )!
)!

Recommended for you

[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf

Kief Morris rethinks the infrastructure code delivery lifecycle, advocating for a shift towards composable infrastructure systems. We should shift to designing around deployable components rather than code modules, use more useful levels of abstraction, and drive design and deployment from applications rather than bottom-up, monolithic architecture and delivery.

infrastructure as codeclouddevops
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time

Is your patent a vanity piece of paper for your office wall? Or is it a reliable, defendable, assertable, property right? The difference is often quality. Is your patent simply a transactional cost and a large pile of legal bills for your startup? Or is it a leverageable asset worthy of attracting precious investment dollars, worth its cost in multiples of valuation? The difference is often quality. Is your patent application only good enough to get through the examination process? Or has it been crafted to stand the tests of time and varied audiences if you later need to assert that document against an infringer, find yourself litigating with it in an Article 3 Court at the hands of a judge and jury, God forbid, end up having to defend its validity at the PTAB, or even needing to use it to block pirated imports at the International Trade Commission? The difference is often quality. Quality will be our focus for a good chunk of the remainder of this season. What goes into a quality patent, and where possible, how do you get it without breaking the bank? ** Episode Overview ** In this first episode of our quality series, Kristen Hansen and the panel discuss: ⦿ What do we mean when we say patent quality? ⦿ Why is patent quality important? ⦿ How to balance quality and budget ⦿ The importance of searching, continuations, and draftsperson domain expertise ⦿ Very practical tips, tricks, examples, and Kristen’s Musts for drafting quality applications https://www.aurorapatents.com/patently-strategic-podcast.html

patentspatent applicationpatent prosecution
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges

accommodate the strengths, weaknesses, threats and opportunities of autonomous vehicles

automotive self-driving car technology
DSL  (XPath  /  json)	

val titles = xml  "channel"  "item"  "title“

val titles2 = json  "feed"  "entry"  "title" @ "$t"




  github.com/razie/snakked
DSLs  
         testing  frameworks	

val emptyStack = new Stack[String]
  evaluating { emptyStack.pop() } should
     produce [NoSuchElementException]
Full  access  to  the  compiler	
import tools.reflect.ToolBox!
import reflect.runtime.{currentMirror => cm}!
!
val tb = cm.mkToolBox()!
!
scala> val tree = tb parse "(5 + 9) * 3"!
tree: tb.u.Tree = 5.$plus(9).$times(3)!
!
scala> tb eval tree!
res1: Any = 42!
Reflection	

val take = typeOf[List[_]].member(TermName("take")).asMethod!
!
reflect(List(1,3,2,4)).reflectMethod(take)(2) // List(1,2)!

Recommended for you

Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant

Password Rotation in 2024 is still Relevant

passwordmanagementrotation
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses

CIO Council Cal Poly Humboldt September 22, 2023

national research platformdistributed supercomputerdistributed systems
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces

An invited talk given by Mark Billinghurst on Research Directions for Cross Reality Interfaces. This was given on July 2nd 2024 as part of the 2024 Summer School on Cross Reality in Hagenberg, Austria (July 1st - 7th)

augmented realitycross realityvirtual reality
Testing	
•  ScalaCheck
  o  Auto-generation of inputs and mocks.
  o  Composable check units
  o  Inspired by Haskell QuickCheck

•  ScalaTest
  o  TDD, BDD, FeatureSpec
  o  Selenium DSL

•  Specs2
  o  TDD, BDD, Datatables support
  o  Integration with Mockito, EasyMock and JMock
  o  "hello world" must be matching("h.* w.*")

•  JUnit
ScalaCheck  
       (inspired  by  Haskell  QuickCheck)          	

scala> val sqrt = forAll {(n: Int) => math.sqrt(n*n) == n }

scala> propSqrt.check
! Falsified after 1 passed tests:
> -1
BDD  with  ScalaTest	
describe("A Stack") {
it("should throw NoSuchElementException if an empty stack is popped") in {
    val emptyStack = new Stack[String]
    evaluating { emptyStack.pop() } should produce
[NoSuchElementException]
  }
 it("should pop values in last-in-first-out order") { … }
}
How  to  learn	

•    twitter.github.com/scala_school
•    Effective Scala
•    Coursera Scala course (50K students last year)
•    Simply scala (interactive learning)
•    Programming in scala book
•    Stackoverflow

Recommended for you

How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx

How do we build an IoT product, and make it profitable? Talk from the IoT meetup in March 2024. https://www.meetup.com/iot-sweden/events/299487375/

iot
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing

Invited Remote Lecture to SC21 The International Conference for High Performance Computing, Networking, Storage, and Analysis St. Louis, Missouri November 18, 2021

distributed supercomputerdistributed machine learning
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf

These fighter aircraft have uses outside of traditional combat situations. They are essential in defending India's territorial integrity, averting dangers, and delivering aid to those in need during natural calamities. Additionally, the IAF improves its interoperability and fortifies international military alliances by working together and conducting joint exercises with other air forces.

air force fighter planebiggest submarinezambia port
Contributing  
          	
  docs.scala-­‐‑lang.org/sips
Contributing  
 github.com/scala
Things  to  be  aware  of	
✗  Scala Compiler has to do much more => slower

✗  Tooling is not perfect
   (debugging, synthetic frames, macros support)
   Getting better every day.

✗  Language is rapidly evolving.
   Deprecations should be expected.
Scala 2013 review

Recommended for you

Quantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLMQuantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLM

Quantum Communications Q&A with Gemini LLM. These are based on Shannon's Noisy channel Theorem and offers how the classical theory applies to the quantum world.

quantum communicationsshannon's channel theoremclassical theory
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf

Profile portofolio

Measuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at TwitterMeasuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at Twitter

Widya Salim and Victor Ma will outline the causal impact analysis, framework, and key learnings used to quantify the impact of reducing Twitter's network latency.

More Related Content

What's hot

Scala vs java 8
Scala vs java 8Scala vs java 8
Scala vs java 8
François Sarradin
 
Scala
ScalaScala
Functional Objects & Function and Closures
Functional Objects  & Function and ClosuresFunctional Objects  & Function and Closures
Functional Objects & Function and Closures
Sandip Kumar
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
Derek Chen-Becker
 
Hello, Guava !
Hello, Guava !Hello, Guava !
Hello, Guava !
輝 子安
 
Demystifying functional programming with Scala
Demystifying functional programming with ScalaDemystifying functional programming with Scala
Demystifying functional programming with Scala
Denis
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
Łukasz Bałamut
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
Ruslan Shevchenko
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
Roberto Casadei
 
All about scala
All about scalaAll about scala
All about scala
Yardena Meymann
 
Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008
Yardena Meymann
 
Scala Intro
Scala IntroScala Intro
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
Tomer Gabel
 
Scala cheatsheet
Scala cheatsheetScala cheatsheet
Scala cheatsheet
Arduino Aficionado
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
Jesper Kamstrup Linnet
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
Garth Gilmour
 
Intro to Functional Programming in Scala
Intro to Functional Programming in ScalaIntro to Functional Programming in Scala
Intro to Functional Programming in Scala
Shai Yallin
 
Scala Intro
Scala IntroScala Intro
Scala Intro
Paolo Platter
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
futurespective
 
Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
Eelco Visser
 

What's hot (20)

Scala vs java 8
Scala vs java 8Scala vs java 8
Scala vs java 8
 
Scala
ScalaScala
Scala
 
Functional Objects & Function and Closures
Functional Objects  & Function and ClosuresFunctional Objects  & Function and Closures
Functional Objects & Function and Closures
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
 
Hello, Guava !
Hello, Guava !Hello, Guava !
Hello, Guava !
 
Demystifying functional programming with Scala
Demystifying functional programming with ScalaDemystifying functional programming with Scala
Demystifying functional programming with Scala
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
 
All about scala
All about scalaAll about scala
All about scala
 
Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008Scala at HUJI PL Seminar 2008
Scala at HUJI PL Seminar 2008
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
 
Scala cheatsheet
Scala cheatsheetScala cheatsheet
Scala cheatsheet
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
 
Intro to Functional Programming in Scala
Intro to Functional Programming in ScalaIntro to Functional Programming in Scala
Intro to Functional Programming in Scala
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
 
Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
 

Viewers also liked

Akka -- Scalability in Scala and Java
Akka -- Scalability in Scala and JavaAkka -- Scalability in Scala and Java
Akka -- Scalability in Scala and Java
Nadav Wiener
 
Concurrency in Scala - the Akka way
Concurrency in Scala - the Akka wayConcurrency in Scala - the Akka way
Concurrency in Scala - the Akka way
Yardena Meymann
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
Alex Payne
 
Comparing JVM Web Frameworks - Devoxx France 2013
Comparing JVM Web Frameworks - Devoxx France 2013Comparing JVM Web Frameworks - Devoxx France 2013
Comparing JVM Web Frameworks - Devoxx France 2013
Matt Raible
 
Emotiv epoc
Emotiv epocEmotiv epoc
Emotiv epoc
Ravi Jakashania
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
Sander Mak (@Sander_Mak)
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akka
nartamonov
 

Viewers also liked (8)

Akka -- Scalability in Scala and Java
Akka -- Scalability in Scala and JavaAkka -- Scalability in Scala and Java
Akka -- Scalability in Scala and Java
 
Concurrency in Scala - the Akka way
Concurrency in Scala - the Akka wayConcurrency in Scala - the Akka way
Concurrency in Scala - the Akka way
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
 
Comparing JVM Web Frameworks - Devoxx France 2013
Comparing JVM Web Frameworks - Devoxx France 2013Comparing JVM Web Frameworks - Devoxx France 2013
Comparing JVM Web Frameworks - Devoxx France 2013
 
Emotiv epoc
Emotiv epocEmotiv epoc
Emotiv epoc
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Event-sourced architectures with Akka
Event-sourced architectures with AkkaEvent-sourced architectures with Akka
Event-sourced architectures with Akka
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akka
 

Similar to Scala 2013 review

2.1 recap from-day_one
2.1 recap from-day_one2.1 recap from-day_one
2.1 recap from-day_one
futurespective
 
Scala taxonomy
Scala taxonomyScala taxonomy
Scala taxonomy
Radim Pavlicek
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
BTI360
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
wpgreenway
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
Jesper Kamstrup Linnet
 
Scala
ScalaScala
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Lorenzo Dematté
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
Benjamin Waye
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
Codecamp Romania
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
Christian Baranowski
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
HamletDRC
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う
bpstudy
 
Groovy intro for OUDL
Groovy intro for OUDLGroovy intro for OUDL
Groovy intro for OUDL
J David Beutel
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Aleksandar Prokopec
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
Arturo Herrero
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
Loïc Descotte
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kirill Rozov
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
Paulo Morgado
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
HamletDRC
 
Spring and dependency injection
Spring and dependency injectionSpring and dependency injection
Spring and dependency injection
Steve Ng
 

Similar to Scala 2013 review (20)

2.1 recap from-day_one
2.1 recap from-day_one2.1 recap from-day_one
2.1 recap from-day_one
 
Scala taxonomy
Scala taxonomyScala taxonomy
Scala taxonomy
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
 
Scala
ScalaScala
Scala
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う
 
Groovy intro for OUDL
Groovy intro for OUDLGroovy intro for OUDL
Groovy intro for OUDL
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
Spring and dependency injection
Spring and dependency injectionSpring and dependency injection
Spring and dependency injection
 

Recently uploaded

[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
Aurora Consulting
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
huseindihon
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
Larry Smarr
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
Adam Dunkels
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
Larry Smarr
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
jackson110191
 
Quantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLMQuantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLM
Vijayananda Mohire
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 
Measuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at TwitterMeasuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at Twitter
ScyllaDB
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
ScyllaDB
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
Awais Yaseen
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
Andrey Yasko
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
Yevgen Sysoyev
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
Stephanie Beckett
 

Recently uploaded (20)

[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
Quality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of TimeQuality Patents: Patents That Stand the Test of Time
Quality Patents: Patents That Stand the Test of Time
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
The Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU CampusesThe Increasing Use of the National Research Platform by the CSU Campuses
The Increasing Use of the National Research Platform by the CSU Campuses
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
How to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptxHow to Build a Profitable IoT Product.pptx
How to Build a Profitable IoT Product.pptx
 
The Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive ComputingThe Rise of Supernetwork Data Intensive Computing
The Rise of Supernetwork Data Intensive Computing
 
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdfINDIAN AIR FORCE FIGHTER PLANES LIST.pdf
INDIAN AIR FORCE FIGHTER PLANES LIST.pdf
 
Quantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLMQuantum Communications Q&A with Gemini LLM
Quantum Communications Q&A with Gemini LLM
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 
Measuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at TwitterMeasuring the Impact of Network Latency at Twitter
Measuring the Impact of Network Latency at Twitter
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
 
Comparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdfComparison Table of DiskWarrior Alternatives.pdf
Comparison Table of DiskWarrior Alternatives.pdf
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
 

Scala 2013 review

  • 1. 2013  overview Sagie Davidovich singularityworld.com linkedin.com/in/sagied
  • 2. 2013  JVM  Languages  Landscape Static Object  Oriented Functional Dynamic
  • 6. Thoughtworks   Technology  Radar  2012 Evaluate Consider Hold
  • 7. Language  Design   Trade-­‐‑offs Expressiveness Performance Complexity
  • 8. Positioning Object   Oriented JVM Statically   Typed Functional
  • 9. Prof.  Martin  Odersky •  Designer of Java Generics •  Creator of JavaC •  Prof. at EPFL •  ACM Fellow •  Founder of
  • 10. Class  Employee  -­‐‑  Java public class Employee implements Serializable { public boolean equals(Object o) { private final String firstName; if (this == o) { private final String lastName; return true;   } public Employee (String firstName, String lastName) { if (o == null || getClass() != o.getClass()) { this.firstName = firstName; return false; this.lastName = lastName; } } Employee employee = (Employee) o;   if (firstName != null ? !firstName.equals(employee.firstName) : public String getFirstName() { person.firstName != null) { return lastName; return false; } }   if (lastName != null ? !lastName.equals(employee.lastName) : employee.lastName != null) { public String getLastName() { return true; return firstName;   } } return true; Oops,  should  be  false   public Employee withFirstName(String firstName) {   } Anyone  noticed? return new Employee (firstName, lastName); } public int hashCode() { int result = firstName != null ? firstName.hashCode() : 0;   result = 31 * result + (lastName != null ? public Employee withLastName(String lastName) { lastName.hashCode() : 0); return new Employee (firstName, lastName); return result; } }     public String toString() { return "Employee(" + firstName + "," + lastName + ")"; } }
  • 11. Class  Employee  -­‐‑  Scala case class Employee(firstName: String, lastName: String)! •  Constructor •  Copy  constructors •  Fields •  GeVers  /  (seVers) •  equals •  hashCode •  toString •  Recursive  decomposition •  Companion  object
  • 12. Singletons Java public class OneAndOnly { private final static OneAndOnly INSTANCE = new OneAndOnly(); private OneAndOnly() {} public static OneAndOnly getInstance() { return OneAndOnly.INSTANCE; } } Scala object OneAndOnly
  • 13. Everything  is  an  object 1.+(2) Same as 1+2
  • 14. Every  block  returns  a  value   (no  statements,  only  expressions) def add (x:Int, y:Int) = x + {val tmp = y; tmp * 3}! ! if (x > 2) 3 else 4! ! val doubled = for(i <- (1 to 10)) yield i * 2!
  • 15. Type  inference scala> val x = 3 x: Int = 3 scala> def x(y:Int) = y * 9 x: (y: Int)Int scala> def x(y:Int) = if (y == 1) List(y) else Set(y) x: (y: Int) Iterable[Int]
  • 16. Higher  order  functions List(1, 2, 3).map((x: Int) => x + 1) = List(1, 2, 3).map(x => x + 1) // type is inferred = List(1, 2, 3).map(_ + 1) // placeholder notation
  • 17. Universal  access  principle   import System._! ! class Clz {! def w = currentTimeMillis / 1000! val x = currentTimeMillis / 1000! var y = currentTimeMillis / 1000! lazy val z = currentTimeMillis / 1000! }!
  • 18. Default  methods   apply  and  unapply object Square{ def apply(d: Double) = d * d def unapply(d: Double) = Some(math.sqrt(d)) } //apply val s = Square(3) // 9 // unaply 16 match { case Square(x) => x } // 4
  • 19. Curried  functions •  Add new flow control and language constructs! def loop(n: Int)(body: => Any) {! (0 until n) foreach (n => body)! }! ! loop(2) {! println("IM IN YR LOOP!")! }! •  Multiple varargs lists are possible!! def crossProduct[L,R](left: L*)(right: R*) =
 for (l <- left; r <- right) yield (l,r)! crossProduct(1,2,3)(‘a’,’b’,’c’)! •  Partially applied functions! !
  • 20. Multiple  inheritance  without   the  diamond  problem
  • 22. Type  system Strong Explicit  +  Inferred Traits Self  types Static  +  Dynamic Functional Erasure Nominal  +  Structural Type  aliases Nonnullable Monads Implicit Co/Contra-­‐‑variant Existential Value  +  Reference Case  classes Path  dependent Anonymous
  • 23. Type  safety  (Java  example) // compiles fine in Java (arrays are co-variant!!) int[] ints = {3}; Object[] objects = ints; // ArrayStoreException in runtime objects[0] = new Object();
  • 24. Structural  types object Closer { def using(closeable: { def close(): Unit }, f: => Unit) { try { f } finally { closeable.close } } }
  • 27. Simpler  is  safer   Indexing  by  first  character Java List<String> keywords = Arrays.asList("Apple", "Banana", "Beer"); Map<Character, List<String>> result = new HashMap<Character, List<String>>(); for(String k : keywords) { char firstChar = k.charAt(1); Oops,  here’s  a  bug.   if(!result.containsKey(firstChar)) { Anyone  noticed? result.put(firstChar, new ArrayList<String>()); } result.get(firstChar).add(k); } for (List<String> list : result.values()) { Collections.sort(list); } Scala val keywords = List("Apple", "Banana", "Beer”) val result = keywords.sorted.groupBy(_.head)
  • 28. Another  example ! Java! public List<String> empNames(ArrayList<Employee> employees) {! !ArrayList<String> result = new ArrayList<String>();! !for (Employee emp: employees) {! ! !result.add(emp.getName());! !}! !return result;! }! ! ! ! Scala! def empNames(employees: List[Employee]) = employees map getName!
  • 29. Map  combinator  paVern ! Java! public List<String> empNames(ArrayList<Employee> employees) {! !ArrayList<String> res = new ArrayList<String>();! !for (Employee emp: employees) {! ! !res.add(emp.getName());! !}! !return res;! }! ! ! ! Really  need  to  encapsulate?? Scala! def empNames(employees: List[Employee]) = employees map getName!
  • 30. Another  example ! Java! public static int factorial(int n) {! int res = 1;! for (int i = 1; i <= n; i++) {! res *= i;! }! return res;! }! ! ! Scala! def factorial(n: Int) = (1 to n).reduce(_*_)!
  • 31. Reduce  combinator  paVern ! Java! public static int factorial(int n) {! int res = 1;! for (int i = 1; i <= n; i++) {! res *= i;! }! return res;! }! ! ! Scala! def factorial(n: Int) = (1 to n).reduce(_ * _)!
  • 32. Combinatorics o  (1 to 5) combinations 2 List(Vector(1, 2), Vector(1, 3), Vector(1, 4), Vector(1, 5), Vector(2, 3), Vector(2, 4), Vector(2, 5), Vector(3, 4), Vector(3, 5), Vector(4, 5)) o  (1 to 5).permutations "George W. Bush".split(" ").permutations List(Array(George, W., Bush), Array(George, Bush, W.), Array(W., George, Bush), Array(W., Bush, George), Array(Bush, George, W.), Array(Bush, W., George)) o  "George W. Bush".split(" ").toSet.subsets List(Set(), Set(George), Set(W.), Set(Bush), Set(George, W.), Set(George, Bush), Set(W., Bush), Set(George, W., Bush))
  • 33. ++ Collection  framework ++: +: /: /: ! :+ :: ::: : addString ! aggregate andThen apply applyOrElse asInstanceOf ! canEqual collect collectFirst combinations companion ! compose contains containsSlice copyToArray copyToBuffer ! corresponds count diff distinct drop ! dropRight dropWhile endsWith exists filter ! filterNot find flatMap flatten fold ! foldLeft foldRight forall foreach genericBuilder ! groupBy grouped hasDefiniteSize head headOption ! indexOf indexOfSlice indexWhere indices init ! inits intersect isDefinedAt isEmpty isInstanceOf ! isTraversableAgain iterator last lastIndexOf lastIndexOfSlice ! lastIndexWhere lastOption length lengthCompare lift ! map mapConserve max maxBy min ! minBy mkString nonEmpty orElse padTo ! par partition patch permutations prefixLength ! product productArity productElement productIterator productPrefix ! reduce reduceLeft reduceLeftOption reduceOption reduceRight ! reduceRightOption repr reverse reverseIterator reverseMap ! reverse_::: runWith sameElements scan scanLeft ! scanRight segmentLength seq size slice ! sliding sortBy sortWith sorted span ! splitAt startsWith stringPrefix sum tail ! tails take takeRight takeWhile to ! toArray toBuffer toIndexedSeq toIterable toIterator ! toList toMap toSeq toSet toStream ! toString toTraversable toVector transpose union ! unzip unzip3 updated view withFilter ! zip zipAll zipWithIndex !
  • 34. Placeholder  syntax  for   anonymous  functions Placeholder Regular _ + 1 x => x + 1 _ * _ (x1, x2) => x1 * x2 (_: Int) * 2 (x: Int) => x * 2 if (_) x else y z => if (z) x else y _.map(f) x => x.map(f) _.map(_ + 1) x => x.map(y => y + 1)
  • 35. Distributed  &  multicore   computing Core •  Parallel collections (myList.par.sum) •  Futures & promises •  Actors •  STM – makes Java heap ACID compatible 3rd  Party •  Hadoop •  Spark & Storm •  Plain old Java threads •  Scalding – Twitter’s Scala based MapReduce implementation
  • 36. Calling  Hadoop  from   Scala Java public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { String line = value.toString(); StringTokenizer tokenizer = new StringTokenizer(line); while (tokenizer.hasMoreTokens()) { word.set(tokenizer.nextToken()); output.collect(word, one); } } Scala def map(key: LongWritable, value: Text, output: OutputCollector[Text, IntWritable], reporter: Reporter) = value split " " foreach (output collect (_, one))
  • 37. Futures val from1 = future {conn1.fetch} val from2 = future {conn2.fetch}   from1 either from2 onSuccess println
  • 38. Parallel  collections List(1, 2, 3, 4, 5).par filter (_ % 2 == 0) // ParVector(2, 4)
  • 39. Spark val file = spark textFile "hdfs://...”
 ! file.flatMap(_ split " ")
 .map(word => (word, 1))
 .reduceByKey(_ + _)! !
  • 40. Tail  recursion  optimization Recursion in Java has an Achilles’ heel: the call stack def factorial(n: Int, res: Long = 1): Long = if(n == 0) res else factorial(n - 1, (res * n))
  • 41. Safer  string  composition •  Standard string composition: “I’m “ + name + “, “ + age + “ years old” •  Formatted: “I’m %s, %d years old”.format(name, age) java.util.IllegalFormatConversionException •  Interpolated: s“I’m $name, $age years old”
  • 42. Create  your  own   interpolations xml”””<body> <a href = “http://…”> $text</a> </body> ”””
  • 43. Expression  simplification  –  Java public Expr simplify(Expr expr) { if (expr instanceof UnOp) { UnOp unOp = (UnOp) expr; if (unOp.getOperator().equals("-")) { if (unOp.getArg() instanceof UnOp) { UnOp arg = (UnOp) unOp.getArg(); if (arg.getOperator().equals("-")) return arg.getArg(); } } } if (expr instanceof BinOp) { BinOp binOp = (BinOp) expr; if (binOp.getRight() instanceof Number) { Number arg = (Number) binOp.getRight(); if (binOp.getOperator().equals("+") && arg.getNum() == 0) return binOp.getLeft(); } } return expr; }
  • 44. PaVern  matching   Expression  simplification  -­‐‑  Scala def simplify(expr: Expr): Expr = expr match {! case UnOp("-", UnOp("-", e)) => simplify(e)! case BinOp("+", e, Number(0)) => simplify(e)! case _ => expr! }!
  • 45. Value  classes Extensibility minus boxing overhead! ! class Meter(val v: Double) extends AnyVal {! def plus (that: Meter) = new Meter(v + that.v) ! }! ! Compiler generates! object Meter {! def plus(this: Meter, that: Meter) = new Meter(v + that.v)! }!
  • 46. Compile-­‐‑time   Meta-­‐‑programming •  Language virtualization (overloading/overriding semantics of the original programming language to enable deep embedding of DSLs), •  Program reification (providing programs with means to inspect their own code), •  Self-optimization (self-application of domain-specific optimizations based on program reification), •  Algorithmic program construction (generation of code that is tedious to write with the abstractions supported by a programming language).
  • 47. Meta  programming Language Operate  on Type   Expressive Runtime   safe ness Performance   overhead Textual   C,  Scala Text ✗ Low No preprocessors Template   C++ Text ✗ Low No systems Compile-­‐‑time   Haskell,   Abstract  (typed)   ✔ High No meta-­‐‑ Scala  2.10,   Syntax  trees programming   Nemerle Byte  code   Java,  Scala byte-­‐‑code ✗ Medium No manipulation “Dynamic”   Ruby,  Scala objects ✗ High Yes reflection Run-­‐‑time   Java,  Scala objects ✗ High Yes reflection
  • 48. Scala  macros •  Full blown compile time meta- programming •  Access to the compiler API •  Written in Scala •  Hygienic •  Type-safe
  • 49. Macros  –  safe  printf printf(format: String, params: Any*)! printf(“value is %d”, “boom”)! // runtime exception! java.util.IllegalFormatConversionException: d != java.lang.String! ! ! Macro implementation! def printf(format: String, params: Any*): Unit = macro printf_impl! def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ...!
  • 50. Efficient  Assert assert(2 + 2 == 4, "weird arithmetic") // 2 + 2 == 4 will be evaluated only if assertions were enabled
  • 51. Macros  –  units  of  measure val gravityOnEarth = u(9.81, "m/s^2")! ! val heightOfMyOfficeWindow = u(3.5, "m")! ! val speedOfImpact =
 sqrt(2.0 * gravityOnEarth * heightOfMyOfficeWindow)! ! val monthsInAYear = 10b12! hVp://scalamacros.org/usecases/units-­‐‑of-­‐‑measure.html
  • 52. Macros  –  type  providers type MySqlDb(connString: String) = macro ...! type MyDb = Base with MySqlDb("Server=127.0.0.1;Database=Foo;”)! val products = new MyDb().products! products.filter(p => p.name.startsWith("foo"))!  ! ! ! ! ! http://scalamacros.org/usecases/type-providers.html! Inspired by F# type providers!
  • 53. Type  macros   Injecting  async  methods class D extends Lifter {! !def x = 2! !// def asyncX = future { 2 }! }! ! val d = new D! d.asyncX onComplete {! !case Success(x) => println(x)! !case Failure(_) => println("failed")! }!  hVp://scalamacros.org/talks/2012-­‐‑12-­‐‑18-­‐‑MacroParadise.pdf
  • 54. More  uses  of  macros •  Ad-hoc code style and code-smell detector •  Advanced domain-specific languages •  Logging with minimal overhead •  Pre-compiled SQL queries •  GPU optimized code (see Scalaxy, ScalaCL) •  Macro annotations o  @Cached
  • 55. Macro  annotations class atomic extends MacroAnnotation { def complete(defn: _) = macro(“backing field”) def typeCheck(defn: _) = macro("return defn itself”) } @atomic var fld: Int
  • 56. GPU  compilation •  Enablers: Immutability, Macros •  ScalaCL Collections OpenCL-backed collections that look and behave like standard Scala collections (work in progress). •  ScalaCL Compiler Plugin optimizes Scala programs at compile-time, transforming regular Scala loops into faster code and transforming Scala functions given to ScalaCL Collections into OpenCL kernels.
  • 57. An  extremely  hack-­‐‑able  compiler > scala -Xshow-phases! phase name id description! ---------- -- -----------! parser 1 parse source into ASTs, perform simple desugaring! namer 2 resolve names, attach symbols to named trees! packageobjects 3 load package objects! typer 4 the meat and potatoes: type the trees! patmat 5 translate match expressions! superaccessors 6 add super accessors in traits and nested classes! extmethods 7 add extension methods for inline classes! pickler 8 serialize symbol tables! refchecks 9 reference/override checking, translate nested objects! selectiveanf 10 ANF pre-transform for @cps! selectivecps 11 @cps-driven transform of selectiveanf assignments! uncurry 12 uncurry, translate function values to anonymous classes! tailcalls 13 replace tail calls by jumps! specialize 14 @specialized-driven class and method specialization! explicitouter 15 this refs to outer pointers, translate patterns! erasure 16 erase types, add interfaces for traits! posterasure 17 clean up erased inline classes! lazyvals 18 allocate bitmaps, translate lazy vals into lazified defs! lambdalift 19 move nested functions to top level! constructors 20 move field definitions into constructors! flatten 21 eliminate inner classes! mixin 22 mixin composition! cleanup 23 platform-specific cleanups, generate reflective calls! icode 24 generate portable intermediate code! inliner 25 optimization: do inlining! inlinehandlers 26 optimization: inline exception handlers! closelim 27 optimization: eliminate uncalled closures! dce 28 optimization: eliminate dead code! jvm 29 generate JVM bytecode! terminal 30 The last phase in the compiler chain!
  • 58. Type-­‐‑safe  failures try { 2 / x } catch { case e:Throwable => 0} in 2.10: Try (2 / 0) // returns Failure Try (2 / 1) // returns Success Try (2 / x) getOrElse (0) List(0,1,0,2).map (x=> Try(2 / x)) filter(_.isSuccess) // List(Success(2), Success(1))
  • 59. Implicit  parameters implicit val db = getDB! def store(employee: Employee)(implicit db: DB)! ! store(emp1oyee1) //db is passed implicitly!
  • 60. Implicit  methods implicit def toEuro(x: Currency): Euro = …! ! def transfer(amount: Euro) {! println(”transferred” + amount)! }! ! // dollar is automatically converter to euro! transfer(Dollar(3.0))! transferred 2.25 Euros!
  • 61. Implicit  classes ! implicit class StringExtensions(s: String) {! def words = s split " "! }! ! ! “hello world”.words // Array(hello, world)!
  • 62. Environments -­‐‑  Currently  the  most  mature -­‐‑  Formally  supported  by  TypeSafe ublime   -­‐‑  Through  Ensime Scala  REPL
  • 63. DSLs  (accounting) Rules to calculate an employee's paycheck:! employee's gross salary for 2 weeks! minus deductions for! federalIncomeTax, which is 25% of gross! stateIncomeTax, which is 5% of gross! insurancePremiums, which are 500 in gross’s currency! retirementFundContributions are 10% of gross! ! hVp://ofps.oreilly.com/titles/9780596155957/DomainSpecificLanguages.html
  • 64. DSLs  (JSON) ("person" ->! ("name" -> "Joe") ~! ("age" -> 35) ~! ("spouse" ->! ("person" ->! ("name" -> "Marilyn") ~! ("age" -> 33)! )! )! )!
  • 65. DSL  (XPath  /  json) val titles = xml "channel" "item" "title“ val titles2 = json "feed" "entry" "title" @ "$t" github.com/razie/snakked
  • 66. DSLs   testing  frameworks val emptyStack = new Stack[String] evaluating { emptyStack.pop() } should produce [NoSuchElementException]
  • 67. Full  access  to  the  compiler import tools.reflect.ToolBox! import reflect.runtime.{currentMirror => cm}! ! val tb = cm.mkToolBox()! ! scala> val tree = tb parse "(5 + 9) * 3"! tree: tb.u.Tree = 5.$plus(9).$times(3)! ! scala> tb eval tree! res1: Any = 42!
  • 68. Reflection val take = typeOf[List[_]].member(TermName("take")).asMethod! ! reflect(List(1,3,2,4)).reflectMethod(take)(2) // List(1,2)!
  • 69. Testing •  ScalaCheck o  Auto-generation of inputs and mocks. o  Composable check units o  Inspired by Haskell QuickCheck •  ScalaTest o  TDD, BDD, FeatureSpec o  Selenium DSL •  Specs2 o  TDD, BDD, Datatables support o  Integration with Mockito, EasyMock and JMock o  "hello world" must be matching("h.* w.*") •  JUnit
  • 70. ScalaCheck   (inspired  by  Haskell  QuickCheck) scala> val sqrt = forAll {(n: Int) => math.sqrt(n*n) == n } scala> propSqrt.check ! Falsified after 1 passed tests: > -1
  • 71. BDD  with  ScalaTest describe("A Stack") { it("should throw NoSuchElementException if an empty stack is popped") in { val emptyStack = new Stack[String] evaluating { emptyStack.pop() } should produce [NoSuchElementException] } it("should pop values in last-in-first-out order") { … } }
  • 72. How  to  learn •  twitter.github.com/scala_school •  Effective Scala •  Coursera Scala course (50K students last year) •  Simply scala (interactive learning) •  Programming in scala book •  Stackoverflow
  • 73. Contributing   docs.scala-­‐‑lang.org/sips
  • 75. Things  to  be  aware  of ✗  Scala Compiler has to do much more => slower ✗  Tooling is not perfect (debugging, synthetic frames, macros support) Getting better every day. ✗  Language is rapidly evolving. Deprecations should be expected.