Typesafe Stack Software
Development On The JVM

Sushanta Pradhan
Talentica Software (I) Pvt. Ltd.
History of Hardware Architecture

•   Single core era
    • moore's law achieved by increasing clock cycles

•   Multi core era
    • moore's law achieved by increasing # of cores
Moore’s Law
PPP – Grand Challenge
•   Parallel programming as easy as sequential
    programming
•   Moores’s law of performance – speed up 2 times year
    on year
•   Eliminate concurrency bugs
History of software applications
 • pre .com era
   • standalone desktop apps
 • .com era
   • web sites - static web pages, automated business
      processes
   • data controlled by software vendor
   • deployed on data centers
contd ..
 •   web2.0/semantic web era
     • web/networked applications
     • Smart apps
     • data not controlled by vendor but by the users
     • deployed on cloud
Properties of modern day App
•   Scalability
•   Distributed
•   Parallel & Concurrent
•   Dynamic
•   Agile & Swift
Parallelism & Concurrency
 •   Parallel Programming
     • parallel execution of programs
     • can't be performed without parallel hardware
     • programs get faster
Parallelism & Concurrency
•   Concurrent Programming
    • simultaneous execution of programs
    • can be performed without parallel hardware
    • programs get more responsive

Both are too hard !!
Why Hard?

•   non-determinism due to shared mutable state by
    concurrent threads
•   encapsulate state in actors or transactors but fundamental
    problems still remains

    non-determinism = parallel processing + mutable state
Remedy?
       PREVENTION IS BETTER THAN CURE !!

 •   Avoid mutable state and get deterministic processing

 •   Which means program functionally
Space vs Time
Space(functional/parallel)




    Time(imperative/concurrent)
Scala
•   Hybrid – functional & object oriented (pure)
•   strong static typing
•   Agile - concise & expressive
•   Parallel & Sequential
•   intermixes well with Java
Scala contd ..

  Parallellism
  • parallel collections
  • distributed collections
  Concurrency
  • Actors
  • STM              Akka
  • Futures
Scala contd ..

•   Concise Java
•   Immutability Val & Var
•   Tuples & Multiple Assignments
•   Sensible Defaults
•   Operator Overloading
Scala classes ..
•   Terse
•   Object keyword - Singleton
•   Companion Objects
•   Type inference
•   Option[T] – Some[T], None
Class hierarchy
Scala – Functional Aspects
•   Functions too are objects
•   Higher Order Functions
•   Partially applied Functions
•   Closures
Scala Inehritance
•   Traits
•   Mixins
•   Type inference - implicit keyword
Scala collections
•   Mutable & immutable
•   filter()
•   Map()
•   foldLeft()
•   foldRight()
Scala – Pattern Matching
•   Advanced switch case
•   Literals and constants
•   WildCards
•   Tuples & Lists
•   Guards
•   Regular Expressions
Scala - Concurrency
•   actor()
•   Actor Class
•   receive() & recieveWithin()
•   react() & reachWithin()
•   loop() & loopwhile()
Akka - Middleware
•   Concurrent, Scalable & fault-tolerant
•   based on actor model
•   highly performant
•   event driven
•   location transparency
Actor system
•   ensemble of actors sharing common configuration
•   hierarchical structure
•   heavyweight
•   has its own pool of resources threads
Supervision
•   dependency relationship between actors
•   supervisor - subordinate model
•   supervisor monitors and reacts to any errors reported
    by subordinates
•   configurable supervision strategy
•   lifecycle monitoring
Supervision hierarchy




                                ”root guardian”

                        ”guardian”
             shutdown                    “system
         guardian”
                                order
Remoting
•   ActorPath
    • purely local - "akka://my-sys/user/service-a/worker1"
    • local or remote - "akka://my-sys@host.example.com:5678
                   /user/service-b"

•   Seamlessly send messages to actors on remote nodes
Routing
•   route messages to actors(routees)
•   ideal for load balancing
•   Examples
    • RoundRobinRouter
    • RandomRouter
    • SmallestMailboxRouter
    • BroadcastRouter
Dispatchers
•   make akka actors tick
•   manages the resources(threads) used by actors
•   configure mailboxes of actors
•   Examples
    • fork-join-executor
    • thread-pool-executor
Play
•   ruby on rails like agility
•   convention over configuration
•   seamless integration with akka for scalability
•   edit and test
Play contd ..
 •   an easy, out-of-the-box setup for unit and functional testing
 •   asynchronous HTTP request handling
 •   WebSocket support
 •   cache support (e.g. memcached)
 •   integrated JSON and XML handling
