CSE 5317Lecture 13: Scala14 Oct 2010Nate NystromUniversity of Texas at ArlingtonScala• Developed by Martin Odersky’s group at EPFL in Lausanne, CH, from 2003-present• Integrates OO and functional programming features• Runs on the JVM and on .NET• JVM better supported, though• Seamless integration with Java• Scala programs can use Java classes• Java programs can use Scala classesWhere to get it• Scala webpage:• http://www.scala-lang.org• Download: http://www.scala-lang.org/downloads• Scala Eclipse, NetBeans, IntelliJ plugins• http://www.scala-lang.org/node/91Where to learn more• Scala tutorials:• http://www.scala-lang.org/node/1305• http://www.artima.com/scalazine/articles/steps.html• Scala books:• Programming in Scala by Odersky, Spoon, and Venners• Programming Scala by Wampler and Payne• Free download from:• http://programming-scala.labs.oreilly.com/Scala compiler and interpreter• Compiler•scalac%foo.scala – compiles foo.scala to Java bytecode • Interpreter:•scala%foo.scala – compiles and runs foo.scala•run scala on the command-line to get a “shell”Features• Lightweight syntax• no ‘;’ required• def, val, var• method call: x.m vs. x.m()• Type inference• Usual imperative features: while, if, ...• Iteration: for, foreach• Minor gotchas: no C-style for loop, no x++ (use x += 1)• Pure OO• all values are objects including: Int, Boolean, Float, Array[Int], ...• all operations are methods: + is a method of Int, ...• Function types, arrays, lists, tuples, sets, maps• Singleton objects rather than static• Traits (interfaces with code)Where to go• ssh omega.uta.edu• ~nystrom/scala/bin/scala• ~nystrom/scala/bin/scalac• add to your .bash_profile•
View Full Document