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

A Glimpse of a Scala - Java Meetup Novi Sad May 2014

A Glimpse of a Scala - Java Meetup Novi Sad May 2014

I gave an introduction to Scala at Novi Sad on 29.05.2014. The corresponding code examples can be found here: https://github.com/lukaspustina/A-Glimpse-Of-Scala-Java-Meet-Up-in-Novi-Sad

Lukas Pustina

May 30, 2014
Tweet

More Decks by Lukas Pustina

Other Decks in Programming

Transcript

  1. A Glimpse of Scala
    Dr. Lukas Pustina
    @drivebytesting
    codecentric AG

    View Slide

  2. Which Programming Language
    would you use now on top of
    JVM? Scala!
    James Gosling, Father of Java

    View Slide

  3. Scala is fun
    and designed for the future.

    View Slide

  4. @drivebytesting

    View Slide

  5. What to expect

    View Slide

  6. Syntax vs. Idioms
    How to use a language.

    View Slide

  7. Before we start

    View Slide

  8. Open your mind

    View Slide

  9. Let’s program our minds
    The brain has bugs

    View Slide

  10. Exposure Effect
    We prefer things we know and are familiar with

    View Slide

  11. View Slide

  12. “Gott würfelt nicht!”
    “God doesn’t role the dice!” — Albert Einstein

    View Slide

  13. Bundesarchiv, Bild183-R57262 / CC-BY-SA

    View Slide

  14. Today’s
    Challenges

    View Slide

  15. CPU Memory

    View Slide

  16. !Von Neumann
    Bottleneck

    View Slide

  17. Can Programming Be
    Liberated from the von
    Neumann Style
    A Functional Style and Its Algebra of Programs —
    John Backus, 1977

    View Slide

  18. CPU Memory
    Cache

    View Slide

  19. CPU Memory
    Cache Cache

    View Slide

  20. CPU Memory
    Cache Cache
    Core
    Core
    Core
    Core

    View Slide

  21. CPU Memory
    Cache Cache
    Core
    Core
    Core
    Core

    View Slide

  22. !False Sharing

    View Slide

  23. Cache
    Cache
    Cache
    Core
    Core

    View Slide

  24. Cache
    Cache
    Cache
    Core
    Core

    View Slide

  25. Cache
    Cache
    Cache
    Core
    Core

    View Slide

  26. !I/O Waits

    View Slide

  27. This is the future
    Massive parallel computing

    View Slide

  28. ?Threads
    The software engineers’ answer

    View Slide

  29. A Universal
    Modular Actor Formalism for
    Artificial Intelligence
    Carl Hewitt, Peter Bishop, Richard Steiger 1973

    View Slide

  30. Reactive Programming
    Immutability, Functional, Actors are one approach.

    View Slide

  31. A Glimpse of
    Scala

    View Slide

  32. SCAlable LAnguage
    A multi-paradigm language

    View Slide

  33. Return of
    Computer Science
    Bear with me :)

    View Slide

  34. Object oriented,
    functional language
    Multi-paradigm language

    View Slide

  35. OO and func
    • State Mutation vs. Immutability
    • Object Composition vs. Functional Composition
    • Class Hierarchies vs. Pattern Matching

    View Slide

  36. Type Inference
    The type of variables and functions is interfered from
    assignments and return values.

    View Slide

  37. Immutability
    Immutability right in the language: val and immutable
    collections.

    View Slide

  38. Functions as
    1st class citizens
    Pass a function as you would pass an Int, a String, or
    an arbitrary object.

    View Slide

  39. Hello World
    The first program in the REPL

    View Slide

  40. [lukas@muffin] ~ ➜ scala!
    Welcome to Scala version 2.11.1 (Java HotSpot(TM) 64-Bit Server VM,
    Java 1.7.0_51).!
    Type in expressions to have them evaluated.!
    Type :help for more information.!
    !
    scala> print("Hello World")!
    Hello World

    View Slide

  41. A Closer Look

    View Slide

  42. With great power …
    … comes great responsibility.

    View Slide

  43. @drivebytesting

    View Slide

  44. End
    Dr. Lukas Pustina
    @drivebytesting
    codecentric AG

    View Slide