SlideShare a Scribd company logo
Scala - just good
for Java shops?
Sarah Mount @snim2
Outline
● Scala - who, what why?
● Basics and idioms
● Scala swing
● Concurrency model
● XML
● Advantages and drawbacks
Scala - what and why?
● An object-functional language
● Based on earlier work by Odersky and
Typesafe
● Compiles / runs on JVM
● A “better” Java
● Whereas OCaml feels more FP + OO, Scala
is more OO + FP
Toolchain
Much like Java:
$ scalac ex1.scala
$ ls
ex1.scala HelloWorld.class
HelloWorld$.class
HelloWorld$delayedInit$body.class
$ scala HelloWorld
Hello, World!
Hello Java!
// Access modifiers, classes, names, blocks, naming
// conventions.
public class Hello {
// Access modifiers, “static”, arg types, return types,
// methods, argument passing, strings, arrays,
// command-line args, blocks, “main”.
public static void main(String[] args) {
// Classes, objects, methods, literals,
// “.”, string literals, sequencing.
System.out.println(“Hello Java world!”);
}
}
Hello Scala!
// Access objects, inheritance,
// strings, blocks, naming
// conventions
object HelloWorld extends App {
println("Hello, World!")
}
Look ma, no semicolon!
object Fibonacci {
def fib(n : Int) : Int = {
if (n == 0 || n == 1) 1
else fib(n - 1) + fib(n - 2)
}
def main(args : Array[String]) : Unit = {
println(fib(5))
}
}
Look ma, no constructor!
class Module(val name : String, val code : String) { }
object Ex4 {
def main(args : Array[String]) : Unit = {
val m = new Module("Concurrent Programming",
"5CS004")
println(m.name)
}
}
Variables can be ...
val x = 3 // Immutable
var y = 4 // Mutable
lazy val z = 5 // Lazy, immutable
Scala Swing
import swing._
object MySwing extends SimpleSwingApplication {
def top = new MainFrame {
val button = new Button { text = "Click me!" }
title = "Hello Swing!"
visible = true
preferredSize = new Dimension(500, 500)
contents = button
}
}
XML support built in
import scala.xml._
import scala.io.Source
import java.net.{URL, URLConnection}
import scala.collection.mutable.{Queue, HashMap}
object ex7 {
def main(args : Array[String]) : Unit = {
val url = new URL("http://feeds.bbci.co.uk/news/technology/rss.xml")
val conn = url.openConnection
val rss = XML.load(conn.getInputStream)
for(t <- rss  "title") { println(t.text) }
}
}
Actor model built in
class Pong extends Actor {
var ping : Ping = null
def act() = {
loop {
react {
case counter : Int =>
println("Pong: " + counter)
reply(counter + 1)
}
}
}
}
class Ping(counter : Int, pong :
Pong) extends Actor {
def act() : Unit = {
pong ! counter
loop {
react {
case counter : Int =>
println("Ping: " + counter)
pong ! (counter + 1)
}
}
}
}
Actor model built in
import scala.actors._
import scala.actors.Actor._
object ex8 {
def main(args: Array[String]) : Unit = {
val pong = new Pong()
val ping = new Ping(0, pong)
ping.start()
pong.start()
}
}
Scala: The good parts
● Sensible concurrency model
● Has a REPL and can be used as a scripting language
● Fits well with existing Java code
● Boilerplate-free Java
● Statically typed with some inference
● XML handling built into language
● FP constructs - pattern matching, etc.
Scala: The not so good parts
Ecosystem moves fast, not always backwards
compatible. This year scala.swing was moved.
Swing examples now compile with:
$ scalac –classpath $CLASSPATH:/usr/share/java/scala-swing.jar *.scala
This year was a good year!
Scala: The not so good parts
● Smaller online community, StackOverflow
etc
● The compiler is slow. Like, make a coffee
and drink the whole pot slow
● A caching compiler fsc exists, but
sometimes needs resetting
● Some nice FP features have ugly syntax…
Scala: The not so good parts
def aFunction(a : Any) : Unit = {
a match {
case i : Int => println("Integer")
case s : String => println("String")
case d : Double => println("Double")
case _ => println("Wildcard")
}
}
Scala: Just good for Java shops?
Probably.

