Note, however, that Scala.js is not part of the Typesafe Reactive platform. Thus, although we consider Scala.js production-ready, Typesafe does not provide any commercial support for it.
More than a compiler, an entire ecosystem
.scala files to a single optimized and minimized
.js file per application.
Just like regular Scala, you get all the powerful language features that you know and love: type inference, classes, traits and objects, pattern matching, the collections library, implicits, etc.
While that all sounds great, a compiler would be nothing without an ecosystem of libraries and tools. Scala.js has that covered too!
Building Scala.js libraries and applications is easy – there is an sbt plugin, which gives you the same comfort and development speed as with Scala on the JVM. It can even run unit tests automatically with either Rhino, Node.js or PhantomJS, according to your needs.
Scala.js also has a growing ecosystem of libraries, which you can depend on through Maven dependencies (
libraryDependencies in sbt).
They cover UI frameworks, statically-typed client-server communication, reactive extensions, and so on.
Several popular Scala community libraries such as Shapeless and Scalaz cross-compile with Scala.js.
Why Scala.js is awesome
We’ve asked developers who use Scala.js daily why they think Scala.js is awesome. Here is a distilled version of what they have answered, in decreasing order of how many people mentioned it. You can read the entire discussion on the mailing list.
- 5 Share code between client and server
- 4 Tooling: IDE support, sbt integration, dependency, unit testing, stack traces and source maps, cross-compiling projects
- 2 Fast compilation cycle (wrt other compile-to-JS options such as GWT)
- 2 Statically-checked client-server RPC with Autowire
- 2 The Scala Standard library
- 2 It’s not a toy
- 2 Great community, welcoming to new users and helpful
- 1 Very good documentation
Here are also a few selected quotes from the mailing list discussion.
It’s mostly about the strong typing for me. Nothing revolutionary about that idea, but it’s just as true on the client as on the server: having the compiler type-check your code makes it much quicker to get complex, sophisticated systems up and running.
Also, having the same language, end-to-end, is fabulous. […] With Scala.js, for the first time ever, I have a single solid, strongly-typed language that I can use throughout the system – from the fiddly details of the UI, through the API definitions and the front-end web server, to the Akka middleware and the database back end. That’s really kind of amazing. It is also why I personally think Scala.js is the killer app for Scala as a language. – Justin du Cœur
In a lot of ways, Scala.js frees your Scala code from the confines of the headless Linux server that it’s been running on for years. Scala might be a nice language, but you’ve never been able to use it to make anything cool that a non-backend-systems person would understand. […] With Scala.js, you can easily create small Scala applications and email the tiny 100kb executables (or just the link to them) to anyone, who can run them on any modern device, even smartphones. Made a cute game? A fun visualization? An animated sequence? Now you can show the world.
Scala’s no longer just for distributed systems people and type-theorists! – Li Haoyi
js.Dynamicor add a typed facade if desired is fantastic. – Nick Childers
Scala.js has very good tooling and very good documentation. If you already write JVM flavoured Scala you can be up and running in no time and write JS flavoured Scala. – Guillaume Belrose
[…] Scala.js has one of the smartest and most responsive communities I have ever seen. You, Li Haoyi, and many other posters here have contributed to making this platform welcoming to newcomers. The help I’ve received here has encouraged me to learn Scala proper, as well as many interesting functional programming concepts. – Travis Good
One of the biggest awesomeness of Scala.js is the core team’s steady hands. Right from the get go, Scala.js showed a mature engineering approach where each release made a meaningful difference to user projects, vetted release-to-release compatibility, communicated breaking changes well in advance, maintained useful associated libraries, and let pragmatism win over everything else. As a result, even though this is such a new project, it doesn’t feel risky to use it in real projects. – Ramnivas Laddad
Scala.js is simply the best option available on browsers today, if you’re looking for a language with a powerful yet flexible type system. – Xavier Cho
Why remove the experimental flag now?
Many Scala.js users would say that it has been production-ready for quite some time already. Possibly as early as 0.5.0, which was released in June 2014. So why do we choose to remove the experimental flag now? What has changed?
The big difference is several different aspects of stability:
- The semantics of the language are settled. They may still evolve in a backward compatible way (defining previously undefined behaviors), but will otherwise not change anymore.
- The standard library of Scala.js (the
scala.scalajs.jspackage) will remain backward source and binary compatible.
- The sbt builds will remain backward source compatible.
Of course, we must still be able to evolve the library and the builds, so things might become deprecated, and eventually removed, but will do so at a slower pace than before.
All things considered, this means that the code you write today, for Scala.js 0.6.0, will continue to work throughout 0.6.x and 1.x.y unchanged.
“So why isn’t it 1.0.0 already? It seems like these properties satisfy to the requirements of a 1.0.0 version. What are you hiding?”
While from all user-visible points of view Scala.js is stable, there remains just one quasi-implementation detail which might have to change in future versions – the format of the intermediate files of Scala.js, the
These files are essentially the Scala.js equivalent of
.class files for the JVM.
We’re not yet completely certain that we’re settled on their format, so we’d like to reserve the possibility of changing it in the coming months.
Doing so means breaking binary compatibility (by definition), and therefore would require a change in major version number.
So we’re not yet jumping to version 1.0.0 just yet – this is so that we may give ourselves one last chance to modify the Scala.js intermediate format before we make the leap to our first major version.
Though, rest assured! We’re confident that Scala.js is otherwise stable and ready for widespread adoption.
There are three main ways to get started with Scala.js:
So go ahead! Use it, love it, and build the web applications of the future!