After seven years of development, the General Availability release of Scala.js 1.0.0 is here. This dialect of Scala compiles Scala code directly to JavaScript and includes editor support which catches typos before you even compile your code. See how to update to version 1.0.0, how to get started, and take a brief tour of its key features.
Scala.js is a dialect of Scala which compiles Scala source code to JavaScript code. The 1.0.0 version arrived on February 25, 2020, after seven years of development.
From the announcement blog:
Scala.js 1.0.0 is the culmination of our efforts to simplify, specify, and future-proof all aspects of Scala.js, from the language semantics to the internal APIs, so that there is nothing left to take away.
Users should take note that the 1.0.0 release includes a number of breaking changes that are incompatible with 0.6x. In the 1.0.0 announcement post, users are recommended that they upgrade to version 0.6.32 or later and address all breaking changes before moving forward with the update.
SEE ALSO: Python web framework JustPy – interactive websites without JavaScript
1.0.0 enhancements
This release mainly focused on “simplifying Scala.js” and future-proofing it, instead of adding new features, so there is a short list of new enhancements and improvements.
The new enhancements include:
- Access
require
and other “global” variables of special JavaScript environments
- Easily declare inner classes in native JS classes
- Declare non-native JS classes inside outer
class
es or inside def
s, and use their js.constructorOf
- Run-time performance improvements
Version 1.0.0 fixes various bugs and resolves open issues as well.
by Manfred Steyer (SOFTWAREarchitekt.at)
Scala.js overview
Compared to similar languages that compile to JavaScript, (such as TypeScript) Scala.js includes more language features, such as an optimizing compiler, extensive standard libraries, macros, and a strong type system. It offers interoperability, so users can use any JavaScript library directly from their Scala.js code, including React and Angular JS.
The IDE helps catch most errors and typos without having to compile your code.
JavaScript developers can view the comparison between Scala.js code and JavaScript code and get started with the hands-on tutorials. Or, test it out in the browser and create a small program with ScalaFiddle, an online playground. Simply write some Scala code and press the Run button to begin compiling.
A number of project skeletons are available so you can begin playing around with Scala.js as soon as possible.
Getting started requires a recent version of Java JDK and SBT. View the repository on GitHub.
SEE ALSO: Mint programming language is an alternative to JavaScript for writing single page apps
A look back
Back in 2013, we interviewed the creator of Scala.js, Sébastien Doeraene about the compiler’s origins and what it aims to achieve. Did it achieve its goal? Take a look back and see how far this compiler has come from its v0.1 infancy.
Why did Doeraene begin the project? From the interview:
It was not my idea, actually. When I applied for a position in LAMP, the Programming Methods Laboratory at EPFL, aka the Scala Team, Martin Odersky suggested that I work on a JavaScript compiler backend. As I already had experience with writing a backend for Scala targeting a dynamically typed language (with my previous work on Ozma), I had a head start to make this happen. Besides, I love Scala, and I love writing compilers, so I was super excited to start on this project. The fact that a lot of people are really excited about this is also highly motivating.
What will it add in the next release?
Author
Sarah Schlothauer is an assistant editor for JAXenter.com. She received her Bachelor's degree from Monmouth University and is currently enrolled at Goethe University in Frankfurt, Germany where she is working on her Masters. She lives in Frankfurt with her husband and cat.
She is also the editor for
Conditio Humana, an online magazine about ethics, AI, and technology.