Scala.js the Scala to JavaScript compiler
Scala.js compiles Scala code to JavaScript, allowing you to write your web application entirely in Scala! Take a look at the project gallery to see what kind of things you can build with Scala.js.
Get started
Start the Tutorial Try it in the Browser
The easiest way to get started is to follow our tutorial. You can also fork the bootstrapping skeleton and follow the instructions in its readme or try it out in the browser. There's also an e-book Hands-on Scala.js which contains a lot of introductory material to help you get started.
We also have a standalone distribution that doesn't require SBT.
Note 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.
Noteworthy features
- Support all of Scala (including macros!), modulo a few semantic differences
- Very good interoperability with JavaScript code. For example, use jQuery and HTML5 from your Scala.js code, either in a typed or untyped way. Or create Scala.js objects and call their methods from JavaScript.
- Integrated with sbt (including support for dependency management and incremental compilation)
- Can be used with your favorite IDE for Scala
- Generates Source Maps for a smooth debugging experience (step through your Scala code from within your browser supporting source maps)
- Integrates Google Closure Compiler for producing minimal code for production. Compiled blobs range from 170-400kb
- Produces (very) efficient JavaScript code (benchmarks)
Resources
- Documentation: APIs, guides, and reference.
- Scala.js tag on Stackoverflow: for delimited technical questions on using Scala.js.
- Official mailing list: for general discussion, ideas, announcements of your libraries, etc.
- Gitter chat room: come and meet the community of Scala.js users.
Featured presentations to get you convinced:
- Hands-on Scala.js at Pacific North-West Scala 2014, by Li Haoyi
- Cross-Platform Development in Scala.js at Scala by the Bay 2014, by Li Haoyi
Libraries
This is a collection of libraries known to work with Scala.js.
Some of them, like scala-js-dom
and scala-js-jquery
, are specific to Javascript and don't make sense on the JVM.
Some others, such as scala-async
, are pure-macro projects, and thus work with Scala.js out of the box.
Most of them, though, are cross-compiling over JVM and JS, and thus have separate artifacts to run on each platform.
Static types for JavaScript libraries
- scalajs-dom: static types for the DOM API, plus a few extensions
- scalajs-jquery: static types for jQuery
- jquery-facade: alternate static types for jQuery -- less complete, more strongly typed
- scalajs-pouchdb: static types for PouchDB
Testing frameworks
All these testing frameworks cross-compile on the JVM and JS.
- uTest
- MiniTest
- Little Spec
- Nyaya: Property testing and related.
- zcheck: A wrapper around scalacheck and scalaz's Speclite.
- Greenlight
HTML templating libraries
- Scalatags: cross-compiling HTML templating library/DSL that works on both Scala/JVM and Scala.js
UI frameworks
- scalajs-react: Type-safe and Scala-friendly library over Facebook's React.
- scala-js-binding: An all-Scala.js HTML binding library
- scalajs-angular with TodoMvc example: static types and complementary API for AngularJS
- scalajs-angulate: another binding to AngularJS with enhancements
- Widok: Reactive web framework for the JVM and Scala.js
Serialization/pickling libraries
- uPickle: cross-compiling statically-typed pickling (via typeclasses/macros) for both Scala/JVM and Scala.js
- Prickle: cross-compiling statically-typed pickling library with support for pickling object graphs containing shared objects and cycles
- Scala.js Pickling: cross-compiling pickling library based on explicit registration of picklers
Client-server communication
- autowire: cross-compiling statically-typed Ajax calls and RPCs
Visualization
- Paths.scala.js: a library to generate SVG charts and shapes (wrapper over Paths.js)
FRP/reactive extensions
- Scala.Rx: cross-compiling change-propagation/FRP library
- Monifu: cross-compiling reactive extensions (Rx) with back-pressure, atomic references and other multi-threading primitives
Ports of well-known Scala libraries
- NICTA/rng: Pure-functional random value generation.
- Monocle: Optics library strongly inspired by Haskell Lens.
- Scalaz: Library for functional programming.
- Shapeless: Generic programming for Scala.
Miscellaneous
- Scala-Async (works out-of-box with Scala.js)
- Scalaxy Loops and Streams (work out-of-box with Scala.js)
- jsext: utilities for developing facades
Skeletons
- workbench-example-app: skeleton application using Scala.js workbench for live-reloading in the browser, together with a collection of sample applications developed using it
- Play! application with Scala.js
- Node.js module with Scala.js
- SPA tutorial with Scala.js and React: Simple Single Page Application tutorial built upon scalajs-react, Spray and Bootstrap.
Tools
- Scala.js workbench: sbt plugin for Scala.js projects for live-reloading in the browser (example app)
Miscellaneous
Contribute
Built with Scala.js
List of websites using Scala.js:
- April 2015
- Querki, a cloud-based system for small-scale data management
- March 2015
- Doctus, a library for the creation of visual art pieces, by Wolfgang Wagner
- September 2014
- July 2014
- Play and Scala.js Showcase, by Hussachai Puripunpinyo
- May 2014
- Papa-Carlo Incremental Parser Demo, by Eliah-Lakhin
- April 2014
- Ray-Tracer, a ray-tracer written in Scala.js by Li Haoyi
- February 2014
- TodoMVC, an implementation of the TodoMVC example application using Scala.js, Scalatags, Scala.Rx and scala-js-dom, by Li Haoyi
- Sierpinski Triangle and Dodge the dot (Scala.js workbench example apps), by Li Haoyi
- Scala.jsFiddle, an online scratchpad that lets you compile and run Scala.js snippets right in the browser, by Li Haoyi
- December 2013
- Roll, a 2D Physics Platformer by Li Haoyi
- December 2013
- October 2013
- Several games by Li Haoyi
- July 2013
- Knapsack on a graph by Krishnan Raman
- June 2013
- April 2013
- The Reversi example by Sébastien Doeraene
Version History
- 0.6.2
- 0.6.1
- 0.6.0
- 0.6.0-RC2
- 0.6.0-RC1
- 0.6.0-M3
- 0.6.0-M2
- 0.6.0-M1
- 0.5.6
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3
- 0.2
- 0.1
Hall of Fame
- Bug in node.js/v8 discovered by Scala.js through Scala test suite