+ All Categories
Home > Documents > Indic threads pune12-typesafe stack software development on the jvm

Indic threads pune12-typesafe stack software development on the jvm

Date post: 10-May-2015
Category:
Upload: indicthreads
View: 562 times
Download: 1 times
Share this document with a friend
Description:
The 7th Annual IndicThreads Pune Conference was held on 14-15 December 2012. http://pune12.indicthreads.com/
Popular Tags:
33
Typesafe Stack Software Development On The JVM Sushanta Pradhan Talentica Software (I) Pvt. Ltd.
Transcript
Page 1: Indic threads pune12-typesafe stack software development on the jvm

Typesafe Stack Software Development On The JVM

Sushanta PradhanTalentica Software (I) Pvt. Ltd.

Page 2: Indic threads pune12-typesafe stack software development on the jvm

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

Page 3: Indic threads pune12-typesafe stack software development on the jvm

Moore’s Law

Page 4: Indic threads pune12-typesafe stack software development on the jvm

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

Page 5: Indic threads pune12-typesafe stack software development on the jvm

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

Page 6: Indic threads pune12-typesafe stack software development on the jvm

contd ..

• web2.0/semantic web era• web/networked applications• Smart apps• data not controlled by vendor but by the users• deployed on cloud

Page 7: Indic threads pune12-typesafe stack software development on the jvm

Properties of modern day App

• Scalability• Distributed• Parallel & Concurrent• Dynamic• Agile & Swift

Page 8: Indic threads pune12-typesafe stack software development on the jvm

Parallelism & Concurrency

• Parallel Programming• parallel execution of programs • can't be performed without parallel hardware• programs get faster

Page 9: Indic threads pune12-typesafe stack software development on the jvm

Parallelism & Concurrency

• Concurrent Programming• simultaneous execution of programs• can be performed without parallel hardware• programs get more responsive

Both are too hard !!

Page 10: Indic threads pune12-typesafe stack software development on the jvm

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

Page 11: Indic threads pune12-typesafe stack software development on the jvm

Remedy?

PREVENTION IS BETTER THAN CURE !!

• Avoid mutable state and get deterministic processing

• Which means program functionally

Page 12: Indic threads pune12-typesafe stack software development on the jvm

Space vs Time

Space(functional/parallel)

                                           

 

Time(imperative/concurrent)           

Page 13: Indic threads pune12-typesafe stack software development on the jvm

Scala

• Hybrid – functional & object oriented (pure)• strong static typing• Agile - concise & expressive• Parallel & Sequential• intermixes well with Java

Page 14: Indic threads pune12-typesafe stack software development on the jvm

Scala contd ..

Parallellism• parallel collections• distributed collections   

Concurrency• Actors    • STM        Akka• Futures

Page 15: Indic threads pune12-typesafe stack software development on the jvm

Scala contd ..

• Concise Java• Immutability Val & Var• Tuples & Multiple Assignments• Sensible Defaults• Operator Overloading

Page 16: Indic threads pune12-typesafe stack software development on the jvm

Scala classes ..• Terse• Object keyword - Singleton• Companion Objects• Type inference• Option[T] – Some[T], None

Page 17: Indic threads pune12-typesafe stack software development on the jvm

Class hierarchy

Page 18: Indic threads pune12-typesafe stack software development on the jvm

Scala – Functional Aspects

• Functions too are objects• Higher Order Functions• Partially applied Functions• Closures

Page 19: Indic threads pune12-typesafe stack software development on the jvm

Scala Inehritance

• Traits• Mixins• Type inference - implicit keyword

Page 20: Indic threads pune12-typesafe stack software development on the jvm

Scala collections• Mutable & immutable• filter()• Map()• foldLeft()• foldRight()

Page 21: Indic threads pune12-typesafe stack software development on the jvm

Scala – Pattern Matching• Advanced switch case• Literals and constants• WildCards• Tuples & Lists• Guards• Regular Expressions

Page 22: Indic threads pune12-typesafe stack software development on the jvm

Scala - Concurrency• actor()• Actor Class• receive() & recieveWithin()• react() & reachWithin()• loop() & loopwhile()

Page 23: Indic threads pune12-typesafe stack software development on the jvm

Akka - Middleware

• Concurrent, Scalable & fault-tolerant• based on actor model• highly performant• event driven• location transparency

Page 24: Indic threads pune12-typesafe stack software development on the jvm

Actor system

• ensemble of actors sharing common configuration• hierarchical structure• heavyweight • has its own pool of resources threads

Page 25: Indic threads pune12-typesafe stack software development on the jvm

Supervision• dependency relationship between actors• supervisor - subordinate model• supervisor monitors and reacts to any errors reported

by subordinates• configurable supervision strategy• lifecycle monitoring

Page 26: Indic threads pune12-typesafe stack software development on the jvm

Supervision hierarchy

”root guardian”

”guardian”shutdown

“system guardian”order

Page 27: Indic threads pune12-typesafe stack software development on the jvm

Remoting

• ActorPath • purely local - "akka://my-sys/user/service-a/worker1"               • local or remote - "akka://[email protected]:5678

/user/service-b"

• Seamlessly send messages to actors on remote nodes

Page 28: Indic threads pune12-typesafe stack software development on the jvm

Routing• route messages to actors(routees)• ideal for load balancing• Examples

• RoundRobinRouter• RandomRouter• SmallestMailboxRouter• BroadcastRouter

Page 29: Indic threads pune12-typesafe stack software development on the jvm

Dispatchers

• make akka actors tick• manages the resources(threads) used by actors• configure mailboxes of actors• Examples

• fork-join-executor• thread-pool-executor

Page 30: Indic threads pune12-typesafe stack software development on the jvm

Play• ruby on rails like agility• convention over configuration• seamless integration with akka for scalability• edit and test

Page 31: Indic threads pune12-typesafe stack software development on the jvm

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

Page 32: Indic threads pune12-typesafe stack software development on the jvm

Progressive Stream Processing

• Iteratees• Enumerators• Enumeratees

Page 33: Indic threads pune12-typesafe stack software development on the jvm

Q/A


Recommended