Progressive Stream Processing
•   Iteratees
•   Enumerators
•   Enumeratees
Q/A

Indic threads pune12-typesafe stack software development on the jvm

  • 1.
    Typesafe Stack Software DevelopmentOn The JVM Sushanta Pradhan Talentica Software (I) Pvt. Ltd.
  • 2.
    History of HardwareArchitecture • Single core era • moore's law achieved by increasing clock cycles • Multi core era • moore's law achieved by increasing # of cores
  • 3.
  • 4.
    PPP – GrandChallenge • Parallel programming as easy as sequential programming • Moores’s law of performance – speed up 2 times year on year • Eliminate concurrency bugs
  • 5.
    History of softwareapplications • pre .com era • standalone desktop apps • .com era • web sites - static web pages, automated business processes • data controlled by software vendor • deployed on data centers
  • 6.
    contd .. • web2.0/semantic web era • web/networked applications • Smart apps • data not controlled by vendor but by the users • deployed on cloud
  • 7.
    Properties of modernday App • Scalability • Distributed • Parallel & Concurrent • Dynamic • Agile & Swift
  • 8.
    Parallelism & Concurrency • Parallel Programming • parallel execution of programs • can't be performed without parallel hardware • programs get faster
  • 9.
    Parallelism & Concurrency • Concurrent Programming • simultaneous execution of programs • can be performed without parallel hardware • programs get more responsive Both are too hard !!
  • 10.
    Why Hard? • non-determinism due to shared mutable state by concurrent threads • encapsulate state in actors or transactors but fundamental problems still remains non-determinism = parallel processing + mutable state
  • 11.
    Remedy? PREVENTION IS BETTER THAN CURE !! • Avoid mutable state and get deterministic processing • Which means program functionally
  • 12.
    Space vs Time Space(functional/parallel) Time(imperative/concurrent)
  • 13.
    Scala • Hybrid – functional & object oriented (pure) • strong static typing • Agile - concise & expressive • Parallel & Sequential • intermixes well with Java
  • 14.
    Scala contd .. Parallellism • parallel collections • distributed collections Concurrency • Actors • STM Akka • Futures
  • 15.
    Scala contd .. • Concise Java • Immutability Val & Var • Tuples & Multiple Assignments • Sensible Defaults • Operator Overloading
  • 16.
    Scala classes .. • Terse • Object keyword - Singleton • Companion Objects • Type inference • Option[T] – Some[T], None
  • 17.
  • 18.
    Scala – FunctionalAspects • Functions too are objects • Higher Order Functions • Partially applied Functions • Closures
  • 19.
    Scala Inehritance • Traits • Mixins • Type inference - implicit keyword
  • 20.
    Scala collections • Mutable & immutable • filter() • Map() • foldLeft() • foldRight()
  • 21.
    Scala – PatternMatching • Advanced switch case • Literals and constants • WildCards • Tuples & Lists • Guards • Regular Expressions
  • 22.
    Scala - Concurrency • actor() • Actor Class • receive() & recieveWithin() • react() & reachWithin() • loop() & loopwhile()
  • 23.
    Akka - Middleware • Concurrent, Scalable & fault-tolerant • based on actor model • highly performant • event driven • location transparency
  • 24.
    Actor system • ensemble of actors sharing common configuration • hierarchical structure • heavyweight • has its own pool of resources threads
  • 25.
    Supervision • dependency relationship between actors • supervisor - subordinate model • supervisor monitors and reacts to any errors reported by subordinates • configurable supervision strategy • lifecycle monitoring
  • 26.
    Supervision hierarchy ”root guardian” ”guardian” shutdown “system guardian” order
  • 27.
    Remoting • ActorPath • purely local - "akka://my-sys/user/service-a/worker1" • local or remote - "akka://my-sys@host.example.com:5678 /user/service-b" • Seamlessly send messages to actors on remote nodes
  • 28.
    Routing • route messages to actors(routees) • ideal for load balancing • Examples • RoundRobinRouter • RandomRouter • SmallestMailboxRouter • BroadcastRouter
  • 29.
    Dispatchers • make akka actors tick • manages the resources(threads) used by actors • configure mailboxes of actors • Examples • fork-join-executor • thread-pool-executor
  • 30.
    Play • ruby on rails like agility • convention over configuration • seamless integration with akka for scalability • edit and test
  • 31.
    Play contd .. • an easy, out-of-the-box setup for unit and functional testing • asynchronous HTTP request handling • WebSocket support • cache support (e.g. memcached) • integrated JSON and XML handling
  • 32.
    Progressive Stream Processing • Iteratees • Enumerators • Enumeratees
  • 33.