More Related Content

What's hot

Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
Stuart Roebuck
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
Sarvesh Kushwaha
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the future
AnsviaLab
 
Practically Functional
Practically FunctionalPractically Functional
Practically Functional
djspiewak
 
Intro to scala
Intro to scalaIntro to scala
Intro to scalaJoe Zulli
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
Bongwon Lee
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
Adrian Spender
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
Guilherme Blanco
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
Peter Maas
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
Yardena Meymann
 
Quick swift tour
Quick swift tourQuick swift tour
Quick swift tour
Kazunobu Tasaka
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changed
Ayesh Karunaratne
 
Java, what's next?
Java, what's next?Java, what's next?
Java, what's next?
Stephan Janssen
 
Working with Cocoa and Objective-C
Working with Cocoa and Objective-CWorking with Cocoa and Objective-C
Working with Cocoa and Objective-C
Kazunobu Tasaka
 
Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014
Metosin Oy
 
Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)
Tomer Gabel
 
PHP 8: What's New and Changed
PHP 8: What's New and ChangedPHP 8: What's New and Changed
PHP 8: What's New and Changed
Ayesh Karunaratne
 
Ponies and Unicorns With Scala
Ponies and Unicorns With ScalaPonies and Unicorns With Scala
Ponies and Unicorns With Scala
Tomer Gabel
 

What's hot (20)

Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the future
 
Practically Functional
Practically FunctionalPractically Functional
Practically Functional
 
Intro to scala
Intro to scalaIntro to scala
Intro to scala
 
[Start] Scala
[Start] Scala[Start] Scala
[Start] Scala
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
Scala - core features
Scala - core featuresScala - core features
Scala - core features
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
 
Quick swift tour
Quick swift tourQuick swift tour
Quick swift tour
 
PHP 8.1 - What's new and changed
PHP 8.1 - What's new and changedPHP 8.1 - What's new and changed
PHP 8.1 - What's new and changed
 
Java, what's next?
Java, what's next?Java, what's next?
Java, what's next?
 
Working with Cocoa and Objective-C
Working with Cocoa and Objective-CWorking with Cocoa and Objective-C
Working with Cocoa and Objective-C
 
Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014
 
Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)
 
PHP 8: What's New and Changed
PHP 8: What's New and ChangedPHP 8: What's New and Changed
PHP 8: What's New and Changed
 
Ponies and Unicorns With Scala
Ponies and Unicorns With ScalaPonies and Unicorns With Scala
Ponies and Unicorns With Scala
 

Viewers also liked

Mining python-software-pyconuk13
Mining python-software-pyconuk13Mining python-software-pyconuk13
Mining python-software-pyconuk13Sarah Mount
 
Message-passing concurrency in Python
Message-passing concurrency in PythonMessage-passing concurrency in Python
Message-passing concurrency in Python
Sarah Mount
 
Europython lightening talk_on_open_ihm
Europython lightening talk_on_open_ihmEuropython lightening talk_on_open_ihm
Europython lightening talk_on_open_ihm
Sarah Mount
 
Introducción a Scala
Introducción a ScalaIntroducción a Scala
Introducción a Scala
Jose Emilio Labra Gayo
 
Programación Funcional en Scala
Programación Funcional en ScalaProgramación Funcional en Scala
Programación Funcional en Scala
Rubén Pérez Lujano
 
Curso de Scala: Trabajando con variables
Curso de Scala: Trabajando con variablesCurso de Scala: Trabajando con variables
Curso de Scala: Trabajando con variables
Gary Briceño
 
JavaFX and Scala - Like Milk and Cookies
JavaFX and Scala - Like Milk and CookiesJavaFX and Scala - Like Milk and Cookies
JavaFX and Scala - Like Milk and Cookies
Stephen Chin
 
Introducción a scala
Introducción a scalaIntroducción a scala
Introducción a scala
Paradigma Digital
 
Koreference
KoreferenceKoreference
Koreference
Takuji Nishibayashi
 
Scala+swing
Scala+swingScala+swing
Scala+swingperneto
 
Python decorators
Python decoratorsPython decorators
Python decorators
Guillermo Blasco Jiménez
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
Stephen Chin
 
4 Introducción al lenguaje Scala
4 Introducción al lenguaje Scala4 Introducción al lenguaje Scala
4 Introducción al lenguaje Scala
Jose Emilio Labra Gayo
 
Scala
ScalaScala
Scala
deathxlent
 

Viewers also liked (17)

Mining python-software-pyconuk13
Mining python-software-pyconuk13Mining python-software-pyconuk13
Mining python-software-pyconuk13
 
Message-passing concurrency in Python
Message-passing concurrency in PythonMessage-passing concurrency in Python
Message-passing concurrency in Python
 
Europython lightening talk_on_open_ihm
Europython lightening talk_on_open_ihmEuropython lightening talk_on_open_ihm
Europython lightening talk_on_open_ihm
 
Scala en la Practica
Scala en la PracticaScala en la Practica
Scala en la Practica
 
Pf con scala
Pf con scalaPf con scala
Pf con scala
 
Introducción a Scala
Introducción a ScalaIntroducción a Scala
Introducción a Scala
 
Programación Funcional en Scala
Programación Funcional en ScalaProgramación Funcional en Scala
Programación Funcional en Scala
 
Curso de Scala: Trabajando con variables
Curso de Scala: Trabajando con variablesCurso de Scala: Trabajando con variables
Curso de Scala: Trabajando con variables
 
JavaFX and Scala - Like Milk and Cookies
JavaFX and Scala - Like Milk and CookiesJavaFX and Scala - Like Milk and Cookies
JavaFX and Scala - Like Milk and Cookies
 
Introducción a scala
Introducción a scalaIntroducción a scala
Introducción a scala
 
Baño
BañoBaño
Baño
 
Koreference
KoreferenceKoreference
Koreference
 
Scala+swing
Scala+swingScala+swing
Scala+swing
 
Python decorators
Python decoratorsPython decorators
Python decorators
 
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
JavaFX 2 and Scala - Like Milk and Cookies (33rd Degrees)
 
4 Introducción al lenguaje Scala
4 Introducción al lenguaje Scala4 Introducción al lenguaje Scala
4 Introducción al lenguaje Scala
 
Scala
ScalaScala
Scala
 

Similar to Scala - just good for Java shops?

Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
Venkateswaran Kandasamy
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
Isaias Barroso
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
PrasannaKumar Sathyanarayanan
 
Scala
ScalaScala
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
Łukasz Bałamut
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
Michael Stal
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersMiles Sabin
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
Miles Sabin
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scala
Michael Stal
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?Tomasz Wrobel
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
Derek Chen-Becker
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
Eric Pederson
 
Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013
slandelle
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
Abbas Raza
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java Developers
Miles Sabin
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersSkills Matter
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
Jimin Hsieh
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
Mario Camou Riveroll
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationAjax Experience 2009
 

Similar to Scala - just good for Java shops? (20)

Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
 
Scala ntnu
Scala ntnuScala ntnu
Scala ntnu
 
Scala uma poderosa linguagem para a jvm
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
 
Scala
ScalaScala
Scala
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java Developers
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scala
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013Gatling @ Scala.Io 2013
Gatling @ Scala.Io 2013
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java Developers
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java Developers
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus Presentation
 

Recently uploaded

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 

Recently uploaded (20)

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 

