javawug bof 57 scala why now
DESCRIPTION
TRANSCRIPT
![Page 1: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/1.jpg)
SCALA, WHY NOW?
Monday, 5th July Peter Pilgrim, Oracle Java Champion,
![Page 2: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/2.jpg)
Brief History Scala
Scala – Scalable LanguagePre‐history
1996 – 1997 Pizza, 1998‐2000 GJ2003 Experiment2006‐2009 Industrial strength programming language
“Make a better Java”
![Page 3: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/3.jpg)
Martin Odersky’s Scala Workshop
![Page 4: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/4.jpg)
Why Scala?
Functional
• Closures• Lambda Currying• Immutables• Style
Object Oriented
• Full Types• Hierarchical, Mix‐Ins
• Case Classes
Scalable
• Operators Overloading
• Pattern Matching• Extendable with Libraries
Cross Platform
• Static compilation to byte codes
• JVM • Dot Net
![Page 5: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/5.jpg)
Functional Side
Closures , Lambda Expression, Function TypesImmutable References to Objects (val)Immutable Objects & Collections
Standard Scala Libraries
Currying –Control AbstractionsLast Statement is an ExpressionTail Recursion
![Page 6: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/6.jpg)
Object Oriented Side
Everything is an Object in ScalaBetter Static Classes (Object)Classes with reduced boilerplateTraits , Mix‐ins, Self‐Types
![Page 7: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/7.jpg)
REPL ‐ Read, Evaluate, Print, Loop
Execute Scala like a Scripting languageIncreasing support
Eclipse IDE , NetBeans, IntelliJ
New Tools, Ideas and InnovationsSBT, Actors, Lift
![Page 8: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/8.jpg)
Repeat Until Construction #1a
package demo;
object Control {
def repeatLoop ( body: => Unit ) = new Until( body )
def class Until( body: => Unit ) {def until( cond: => Boolean ) {body;if ( cond )
repeatLoop(body).until(cond)}
}
}
![Page 9: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/9.jpg)
Repeat Until Construction #1b
import demo.Control;
object LoopDemo {
def main( args: Array[String] ) {
var y=0;
repeatLoop {println("found y="+y)y += 1
}
{ until ( y < 10 ) }}
}
![Page 10: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/10.jpg)
Quick Introduction to Currying
Haskell Curry (1901 – 1982)American Mathematician & LogicianCombinatory LogicPartial Functions
U(x,y,z) == F(x) ‐> G(y) ‐> H(z)
![Page 11: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/11.jpg)
Repeat Until Construction #2
object Control {
def repeat(body: => Unit) = new {def until(condition: => Boolean) = {
do {body
} while (!condition)}
}
}
// Jesper and Rex Kerr
![Page 12: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/12.jpg)
Concurrency in Scala
Actor based concurrency library (Bill Venners)Asynchronous messagesDispatch to threads; Fork Join
![Page 13: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/13.jpg)
Taste of Concurrency #1
import scala.actors._import scala.actors.Actor._
object TradeMessageProcessor extends Actor {def act() {
loop {receive {
case f: FXOrder => f.spotPrice()case m: MMOrder => m.maturityPrice()case “stop” => println(“Stopping now...”; exitcase x: Any -> println(“Error: unknown msg: “+x)
}}
}}
![Page 14: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/14.jpg)
Taste of Concurrency #2
TradeMessageProcessor.start()
TradeMessageProcessor ! new FXForwardOrder ( /*...*/ )
TradeMessageProcessor ! new FXSpotOrder( /*...*/ )
TradeMessageProcessor ! new MMOrder( /*...*/ )
TradeMessageProcessor ! 2.87134 // Unknown Msg Error!
TradeMessageProcessor ! “stop” // Processor stops
![Page 15: Javawug bof 57 scala why now](https://reader036.vdocument.in/reader036/viewer/2022081414/54c7f0d84a7959a7608b461c/html5/thumbnails/15.jpg)
Thanks For Your Attention!
For more informationhttp://scala‐lang.orghttp://daily‐scala.blogspot.com/http://stack‐overflow.com search on Scala
Scala is the Java of the Future
http://jroller.com/javawug