SlideShare a Scribd company logo
Scala – why you
should care
SJUG @ Atlassian HQ, 2009


Michael Neale
JBoss R&D
Red Hat Middleware




                      1
Michael Neale
R&D w. JBoss (specialise in drools)
Open source history (user -> fulltime
 developer “acquired” by jboss 2005).
Thanks Atlassian !


me on the web:

www.michaelneale.net, twitter.com/michaelneale,
 michaelneale.blogspot.com

Some slides borrowed from Jonas Boner !
                                2
Outline
 • The elevator pitch
 • Why another language?
 • Scala in more detail
 • Actors/concurrency
 • State of the tools
 • How to integrate/migrate
 • Q&A


                        3
Quick intro
• Scala is a OO/FP hybrid language
• Statically strongly typed
• Scala is a compiler + small (ish) rt.jar
• Compiles statically to bytecode
• Interops fawlessly with JVM/java code
  (in source**, or library form in both
  directions)
• FP favour (but not “pure”)
• Both more static and more OO then
  java
                     4
What's it like to drive




           5
The surface diferences...
public Integer methodName()... public void another(String s)...

def methodName : Integer = {...}

def another(s: String) = {...}



String x = “abc”; final String y = “def”;

var x = “abc”

val x = “def”



public class MyClass

class Foo



(punctuation generally optional: brackets, semi-colons etc..)


                                    6
final Map<String, Integer> m = new HashMap<String, Integer>();

m.put(“hello”, 42);

m.put(“goodbye”, 42);




val m = Map(“hello” -> 42, “goodbye” ->   42)




/* Actually a smaller grammar then java ! */




                                   7
Higher level




      8
9
Closures... fnally
Pascal has them, Even C has them...



    (age: Int) => println(“I am “ + age)



    val fn = (age: Int) => ....




                          10
Why another language
Java showing its age
Was built in a hurry, unable to shoe-horn
 enough in... (eg. unable to agree on
 Closures)
