Skip to content

Instantly share code, notes, and snippets.

@nlinker
Created October 12, 2012 12:23
Show Gist options
  • Save nlinker/3878956 to your computer and use it in GitHub Desktop.
Save nlinker/3878956 to your computer and use it in GitHub Desktop.
Scala feature list

Basic features absent in Java

  • First-class functions
  • Implicit parameters / conversions
  • Pattern matching, case classes
  • Type inference
  • Higher-kinded types (abstraction over type constructors)
  • Monadic for comprehensions
  • Variance annotations
  • Interfaces with behavior (traits)
  • Default and named arguments
  • Unified methods and operators (methods can be used as infix operators, operators can be overloaded because they're just methods)
  • Unified type hierarchy; no primitive types
  • Properties rather than getters and setters
  • Abstract values
  • First-class immutable references (vals are as easy to declare as vars)
  • By-name (lazy) terms (maybe Java closures would make this reasonably easy to express)
  • Some tail-call recursion optimization
  • Abstract types
  • Type aliasing
  • Self types
  • Path-dependent types
  • Structural types
  • Type ascription, as distinguished from type casting
  • Renaming imports
  • First-class modules (objects)
  • First-class packages
  • Reified generics (manifests)
  • Delimited continuations
  • MACROS (http://scalamacros.org/, coming in Scala 2.10)

Some cool secondary constructs that these building blocks enable:

  • Type classes (via implicit parameters and higher-kinded types)
  • The "Pimp My Library" pattern (via implicit conversions)
  • Internal DSLs (via operator overloading and infix methods)
  • Parser combinators (enabled by higher-order functions and made pretty by infix methods)
  • Generators, coroutines, custom control structures (via delimited continuations)
  • Type-level programming (via higher-kinded and abstract types)
  • Obsolescence of dependency injection frameworks (via the Cake Pattern)

Lastly, I'll mention that Scala has a REPL (read-evaluate-print-loop) -- not really a feature of the language itself, but it's very nice to have!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment