Other Projects

Blog

January 8, 2013

Announcing Scala 2.10: A Simpler Way to Tackle Complex Problems

January 8, 2013

We are very excited about the first release in the Scala 2.10 series. This release makes it even simpler to tackle the tough challenges that developers face every day, ranging from the syntactic nicety of String Interpolation to expressing massive asynchronous computations in sequential code style.

Many new features enable library and framework developers to provide a simpler yet richer developer experience for their users. For example, the Play Framework harnesses Scala 2.10's new asynchronous programming model to compose services efficiently and concisely. Similarly, other library developers are using Scala 2.10's experimental Macros and Reflection features to further reduce complexity in applications. Even String Interpolation is easily extensible by library developers in Scala 2.10!

Here are some of Scala 2.10's new features that you can start using right now.

String Interpolation: Simple Type Safe String Substitution

Often times a developer needs to compose strings of text by substituting values for place holders. Scala 2.10 adds a new String Interpolation library that works with the power of compile-time type checking in Scala. Here are two examples.

To insert the contents of a variable in a string, simply prefix the string literal with an "s" and prefix the variable with a "$".

// log only two digits after the decimal to display as seconds
log.info(f"Time elapsed: ${millisElapsed/1000.0}%.2fs.")

The Scala IDE now supports Scala expressions in String Interpolations.

Futures & Promises: A Concise Async Programming Model

The Scala team at EPFL and the Akka team collaborated on a new API which standardizes the API for asynchronous programming using the Future and Promise paradigms. With valued input from Twitter and many other developers building massively asynchronous systems, the result is a very convenient API for expressing powerful asynchronous computations. Additionally, Akka's actors are now included in the distribution.

Developers who are building complex integration apps with Play and Akka are raving about the new Scala 2.10 Future API because it allows them to fire off hundreds of HTTP calls, then compose the results and render a web page. Composing numerous asynchronous calls in Scala 2.10 using a for-comprehension provides a concise programming model that feels natural but also manages resources efficiently and deals with errors gracefully. For instance, an asynchronous request handler in Play, that makes three asynchronous requests to render a page, may look like:

Under the covers, Akka, Scala, and Play all work together to efficiently manage concurrency and resource utilization while maintaining a simple and concise programming model.

Value Classes: Objects On a Diet

Enhancing classes to include additional functionality while avoiding runtime overhead is now possible in Scala 2.10 with Value Classes. For instance, if you need to be able to convert every Int to its hexadecimal representation, then a Value Class can do this without having to create unnecessary instances. For example, the following RichInt class is a Value Class that allows you to wrap an Int to add a toHexString method, without the overhead of allocating an extra object.

Together with Implicit Classes, Value Classes make it simple to enhance objects in a type safe and concise way!

Even More: Scala 2.10 is Simply Better

Scala now provides a way to control different levels of language features so that those just learning to swim don't get thrown into the deep end of the pool. We've come up with a way of putting you in control of which of the features your codebase relies on. This simplifies the initial experience that developers have with Scala and allows organizations to scale their use of the language.

The pattern matcher was rewritten from scratch to produce more robust code and provide more user-friendly error messages.

The Dynamic trait provides a convenient construct for using dynamically typed objects when it makes sense (for example, accessing untyped data over REST).

The bytecode generator now uses the industry-standard ASM library to generate bytecode much faster and for a wider variety of JDK versions including the Java 1.5, 1.6 and 1.7 versions.

Scaladoc now shows implicitly added members, inheritance diagrams and member grouping. Check out the Future documentation to see it in action!

Scala 2.10 includes a few experimental features, including Macros and Reflection. While these are expected to change in the Scala 2.11 series, it hasn't stopped people from doing verycoolthings with them!

At Typesafe we are very excited about the Scala 2.10 release and everything it does to make developers more productive and apps more efficient! You can try out Scala 2.10.0 by downloading the standalone distribution (which includes the REPL) or get started in Eclipse using the Scala Eclipse Plugin. We think Scala 2.10 sets a new standard for building highly sophisticated and amazing apps in a simple, concise manner; we think you'll agree. More power less code!

From the blog

While Reactive application development is off to a roaring start and becoming mainstream, this leads to demands on Operations that are simply not met by yesterday’s software architectures and technologies. The pressure facing enterprises to manage resilient, responsive systems is brutal, yet most existing technologies available today are not designed to deploy and manage Reactive systems running on clusters. It’s due to this fact that Operations face a higher risk of downtime by using inappropriate tools/practices at a time when being unavailable is more costly than ever. So why is this happening? Well, it's not 2005 anymore–and why that's a problem for Operations is explained here...

Ten months ago we posted about architectural changes to Typesafe Activator. After a few a lot of yak shaves, side projects, and detours, we have Activator 1.3.0 based on sbt server, a new setup where multiple clients can share the same instance of sbt. sbt server is also available in ABI-stable protocol-stable form for other clients (IDEs, command line, desktop status icon, whatever you can think of) to try out.