Well documented issues...
(and some don't want it to change)


But JVM is made of awesome...


                   11
12
But why Scala...
• Why not?
• Valid javac successor (true to the
  intentions of Java, static typed, fast
  etc)
• Designed by expert(s)
   – Based on hard won lessons
• Not dynamic, nice for “systems”
  programming
• Obey ! (and Gosling likes it)

                    13
Slightly deeper
• Scala is very deep, but you don't have
  to know that much (unless you are a
  library author, probably).
• Can write it as “nicer java” if you like,
  but lends itself to FP




                     14
15
Just so you know I am not making this up...




                      16
Using java libs..
• Just works
• Arrays in java are “decorated” to be
  like “Lazy sequences”
• (previous slide was JExcel API)
• Other common data types are “often
  decorated” to be scala-friendly
• Outgoing library: use java collections,
  Arrays etc as you would like to see
  them
                    17
Lazyness...
• Hard work pays of eventually
• (but lazyness pays of now)
• Lazy can be GOOD in a language
• “lazy” keyword, lazy sequences..
   – But can be some traps: put in a
     print statement and it will exec,
     remove and it won't... - heisenbugs



                   18
Dynamic language “magic”


 • Monkey patching → Implicits
 • Duck typing → Structural typing




                   19
Implicits...


.. Is how you “extend” a class
Anywhere “in scope” - called
automagically
With great power comes...
Its compile time and safe
                   20
Structural typing




         21
Traits...
• Like interfaces, but can have
  implementations in it
• “Mix ins” - compile time or
  construction time
        //Interface:
        trait Funny {
          def laugh
        }

        //With impl:
        trait Person {
           def tickle = println(“hahaha”)
        }

        class Michael extends Funny...

        val x = new Michael with Person
        //doesn't have to implement Person !



                         22
        e:
Pattern matching




        23
Everything is..
• An expression that returns a value
• “Unit” is like Void
• Even if “statements”, pattern matches
  etc.




                    24
DSL friendly
• Malleable syntax (internal DSLs)
• Parser combinator library (write
  parsers in scala)




                   25
Concurrency




        26
Option/Either
• “Monad” patterns
• Don't have to care, just return option if
  you are not sure if you will have a
  result
• (or either if its, well 1 of 2 things...)
• Very easy to use, correct code, very
  neat...



                      27
State of the tools
• IntelliJ demo time...
• Eclipse – well, maybe with 2.8
• Netbeans: Good !
• Emacs/textmate ??
• Maven works well (/me ducks)



                   28
Who is using it ?
• Big Important companies all over...
• Twitter !
• EPFL, Jetbrains etc committed to
  continuing development and stability
  and tools !




                   29
Some extra magic
• QuickCheck (ScalaCheck)
   – Demo
   –   import org.scalacheck.Prop.forAll

   –   scala> class FeeCalculator(val tax: Int) {

   –      | def howMuch(tx: Int) = tx + tax + 42

   –      |}

   –   val totals = forAll( (amounts: Int) => new FeeCalculator(2).howMuch(amounts) > amounts )

   –   totals.check




                                                    30
Mixed source...
• Scala compiler can work with mixed
  java and scala source
• (multiple passes) – similar to groovy
• Means you can migrate over only what
  you need
• Preferred: have modules in all scala or
  java.




                   31
Case classes
• Case classes help you out (equals,
   hashCode, pattern matching)
• No “new” needed
• Eg:
case class Car(type: String, cost: Int)
val c = Car




                        32
Anti static
• No statics in Scala
• But you can swap “class” for “object”
   and its kind of sort of the same (but
   better)


object MyObject { … }
val x = MyObject
MyObject.whatever




                        33
Resources...
 • scala-lang.org
 • A few good books (Programming In
    Scala) and growing
 • #scala on freenode




                    34
Conclusion...
• Very powerful, mature, fun !
• Would you use it over groovy?
• No “grails” or “rails” (Lift just Ain't It).
• Thanks !
• Discussion and Q&A


• twitter.com/michaelneale
• www.osdc.com.au - Brisbane in Nov.

                         35

More Related Content

Viewers also liked

A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
fanf42
 
Testing practicies not only in scala
Testing practicies not only in scalaTesting practicies not only in scala
Testing practicies not only in scala
Paweł Panasewicz
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
Scalac
 
MySQL Monitoring Shoot Out
MySQL Monitoring Shoot OutMySQL Monitoring Shoot Out
MySQL Monitoring Shoot Out
Kris Buytaert
 
Why Scala for Web 2.0?
Why Scala for Web 2.0?Why Scala for Web 2.0?
Why Scala for Web 2.0?
Alex Payne
 
MySQL DBA
MySQL DBAMySQL DBA
MySQL DBA
lalit choudhary
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
Tim Underwood
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
Martin Odersky
 
Real time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkReal time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache Spark
Rahul Jain
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuHavoc Pennington
 

Viewers also liked (13)

A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Testing practicies not only in scala
Testing practicies not only in scalaTesting practicies not only in scala
Testing practicies not only in scala
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
 
Scala-Ls1
Scala-Ls1Scala-Ls1
Scala-Ls1
 
MySQL Monitoring Shoot Out
MySQL Monitoring Shoot OutMySQL Monitoring Shoot Out
MySQL Monitoring Shoot Out
 
Why Scala for Web 2.0?
Why Scala for Web 2.0?Why Scala for Web 2.0?
Why Scala for Web 2.0?
 
MySQL DBA
MySQL DBAMySQL DBA
MySQL DBA
 
Scala
ScalaScala
Scala
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
Real time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache SparkReal time Analytics with Apache Kafka and Apache Spark
Real time Analytics with Apache Kafka and Apache Spark
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on Heroku
 

Similar to Scala Sjug 09

javascript teach
javascript teachjavascript teach
javascript teachguest3732fa
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_Whiteguest3732fa
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
Simon Willison
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009
spierre
 
Rubinius - A Tool of the Future
Rubinius - A Tool of the FutureRubinius - A Tool of the Future
Rubinius - A Tool of the Future
evanphx
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platformdeimos
 
Better code in JavaScript
Better code in JavaScriptBetter code in JavaScript
Better code in JavaScript
nhm taveer hossain khan
 
Scala: functional programming for the imperative mind
Scala: functional programming for the imperative mindScala: functional programming for the imperative mind
Scala: functional programming for the imperative mind
Sander Mak (@Sander_Mak)
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
Marakana Inc.
 
Live coding scala 'the java of the future'
Live coding scala 'the java of the future'Live coding scala 'the java of the future'
Live coding scala 'the java of the future'Xebia Nederland BV
 
Introduction to Scala : Clueda
Introduction to Scala : CluedaIntroduction to Scala : Clueda
Introduction to Scala : Clueda
Andreas Neumann
 
Building a JavaScript Library
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Library
jeresig
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The JvmQConLondon2008
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
Martin Odersky
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
pmanvi
 
Rubish- A Quixotic Shell
Rubish- A Quixotic ShellRubish- A Quixotic Shell
Rubish- A Quixotic Shellguest3464d2
 
Scala Workshop
Scala WorkshopScala Workshop
Scala Workshop
Clueda AG
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Development
wolframkriesing
 

Similar to Scala Sjug 09 (20)

javascript teach
javascript teachjavascript teach
javascript teach
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009
 
Ndp Slides
Ndp SlidesNdp Slides
Ndp Slides
 
Os Wilhelm
Os WilhelmOs Wilhelm
Os Wilhelm
 
Rubinius - A Tool of the Future
Rubinius - A Tool of the FutureRubinius - A Tool of the Future
Rubinius - A Tool of the Future
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
 
Better code in JavaScript
Better code in JavaScriptBetter code in JavaScript
Better code in JavaScript
 
Scala: functional programming for the imperative mind
Scala: functional programming for the imperative mindScala: functional programming for the imperative mind
Scala: functional programming for the imperative mind
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
 
Live coding scala 'the java of the future'
Live coding scala 'the java of the future'Live coding scala 'the java of the future'
Live coding scala 'the java of the future'
 
Introduction to Scala : Clueda
Introduction to Scala : CluedaIntroduction to Scala : Clueda
Introduction to Scala : Clueda
 
Building a JavaScript Library
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Library
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
 
Scala Days San Francisco
Scala Days San FranciscoScala Days San Francisco
Scala Days San Francisco
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
 
Rubish- A Quixotic Shell
Rubish- A Quixotic ShellRubish- A Quixotic Shell
Rubish- A Quixotic Shell
 
Scala Workshop
Scala WorkshopScala Workshop
Scala Workshop
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Development
 

More from Michael Neale

Jenkins X intro (from google app dev conference)
Jenkins X intro (from google app dev conference)Jenkins X intro (from google app dev conference)
Jenkins X intro (from google app dev conference)
Michael Neale
 
Devoxx 2014 michael_neale
Devoxx 2014 michael_nealeDevoxx 2014 michael_neale
Devoxx 2014 michael_neale
Michael Neale
 
Cd syd
Cd sydCd syd
Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORS
Michael Neale
 
Microservices and functional programming
Microservices and functional programmingMicroservices and functional programming
Microservices and functional programming
Michael Neale
 
Cors michael
Cors michaelCors michael
Cors michael
Michael Neale
 
Osdc 2011 michael_neale
Osdc 2011 michael_nealeOsdc 2011 michael_neale
Osdc 2011 michael_neale
Michael Neale
 
Scala sydoct2011
Scala sydoct2011Scala sydoct2011
Scala sydoct2011
Michael Neale
 
Java one 2011_michaelneale
Java one 2011_michaelnealeJava one 2011_michaelneale
Java one 2011_michaelneale
Michael Neale
 
Errors and handling them. YOW nights Sydney 2011
Errors and handling them. YOW nights Sydney 2011Errors and handling them. YOW nights Sydney 2011
Errors and handling them. YOW nights Sydney 2011
Michael Neale
 
Sjug aug 2010_cloud
Sjug aug 2010_cloudSjug aug 2010_cloud
Sjug aug 2010_cloud
Michael Neale
 
SJUG March 2010 Restful design
SJUG March 2010 Restful designSJUG March 2010 Restful design
SJUG March 2010 Restful design
Michael Neale
 
On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009
Michael Neale
 
Osdc Complex Event Processing
Osdc Complex Event ProcessingOsdc Complex Event Processing
Osdc Complex Event Processing
Michael Neale
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
Michael Neale
 
Osdc Michael Neale 2008
Osdc Michael Neale 2008Osdc Michael Neale 2008
Osdc Michael Neale 2008
Michael Neale
 

More from Michael Neale (16)

Jenkins X intro (from google app dev conference)
Jenkins X intro (from google app dev conference)Jenkins X intro (from google app dev conference)
Jenkins X intro (from google app dev conference)
 
Devoxx 2014 michael_neale
Devoxx 2014 michael_nealeDevoxx 2014 michael_neale
Devoxx 2014 michael_neale
 
Cd syd
Cd sydCd syd
Cd syd
 
Cross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORSCross site calls with javascript - the right way with CORS
Cross site calls with javascript - the right way with CORS
 
Microservices and functional programming
Microservices and functional programmingMicroservices and functional programming
Microservices and functional programming
 
Cors michael
Cors michaelCors michael
Cors michael
 
Osdc 2011 michael_neale
Osdc 2011 michael_nealeOsdc 2011 michael_neale
Osdc 2011 michael_neale
 
Scala sydoct2011
Scala sydoct2011Scala sydoct2011
Scala sydoct2011
 
Java one 2011_michaelneale
Java one 2011_michaelnealeJava one 2011_michaelneale
Java one 2011_michaelneale
 
Errors and handling them. YOW nights Sydney 2011
Errors and handling them. YOW nights Sydney 2011Errors and handling them. YOW nights Sydney 2011
Errors and handling them. YOW nights Sydney 2011
 
Sjug aug 2010_cloud
Sjug aug 2010_cloudSjug aug 2010_cloud
Sjug aug 2010_cloud
 
SJUG March 2010 Restful design
SJUG March 2010 Restful designSJUG March 2010 Restful design
SJUG March 2010 Restful design
 
On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009
 
Osdc Complex Event Processing
Osdc Complex Event ProcessingOsdc Complex Event Processing
Osdc Complex Event Processing
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
Osdc Michael Neale 2008
Osdc Michael Neale 2008Osdc Michael Neale 2008
Osdc Michael Neale 2008
 

Recently uploaded

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 

Recently uploaded (20)

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 

Scala Sjug 09

  • 1. Scala – why you should care SJUG @ Atlassian HQ, 2009 Michael Neale JBoss R&D Red Hat Middleware 1
  • 2. Michael Neale R&D w. JBoss (specialise in drools) Open source history (user -> fulltime developer “acquired” by jboss 2005). Thanks Atlassian ! me on the web: www.michaelneale.net, twitter.com/michaelneale, michaelneale.blogspot.com Some slides borrowed from Jonas Boner ! 2
  • 3. Outline • The elevator pitch • Why another language? • Scala in more detail • Actors/concurrency • State of the tools • How to integrate/migrate • Q&A 3
  • 4. Quick intro • Scala is a OO/FP hybrid language • Statically strongly typed • Scala is a compiler + small (ish) rt.jar • Compiles statically to bytecode • Interops fawlessly with JVM/java code (in source**, or library form in both directions) • FP favour (but not “pure”) • Both more static and more OO then java 4
  • 5. What's it like to drive 5
  • 6. The surface diferences... public Integer methodName()... public void another(String s)... def methodName : Integer = {...} def another(s: String) = {...} String x = “abc”; final String y = “def”; var x = “abc” val x = “def” public class MyClass class Foo (punctuation generally optional: brackets, semi-colons etc..) 6
  • 7. final Map<String, Integer> m = new HashMap<String, Integer>(); m.put(“hello”, 42); m.put(“goodbye”, 42); val m = Map(“hello” -> 42, “goodbye” -> 42) /* Actually a smaller grammar then java ! */ 7
  • 9. 9
  • 10. Closures... fnally Pascal has them, Even C has them... (age: Int) => println(“I am “ + age) val fn = (age: Int) => .... 10
  • 11. Why another language Java showing its age Was built in a hurry, unable to shoe-horn enough in... (eg. unable to agree on Closures) Well documented issues... (and some don't want it to change) But JVM is made of awesome... 11
  • 12. 12
  • 13. But why Scala... • Why not? • Valid javac successor (true to the intentions of Java, static typed, fast etc) • Designed by expert(s) – Based on hard won lessons • Not dynamic, nice for “systems” programming • Obey ! (and Gosling likes it) 13
  • 14. Slightly deeper • Scala is very deep, but you don't have to know that much (unless you are a library author, probably). • Can write it as “nicer java” if you like, but lends itself to FP 14
  • 15. 15
  • 16. Just so you know I am not making this up... 16
  • 17. Using java libs.. • Just works • Arrays in java are “decorated” to be like “Lazy sequences” • (previous slide was JExcel API) • Other common data types are “often decorated” to be scala-friendly • Outgoing library: use java collections, Arrays etc as you would like to see them 17
  • 18. Lazyness... • Hard work pays of eventually • (but lazyness pays of now) • Lazy can be GOOD in a language • “lazy” keyword, lazy sequences.. – But can be some traps: put in a print statement and it will exec, remove and it won't... - heisenbugs 18
  • 19. Dynamic language “magic” • Monkey patching → Implicits • Duck typing → Structural typing 19
  • 20. Implicits... .. Is how you “extend” a class Anywhere “in scope” - called automagically With great power comes... Its compile time and safe 20
  • 22. Traits... • Like interfaces, but can have implementations in it • “Mix ins” - compile time or construction time //Interface: trait Funny { def laugh } //With impl: trait Person { def tickle = println(“hahaha”) } class Michael extends Funny... val x = new Michael with Person //doesn't have to implement Person ! 22 e:
  • 24. Everything is.. • An expression that returns a value • “Unit” is like Void • Even if “statements”, pattern matches etc. 24
  • 25. DSL friendly • Malleable syntax (internal DSLs) • Parser combinator library (write parsers in scala) 25
  • 27. Option/Either • “Monad” patterns • Don't have to care, just return option if you are not sure if you will have a result • (or either if its, well 1 of 2 things...) • Very easy to use, correct code, very neat... 27
  • 28. State of the tools • IntelliJ demo time... • Eclipse – well, maybe with 2.8 • Netbeans: Good ! • Emacs/textmate ?? • Maven works well (/me ducks) 28
  • 29. Who is using it ? • Big Important companies all over... • Twitter ! • EPFL, Jetbrains etc committed to continuing development and stability and tools ! 29
  • 30. Some extra magic • QuickCheck (ScalaCheck) – Demo – import org.scalacheck.Prop.forAll – scala> class FeeCalculator(val tax: Int) { – | def howMuch(tx: Int) = tx + tax + 42 – |} – val totals = forAll( (amounts: Int) => new FeeCalculator(2).howMuch(amounts) > amounts ) – totals.check 30
  • 31. Mixed source... • Scala compiler can work with mixed java and scala source • (multiple passes) – similar to groovy • Means you can migrate over only what you need • Preferred: have modules in all scala or java. 31
  • 32. Case classes • Case classes help you out (equals, hashCode, pattern matching) • No “new” needed • Eg: case class Car(type: String, cost: Int) val c = Car 32
  • 33. Anti static • No statics in Scala • But you can swap “class” for “object” and its kind of sort of the same (but better) object MyObject { … } val x = MyObject MyObject.whatever 33
  • 34. Resources... • scala-lang.org • A few good books (Programming In Scala) and growing • #scala on freenode 34
  • 35. Conclusion... • Very powerful, mature, fun ! • Would you use it over groovy? • No “grails” or “rails” (Lift just Ain't It). • Thanks ! • Discussion and Q&A • twitter.com/michaelneale • www.osdc.com.au - Brisbane in Nov. 35