SlideShare a Scribd company logo
1 of 35
Download to read offline
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 Scalafanf42
 
Testing practicies not only in scala
Testing practicies not only in scalaTesting practicies not only in scala
Testing practicies not only in scalaPaweł Panasewicz
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective JavaScalac
 
MySQL Monitoring Shoot Out
MySQL Monitoring Shoot OutMySQL Monitoring Shoot Out
MySQL Monitoring Shoot OutKris 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
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to ScalaTim Underwood
 
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 SparkRahul 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 – why you should care

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 JavaScriptSimon Willison
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009spierre
 
Rubinius - A Tool of the Future
Rubinius - A Tool of the FutureRubinius - A Tool of the Future
Rubinius - A Tool of the Futureevanphx
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platformdeimos
 
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 mindSander 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 ScalaMarakana 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 : CluedaAndreas Neumann
 
Building a JavaScript Library
Building a JavaScript LibraryBuilding a JavaScript Library
Building a JavaScript Libraryjeresig
 
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 FranciscoMartin Odersky
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistpmanvi
 
Rubish- A Quixotic Shell
Rubish- A Quixotic ShellRubish- A Quixotic Shell
Rubish- A Quixotic Shellguest3464d2
 
Scala Workshop
Scala WorkshopScala Workshop
Scala WorkshopClueda AG
 
Efficient JavaScript Development
Efficient JavaScript DevelopmentEfficient JavaScript Development
Efficient JavaScript Developmentwolframkriesing
 

Similar to Scala – why you should care (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_nealeMichael Neale
 
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 CORSMichael Neale
 
Microservices and functional programming
Microservices and functional programmingMicroservices and functional programming
Microservices and functional programmingMichael Neale
 
Osdc 2011 michael_neale
Osdc 2011 michael_nealeOsdc 2011 michael_neale
Osdc 2011 michael_nealeMichael Neale
 
Java one 2011_michaelneale
Java one 2011_michaelnealeJava one 2011_michaelneale
Java one 2011_michaelnealeMichael 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 2011Michael Neale
 
SJUG March 2010 Restful design
SJUG March 2010 Restful designSJUG March 2010 Restful design
SJUG March 2010 Restful designMichael Neale
 
On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009On Scala Slides - OSDC 2009
On Scala Slides - OSDC 2009Michael Neale
 
Osdc Complex Event Processing
Osdc Complex Event ProcessingOsdc Complex Event Processing
Osdc Complex Event ProcessingMichael Neale
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09Michael Neale
 
Osdc Michael Neale 2008
Osdc Michael Neale 2008Osdc Michael Neale 2008
Osdc Michael Neale 2008Michael 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

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Recently uploaded (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

Scala – why you should care

  • 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