iasi code camp 20 april 2013 iulian dogariu - scala
TRANSCRIPT
Level up your Java
Iulian DogariuNess Technologies
20 April 2013
Why Learn Yet Another Language?
Why Learn Yet Another Language?
Scala
• Functional style programming
• Parallelism
• Concise code
Psycho therapy time !
http://www.youtube.com/watch?v=GlFU0C4YV4o&hd=1
Video demo
A taste of Scala
http://www.youtube.com/watch?v=GWl4jGMojr8&hd=1
Video demo
Functional style programming
Video demos
http://www.youtube.com/watch?v=rn7BETTPwBM&hd=1
http://www.youtube.com/watch?v=35ug8iflmjE&hd=1
“Smaller and more general modules can be reused more widely, easing subsequentprogramming.
This explains why functional programs are so much smaller and easier to write than conventional ones.”
John HughesWhy Functional Programming Matters
12Average # of lines of code per day per programmer
(Fred Brooks – „The Mythical Man Month”)
No matter what programming language !
Not just a tool …
… but a medium of expression
XXVIII 28
Let’s manipulate symbols1372 ÷ 28
Let’s manipulate symbols1372 ÷ 28
1372 | 28 | 112 | 4 | 25 | |
Let’s manipulate symbols1372 ÷ 28
1372 | 28 | 112 | 49 | 252 | 252 | 0
Notation matters.
MCCCLXXII ÷ XXVIII
?
Would you rather work with …
… or with this
Notation matters. A lot!
Parallelism and concurrency
Parallelism and concurrency
CPUs aren’t getting any faster
We’ll just havemore of them !
Parallelism and concurrency
Threads will get you in a mess, fast
public Object fileLock = new Object();public Object dbLock = new Object();
public void doThis() { synchronized (fileLock) { synchronized (dbLock) { logToFileAndDb(db, “Doing this !”); } } }
public void doThat() { synchronized (dbLock) { synchronized (fileLock) { logToFileAndDb(db, “Doing that !”); } } }
99.9999999 % reliabilityLess than 0.63 seconds downtime
Source: Joe Armstrong http://pragprog.com/articles/erlang
… in more than 20 years !
99.9999999 % reliability
Source: Joe Armstrong http://pragprog.com/articles/erlang
Successful Parallel Programming
Message passing
No shared state
Actors
Actors
http://www.youtube.com/watch?v=UgpCfHiCtN0&hd=1
Video demo
Psycho therapy squared
http://www.youtube.com/watch?v=4O0Dq6Tf6k0&hd=1
Video demo
Source: TIOBE index February 2013
How popular?
Who uses Scala?
Source: http://slideshare.net/mslinn/scala-adoption-by-enterprises
But will this be useful to me?
„________ is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use [it]”
-- Eric S Raymond
One more thing
specs2
Be Ready for Tomorrow
• Functional style programming
• Parallelism
• Concise code
... But Use Your Head
Resources
• http://www.scala-lang.org
• Book: Martin Odersky – Programming in Scala
• Book: Venkat Subramaniam – Programming Scala
• Commercial support: Typesafe, Inc. http://www.typesafe.com
• IDE support: IntelliJ IDEA 12
Thank you!
And don’t forget to fill inthe evaluation form