Scala - just good for Java shops?

  • 1. Scala - just good for Java shops? Sarah Mount @snim2
  • 2. Outline ● Scala - who, what why? ● Basics and idioms ● Scala swing ● Concurrency model ● XML ● Advantages and drawbacks
  • 3. Scala - what and why? ● An object-functional language ● Based on earlier work by Odersky and Typesafe ● Compiles / runs on JVM ● A “better” Java ● Whereas OCaml feels more FP + OO, Scala is more OO + FP
  • 4. Toolchain Much like Java: $ scalac ex1.scala $ ls ex1.scala HelloWorld.class HelloWorld$.class HelloWorld$delayedInit$body.class $ scala HelloWorld Hello, World!
  • 5. Hello Java! // Access modifiers, classes, names, blocks, naming // conventions. public class Hello { // Access modifiers, “static”, arg types, return types, // methods, argument passing, strings, arrays, // command-line args, blocks, “main”. public static void main(String[] args) { // Classes, objects, methods, literals, // “.”, string literals, sequencing. System.out.println(“Hello Java world!”); } }
  • 6. Hello Scala! // Access objects, inheritance, // strings, blocks, naming // conventions object HelloWorld extends App { println("Hello, World!") }
  • 7. Look ma, no semicolon! object Fibonacci { def fib(n : Int) : Int = { if (n == 0 || n == 1) 1 else fib(n - 1) + fib(n - 2) } def main(args : Array[String]) : Unit = { println(fib(5)) } }
  • 8. Look ma, no constructor! class Module(val name : String, val code : String) { } object Ex4 { def main(args : Array[String]) : Unit = { val m = new Module("Concurrent Programming", "5CS004") println(m.name) } }
  • 9. Variables can be ... val x = 3 // Immutable var y = 4 // Mutable lazy val z = 5 // Lazy, immutable
  • 10. Scala Swing import swing._ object MySwing extends SimpleSwingApplication { def top = new MainFrame { val button = new Button { text = "Click me!" } title = "Hello Swing!" visible = true preferredSize = new Dimension(500, 500) contents = button } }
  • 11. XML support built in import scala.xml._ import scala.io.Source import java.net.{URL, URLConnection} import scala.collection.mutable.{Queue, HashMap} object ex7 { def main(args : Array[String]) : Unit = { val url = new URL("http://feeds.bbci.co.uk/news/technology/rss.xml") val conn = url.openConnection val rss = XML.load(conn.getInputStream) for(t <- rss "title") { println(t.text) } } }
  • 12. Actor model built in class Pong extends Actor { var ping : Ping = null def act() = { loop { react { case counter : Int => println("Pong: " + counter) reply(counter + 1) } } } } class Ping(counter : Int, pong : Pong) extends Actor { def act() : Unit = { pong ! counter loop { react { case counter : Int => println("Ping: " + counter) pong ! (counter + 1) } } } }
  • 13. Actor model built in import scala.actors._ import scala.actors.Actor._ object ex8 { def main(args: Array[String]) : Unit = { val pong = new Pong() val ping = new Ping(0, pong) ping.start() pong.start() } }
  • 14. Scala: The good parts ● Sensible concurrency model ● Has a REPL and can be used as a scripting language ● Fits well with existing Java code ● Boilerplate-free Java ● Statically typed with some inference ● XML handling built into language ● FP constructs - pattern matching, etc.
  • 15. Scala: The not so good parts Ecosystem moves fast, not always backwards compatible. This year scala.swing was moved. Swing examples now compile with: $ scalac –classpath $CLASSPATH:/usr/share/java/scala-swing.jar *.scala This year was a good year!
  • 16. Scala: The not so good parts ● Smaller online community, StackOverflow etc ● The compiler is slow. Like, make a coffee and drink the whole pot slow ● A caching compiler fsc exists, but sometimes needs resetting ● Some nice FP features have ugly syntax…
  • 17. Scala: The not so good parts def aFunction(a : Any) : Unit = { a match { case i : Int => println("Integer") case s : String => println("String") case d : Double => println("Double") case _ => println("Wildcard") } }
  • 18. Scala: Just good for Java shops? Probably.