Your SlideShare is downloading. ×
  • Like
What's new in Scala and the Scala IDE for Eclipse for 2.8.0
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

What's new in Scala and the Scala IDE for Eclipse for 2.8.0

  • 1,158 views
Published

Talk given at the London Scala Users Group 2nd July 2009

Talk given at the London Scala Users Group 2nd July 2009

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,158
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
14
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. What's new in Scala and the Scala IDE for Eclipse for 2.8.0 Miles Sabin, Chuusai Ltd. http://www.chuusai.com/
  • 2. Vastly Improved REPL ● Read Eval Print Loop: Interactive interpreter ● Unusual for a statically typed JVM language ● New maintainer: Paul Phillips ● New for 2.8.0 ● Completion (packages, classes, members) ● Interactive debugging
  • 3. New Collection Libraries ● Collections in <= 2.7.5 ● Evolved haphazardly ● Hard work for implementors ● Code duplication to avoid unnatural types ● Unpredictable performance ● Java interoperability incomplete
  • 4. New Collection Libraries ● Collections in 2.8.0 ● Coherent design in terms of traversals and builders ● Builders support natural types ● Systematic sharing reduces duplication ● Lazy views now explicit ● Java interoperability conversion bidirectional ● Minimal impact on clients
  • 5. New Collection Libraries Traversable Iterable Map Set Sequence SortedMap SortedSet BitSet Buffer Vector LinearSequence
  • 6. Package Objects ● How to support clients expecting old package layout? ● Package objects support additional members not on any class, trait, object package object scala { type List[+A] = scala.collection.immutable.List[A] val List = scala.collection.immutable.List ... } ● Can be used by any library provider
  • 7. Break (but not continue) ● Scala promotes functional styles — this can trip up imperative programmers for(e <- l) if(p(e)) f(p) else ??? // How to bail out? ● Traditional break behaviour now provided via a library import scala.util.control.Breaks._ breakable { for(e <- l) if(p(e)) f(p) else break // Continue from * } // *
  • 8. Type Constructor Inference ● Type constructor polymorphism originally introduced in 2.5.0. ● Intention was to provide natural types for collection methods ● Lack of type inference made this difficult in practice — new collections use alternative ● Patch being reviewed for 2.8.0, but not yet clear if it will be included
  • 9. Named and Default Arguments ● Method arguments can be supplied by name instead of position def resize(width: Int, height: Int) = { ... } resize(width = 120, height = 42) ● Method definitions can provide default arguments as an alternative to overloading def encode(s : String, encoding : String = “UTF-8”) encode(“Hello world”) // Uses default encoding encode(“Hello world”, “ISO-8859-1”) // Uses supplied ● Allows support for nested annotations
  • 10. Functional Objects ● An appliction of named and default arguments ● Functional update for case classes case class Complex(val re : Double, val im : Double) val c1 = Complex(1.0, -1.0) val c2 = c1.copy(re = 2.0) // c2 == Complex(2.0, -1.0) ● Tuples are case classes so they inherit this behaviour val p1 = (23, “foo”) val p2 = p1.copy(_2 = “bar”) // p2 = (23, “bar)
  • 11. Delimited Continuations ● Powerful control abstraction capturing the concept of “the rest of the computation” ● Can be used to build coroutines, generators and more exotic things (type- safe printf) ● Enable event-driven I/O models without requiring explict state machines ● Initially being provided via a compiler plugin
  • 12. Delimited Continuations ● call/cc (Scheme etc.) capture the entire subsequent control flow ● Scala continuations capture control flow within a delimited region (shift/reset) import scala.continuations._ import scala.continuations.ControlContext._ val result = reset { shift { s : (String => String) => s(“Hello”) } + “ world” } // result == “Hello world”
  • 13. Delimited Continuations ● Can be stored for later execution var stored : (String => String) = _ reset { shift { s : (String => String) => stored = s } + " world" } stored("Hello") // == “Hello world” This enables complex control flow behaviours ● Can be serialized for remote execution
  • 14. Type Specialization ● Adding @specialize annotation to generic type parameter — compiler generates specialized versions of ● Can eliminate expensive boxing and unboxing with higher order functions and arrays. ● Significantly reduce the cost of abstraction ● Nb. this doesn't eliminate erasure in general
  • 15. The Scala IDE for Eclipse ● Integration with the JDT continues ● Much functionality migrated to scalac ● New interface for extracting semantic information for hyperlinks, hovers, completion ● New build manager ● More robust basic functionality ● Dramatic simplification of the codebase ● More maintainable ● Lower barrier to contributions
  • 16. What's new in Scala and the Scala IDE for Eclipse for 2.8.0 Miles Sabin, Chuusai Ltd. http://www.chuusai.com/