Why scala - executive overview

12,788 views

Published on

A executive overview of why development shops should look into scala.

Published in: Technology
1 Comment
11 Likes
Statistics
Notes
  • slide 12 - Scala doesn't replace SQL(server)...so not ALL of the above :) but it certainly replaces SQL(client) ... there's a few frameworks for that already: squeryl, slinq, scalaql ... talk about explosive adoption :) I think my favorite is squeryl.
    Will update the slides in the next version
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
12,788
On SlideShare
0
From Embeds
0
Number of Embeds
59
Actions
Shares
0
Downloads
190
Comments
1
Likes
11
Embeds 0
No embeds

No notes for slide

Why scala - executive overview

  1. 1. Why Scala Executive Overview Razvan Cojocaru – May'10
  2. 2. One Slider <ul><li>Brevity: Scala programs typically 30-50% less code than Java </li></ul><ul><ul><li>Productivity and quality increase </li></ul></ul><ul><ul><li>Shorter time-to-market </li></ul></ul><ul><li>Technology neutral </li></ul><ul><ul><li>Compiles to bytecode and runs on the Java Virtual Machine </li></ul></ul><ul><ul><li>J2EE, servlets, all Java libraries etc </li></ul></ul><ul><li>Soft landing for Java developers </li></ul><ul><ul><li>Language resembles Java, JavaScript and C# </li></ul></ul><ul><ul><li>Compatibility from / to Java: could replace classes one at a time </li></ul></ul><ul><ul><li>Concepts familiar to C++ developers as well </li></ul></ul><ul><li>Advanced DSL capabilities </li></ul><ul><ul><li>Reduce integration costs </li></ul></ul><ul><ul><li>Rapid prototyping </li></ul></ul>
  3. 3. One Slider (part 2) <ul><li>Stable, open </li></ul><ul><li>Acceptance and adoption ramping up </li></ul><ul><li>Excellent new libraries </li></ul><ul><ul><li>Language allows creation of a new breed of libraries, reducing code in certain cases by a factor of 10 (GUI (swing, SWT), web/AJAX) </li></ul></ul><ul><ul><li>Most useful algorithms built-into libraries </li></ul></ul><ul><li>Modern </li></ul><ul><ul><li>Combines functional and Object-Oriented </li></ul></ul><ul><ul><li>Both compiled and interpreted </li></ul></ul><ul><li>Replaces scripting languages and in-house DSL </li></ul>
  4. 4. Background <ul><li>Programming languages evolve on many levels </li></ul><ul><li>Hardware coupling </li></ul><ul><ul><li>Tied to hardware / compiled </li></ul></ul><ul><ul><li>Running on a Virtual Machine </li></ul></ul><ul><li>Abstractions: </li></ul><ul><ul><li>Structured, Functional, Object-oriented </li></ul></ul><ul><li>Type checking, safety </li></ul><ul><ul><li>Compiled, Interpreted </li></ul></ul><ul><li>Generic / specific: many languages start with a specific target </li></ul><ul><li>Hilarious history of programming languages: http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html </li></ul>
  5. 5. Meet Scala: “ items sort (_>_) ” <ul><li>Scala incorporates and unifies the best features from many previous languages </li></ul><ul><ul><li>Runs on the JVM </li></ul></ul><ul><ul><li>Functional and Object Oriented </li></ul></ul><ul><ul><li>Compiled and Interpreted </li></ul></ul><ul><li>Designed with the goal of providing a highly simplified and scalable syntax </li></ul><ul><ul><li>All the time-consuming and superfluous “features” of Java were dropped and replaced by a smart compiler that requires less instructions to achieve the same thing </li></ul></ul><ul><li>Powerful accompanying libraries, while new ones are created continuously. </li></ul><ul><ul><li>Interoperability with all Java libraries and frameworks (J2EE, servlets, JMS etc) </li></ul></ul>
  6. 6. Developer Efficiency <ul><li>Scala programs are typically 30-50% smaller than Java, so by adopting scala, </li></ul><ul><ul><li>Developers can write more functionality, with less code, in less time. </li></ul></ul><ul><ul><li>Cooperation (reviews and maintenance) is cheaper </li></ul></ul><ul><ul><li>Better quality due to less bugs in production. </li></ul></ul><ul><li>Focus on one language/environment, not 10 </li></ul><ul><ul><li>Most shops use a set of languages and frameworks, shell scripts etc </li></ul></ul><ul><ul><li>Scala can displace all those </li></ul></ul><ul><li>The biggest gain </li></ul><ul><ul><li>Lets developers focus more on the problem, domain and functionality rather than the code-to-write </li></ul></ul>
  7. 7. Typical class definition <ul><li>class Point { </li></ul><ul><li>int x; </li></ul><ul><li>int y; </li></ul><ul><li>public Point (int ax, int ay) { </li></ul><ul><li>this.x = ax; </li></ul><ul><li>this.y = ay; </li></ul><ul><li>} </li></ul><ul><li>public int getX () { return x; } </li></ul><ul><li>public int getY () { return y; } </li></ul><ul><li>public int setX (int x) { this.x=x } </li></ul><ul><li>public int setY (int y) { this.y=y } </li></ul><ul><li>} </li></ul><ul><li>class Point (var x:int, var y:int) </li></ul>Scala Java
  8. 8. Typical list operations <ul><li>employees.sort ( </li></ul><ul><li>new Comparator{ </li></ul><ul><li>public int compare(Object emp1, Object emp2){ </li></ul><ul><li>int emp1Age = ( (Employee) emp1).getAge(); </li></ul><ul><li>int emp2Age = ( (Employee) emp2).getAge(); </li></ul><ul><li>if( emp1Age > emp2Age ) </li></ul><ul><li>return 1; </li></ul><ul><li>else if( emp1Age < emp2Age ) </li></ul><ul><li>return -1; </li></ul><ul><li>else </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul><ul><li>employees.sort (_.age > _.age) </li></ul>Java Scala How much time is wasted: writing it? Reviewing? Fixing? Maintaining? How many opportunities for bugs that can be introduced? Does the scala alternative look hard to comprehend or easier?
  9. 9. Learning curve <ul><li>Base language and libraries </li></ul><ul><ul><li>Easy transition from Java, formal training not necessary, lots of materials available </li></ul></ul><ul><ul><li>Enough to understand scala and use it efficiently </li></ul></ul><ul><li>Advanced features </li></ul><ul><ul><li>Training recommended. Steeper learning curve </li></ul></ul><ul><ul><li>Many concepts learned in school but forgotten by Java developers </li></ul></ul><ul><ul><li>More important for library designers, not every-day programming </li></ul></ul><ul><li>Libraries / frameworks </li></ul><ul><ul><li>Can re-use all familiar Java libraries </li></ul></ul><ul><ul><li>Adopt new scala libraries as needed </li></ul></ul><ul><li>Pool of experienced scala developers and trainers growing </li></ul>
  10. 10. Development Environment <ul><li>Plugins for most IDEs: </li></ul><ul><ul><li>Eclipse, NetBeans, IntelliJ Idea, Vi, Emacs :) </li></ul></ul><ul><ul><li>Full debugging, syntax highlighting, content assist etc </li></ul></ul><ul><li>Plus: </li></ul><ul><ul><li>command line and interactive interpreters </li></ul></ul><ul><li>Deployment model: </li></ul><ul><ul><li>scala-library.jar – yet another jar file... that's it! </li></ul></ul><ul><li>Major tools/frameworks </li></ul><ul><ul><li>ScalaUnit – upgrade of Junit </li></ul></ul><ul><ul><li>Sbt – upgrade of maven </li></ul></ul><ul><ul><li>Lift – web framework </li></ul></ul><ul><li>Very active online community, forums </li></ul>
  11. 11. Open, stable, adopted <ul><li>Since 2003 </li></ul><ul><li>Controlled by EPFL (A Swiss University) </li></ul><ul><li>Twitter “Much of Twitter's infrastructure has been ported to Scala, and most new infrastructural projects are being built in the language.” The fact that one of today's leading web enterprises placed a big bet on Scala is more of an endorsement than slow adoption in obscure projects inside any Fortune 100 companies…visibility and proportional “costs of failure” are incomparable. </li></ul>
  12. 12. Babel, meet Scala <ul><li>All companies use a myriad of languages and frameworks. For instance: </li></ul><ul><ul><li>Java, JavaScript, JSP, SQL (server), SQL (client) </li></ul></ul><ul><ul><li>Ruby/Rails, PHP </li></ul></ul><ul><ul><li>Bash, PowerScript, sed, awk </li></ul></ul><ul><li>Don't be fooled: any configuration is a language (Domain Specific Language) </li></ul><ul><ul><li>XML this and XML that </li></ul></ul><ul><ul><li>Ant, struts, spring, maven </li></ul></ul><ul><li>Scala single-handedly displaces all of the above </li></ul><ul><ul><li>Platform independent scripting (Java based) </li></ul></ul><ul><ul><li>XML built-in but not really needed inside new frameworks </li></ul></ul><ul><ul><li>DSL support built-in </li></ul></ul><ul><ul><li>Even JavaScript is hidden in web libraries </li></ul></ul>
  13. 13. Adoption path <ul><li>It may sound risky to adopt a new language, but unifying all in-house development, in time, and focusing on a single language/environment does make sense </li></ul><ul><ul><li>Until the next divergence – things evolve </li></ul></ul><ul><li>Incremental adoption, across projects and teams </li></ul><ul><ul><li>Building knowledge as you go </li></ul></ul><ul><ul><li>Can see it as yet-another-library and use in specialized components/tools </li></ul></ul><ul><li>Don't want to re-write existing Java code, reuse as is </li></ul><ul><ul><li>Compatibility from / to Java: replace classes one at a time, as needed </li></ul></ul><ul><li>Need guidelines </li></ul><ul><ul><li>Avoid abuse </li></ul></ul><ul><ul><li>Give developers time to grow into it </li></ul></ul>
  14. 14. So, why Scala? <ul><li>There are costs of change, for sure </li></ul><ul><ul><li>Learning curve (inefficiency) </li></ul></ul><ul><ul><li>Training </li></ul></ul><ul><ul><li>Risk </li></ul></ul><ul><li>As argued here, once “on Scala”, costs will go down </li></ul><ul><ul><li>Can mitigate the risk and costs by ramping up across teams and projects and feedback into other teams and projects </li></ul></ul><ul><li>One thing is not usually shown in budgets: cost of opportunity : </li></ul><ul><ul><li>Not writing less code </li></ul></ul><ul><ul><li>Not introducing less bugs </li></ul></ul><ul><ul><li>Not spending less time on reviews, maintenance, refactoring, rewriting… </li></ul></ul><ul><ul><li>Not using advanced frameworks and new technologies (actors, DSL) </li></ul></ul>
  15. 15. Links <ul><li>Real world stories </li></ul><ul><ul><li>http:// www.artima.com/scalazine/articles/twitter_on_scala.html </li></ul></ul><ul><li>Good brief Scala intro: </li></ul><ul><ul><li>http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees </li></ul></ul><ul><ul><li>http://www.scala-lang.org/downloads/distrib/files/website/doc/ProgrammingInScala.pdf </li></ul></ul><ul><li>The scala wiki: </li></ul><ul><ul><li>http:// scala.sygneca.com / </li></ul></ul><ul><li>Download new verions: </li></ul><ul><ul><li>http://www.scala-lang.org / </li></ul></ul><ul><li>More goodies: </li></ul><ul><ul><li>http://www.devoxx.com/download/attachments/1705916/D8_U_08_06_01.pdf </li></ul></ul><ul><ul><li>http://www.slideshare.net/michael.galpin/introduction-to-scala-for-java-developers-presentation </li></ul></ul><ul><ul><li>http://www.slideshare.net/jboner/pragmatic-real-world-scala-45-min-presentation </li></ul></ul><ul><li>Other tools: </li></ul><ul><li>ScalaUnit, LiftWeb. </li></ul>

×