Updated March 20, 2023
Introduction to Scala Versions
Ever since the public release of Scala in early 2004 on the Java Platform, the scala team has been on their toes to make scala a popular language for development among developers. With every new version of Scala, the team has been able to introduce new features into the language. With such rapid developments, it is becoming the language of choice. It is the only JVM based language with wide support for Data Mining and Machine Learning libraries. Large Scale ML or BigData project stacks are incomplete without Scala.
In this article, we have listed down all the major releases of Scala that have shaped the language as it is now. With this article, we hope to give you a ride into what has changed over the years and how the language has evolved. So let’s get started.
Below are all the versions in Scala up to date and with the main features in all the versions:
2.5.0 was released around May 2007. Below are some of the main features in this version,
- Early Object Initialization: It allows initializing some fields of an object before any parent constructors are called.
- For-Comprehensions, Revised: Change in the syntax of for-comprehensions. The old syntax is can be reused. It will be deprecated in future versions.
- Implicit Anonymous Functions: It is now possible to define anonymous functions using underscores in the parameter position.
- Refined Pattern Matching Anonymous Functions: It is now possible to use case clauses to define a function value directly for functions of arities greater than one.
Below are the changes that went towards the 2.6.0 version,
- Existential Types: It allows defining existential types using the new keyword forSome.
- Lazy Values: It allows defining lazy value declarations using the new modifier lazy.
- Structural Types: It allows declaring structural types using type refinements.
- Java Generic Types Supported by Default: Translation of generic Java types such as ArrayList<String> to a generic type in Scala: ArrayList[String].
- Case Classes Functionality Extended: In every case now class a companion extractor object is generated by scala compiler.
- Type Specialisation: The compiler will generate multiple versions of a given definition and will use the most specific version when the static type info at the call site allows it.
- Named and Default Arguments: Added support for Named and Default args. Readability is improved by using Named args for a method call with many args. Code duplication is reduced by the use of Default args.
- Package Objects: From this version onwards Packages can now have fields or type aliases apart from classes and objects. They can be added to a package by declaring a package object.
- Improved Annotations: Support for nested java annotations. For annotations on fields, it allows specifying which synthetic members (getter/setter) will have the annotation.
- From this version onwards every collection can be converted to its corresponding parallel implementation. This can be done using its new par method. Parallel collections are useful as they utilize the multicore processors by implementing the filter, map, foreach, etc in parallel. One can find parallel collections in package scala.collection.parallel
- Thread-safe App trait replaces the Application trait.
- DelayedInit trait
- A new tool for customization of the initialization sequence of classes and objects is provided by the DelayedInit trait.
Java Interop Improvements
- The @strictfp annotation is now supported.
- Multiple fixes are pushed towards JavaConverters and JavaConversions allowing smooth interoperation. Now the Primitive types and their boxed versions will be implicitly converted, in both directions.
- Value Classes: In this version, by extending naval the class can now behave like a struct type
- Implicit Classes: One can now use the implicit modified to class definitions further reducing the boilerplate code required for implicit wrappers.
- String Interpolation: With the addition of string interpolation users can now add variable references directly in processed string literals.
val name = "James" println(s"Hello, $name") // Hello, James
- Futures and Promises: Futures can run many operations in parallel in an efficient and non-blocking way. A promise is like a writable, single-assignment container, which completes a future.
- Dynamic and Applydynamic: x.foo can now be written as x.applyDynamic(“foo”) if foo is not defined by x’s type, but is a subtype of Dynamic
- Dependent Method Types:
def depMethod(a: AnyRef): a.type = a // we return what we get
New Bytecode Emitter Based on Asm
- The new version will be able to target JDK 1.5, 1.6 and 1.7
- bytecode version 1.6 is emitted by default.
- The older 1.5 backends are now deprecated.
Introduced a New Version of Pattern Matcher
- The old pattern matcher was rewritten to provi.
- code generation and analysis are now independent.
- Implicits | usage: -implicit
- Diagrams | usage: -diagrams flag, prerequisite Graphviz
- Groups | usage:-groups flag
Akka Actors Are a Part of The Language Now: Akka implementation is now a standard way to use the Actor model in Scala now. The scala.actors will be deprecated from this version onwards.
- ??? and NotImplementedError added.
- IsTraversableOnce and IsTraversableLike type classes added for the extension methods.
- Floating point and octal literal syntax no longer used.
- Scala.dbc is removed
- Support for configuring custom thread pools with Parallel collections.
Some of the highlights of this version are as mentioned below,
- Collection performance improvements.
- Faster filters, unions, and the like, with improved structural sharing (lower memory usage or churn) for Immutable HashMaps and HashSets.
- Mutable LongMap and AnyRefMap are added to provide improved performance when keys are Long or AnyRef.
- BigDecimal now has support for a more verbose and explicit about numeric representations and rounding values. It also supports handling large values without exhausting memory.
- Compiler performance improvements.
The incremental compilation has been improved significantly in this version.
- Java 8 required
- Java 8 bytecode generated
- Java 8 SAM (Functional interface) language support
- Standard library collections are rewritten towards the end goal of performance, safety and most importantly simplicity.
- The future is now faster and is more robust. In the other parts, useful methods and classes have been added.
- Literal types, partial unification, and by-name implicits are some of the additions on the language front.
- The compiler is now 5 to 10% faster with a deterministic output. There has been some improvement in the optimizer as well.
This is a guide to Scala Versions. Here we discuss all the versions in Scala up to date and with main features in all the versions with a brief introduction to the major releases of scala. You can also go through our other related articles to learn more –