Scala.js A 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.
Important notice! Scala.js is still experimental! Although this is a project of LAMP/EPFL for which we will continue to provide best-effort improvements and bug fixes, it is not supported by Typesafe, and not part of any of their support contracts. You have been warned!
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
Resources
- Documentation
- Official mailing list
- Scala.js tag on Stackoverflow. Please help building it up by asking questions.
Presentations:
- Hands-on Scala.js at PNWScala, by Li Haoyi
- Cross-Platform Development in Scala.js, by Li Haoyi
- Scala's evolving ecosystem- Introduction to Scala.js, by Ayush Mishra, Knoldus Software LLP
- Scala.js at Scaladays 2014, by Sébastien Doeraene
- Live Coding Scala.js at SF Scala 2014 by Li Haoyi
- Live-coding with Scala.js at Scala eXchange 2013
- Presentation of Scala.js at Scala Days 2013 (older and somewhat obsolete)
Libraries
This is a collection of libraries that 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 are such as scala-async
are pure-macro projects, and thus work with Scala.js out of the box. Most of them, though, started off as Scala-JVM projects and were ported over, and thus have separate artifacts to run on each platforms. The SBT snippets given are for the version that runs on Scala.js.
scala-js-dom
"org.scala-lang.modules.scalajs" %%% "scalajs-dom" % "0.6"
Static types for the DOM API, by Li Haoyi
scala-js-jquery
"org.scala-lang.modules.scalajs" %%% "scalajs-jquery" % "0.6"
Static types for jQuery, by Sébastien Doeraene
scala-js-react
// Minimal usage
libraryDependencies += "com.github.japgolly.scalajs-react" %%% "core" % "0.6.1"
// Test support including ReactTestUtils
libraryDependencies += "com.github.japgolly.scalajs-react" %%% "test" % "0.6.1" % "test"
// Scalaz support
libraryDependencies += "com.github.japgolly.scalajs-react" %%% "ext-scalaz70" % "0.6.1" // or
libraryDependencies += "com.github.japgolly.scalajs-react" %%% "ext-scalaz71" % "0.6.1"
Lifts Facebook's React library into Scala.js and endeavours to make it as type-safe and Scala-friendly as possible, by David Barri
scala-js-binding
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.1") // project/build.sbt
resolvers += bintray.Opts.resolver.repo("denigma", "denigma-releases")
libraryDependencies += "org.denigma" %%% "binding" % "0.4.4"
A ScalaJS html binding library, by Anton Kulaga
Scalatags
"com.scalatags" %%% "scalatags" % "0.4.2"
A HTML templating library/DSL that works on both Scala-JVM and Scala-JS, by Li Haoyi
Scala.Rx
"com.scalarx" %%% "scalarx" % "0.2.5"
A change-propagation/FRP library that runs on both Scala-JVM and Scala-JS, by Li Haoyi
uTest
addSbtPlugin("com.lihaoyi" % "utest-js-plugin" % "0.2.4") // project/build.sbt
"com.lihaoyi" %%% "utest" % "0.2.4"
A tiny, portable unit testing library that lets you run the same tests on both Scala-JVM and Scala-JS, by Li Haoyi
Little Spec
libraryDependencies += "org.qirx" %%% "little-spec" % "0.3" % "test"
ScalaJSKeys.scalaJSTestFramework in Test := "org.qirx.littlespec.scalajs.TestFramework"
A small extendable test/specification library that can generate documentation, works on both Scala-JVM and Scala-JS, by EECOLOR
MiniTest
libraryDependencies += "org.monifu" %%% "minitest" % "0.2" % "test"
testFrameworks += new TestFramework("minitest.runner.Framework")
MiniTest is a light and effective testing framework for Scala, that lets you share tests across Scala on the JVM and Scala.js, by Alexandru Nedelcu.
NOTE: At this point it is compiled for Scala.js
milestone 0.6.0-M2,
and won't work with the stable 0.5.x
.
uPickle
"com.lihaoyi" %%% "upickle" % "0.2.5"
Statically-typed pickling (via typeclasses/macros) for both Scala-JVM and Scala-JS, by Li Haoyi
autowire
"com.lihaoyi" %%% "autowire" % "0.1.2"
Statically-typed Ajax calls and RPCs for both Scala-JVM and Scala-JS, by Li Haoyi
Scala.js Pickling
"org.scalajs" %%% "scalajs-pickling" % "0.3"
A cross-compiling pickling (aka serialization) library for Scala.js and Scala with a common JSON-based format, by Sébastien Doeraene
Prickle
"com.github.benhutchison" %%% "prickle" % "1.1.0"
Yet another statically-typed pickling library for Scala.js / Scala.jvm, with support for pickling object graphs containing shared objects and cycles, by Ben Hutchison
Monifu
Reactive extensions (Rx) with back-pressure, atomic references and other multi-threading primitives cross-compiled to Scala.js, by Alexandru Nedelcu
Scalaz
"com.github.japgolly.fork.scalaz" %%% "scalaz-core" % "7.1.0-4"
"com.github.japgolly.fork.scalaz" %%% "scalaz-effect" % "7.1.0-4"
// etc
Port of Scalaz to Scala.js, maintained by David Barri
Monocle
"com.github.japgolly.fork.monocle" %%% "monocle-core" % "1.0.1"
Port of Monocle to Scala.js, maintained by David Barri
RNG
"com.github.japgolly.fork.nicta" %%% "rng" % "1.3.0"
Port of RNG to Scala.js, maintained by David Barri
Shapeless
resolvers += "bintray-alexander_myltsev" at "http://dl.bintray.com/content/alexander-myltsev/maven"
libraryDependencies += "name.myltsev" %% "shapeless_sjs0.5" % "2.0.0"
Port of Shapeless to Scala.js, maintained by Alexander Myltsev
Scala-Async
"org.scala-lang.modules" %% "scala-async" % "0.9.1"
Scala-Async is a pure-macro project without any runtime dependencies. Thus it works with Scala.js out of the box, without needing to be specially compiled for it.
Scalaxy Loops and Streams
Another pure-macro project, Scalaxy loops and streams work great with Scala.js without needing to be specially compiled for it.
scalajs-angular with TodoMvc example
Static types and complementary API for AngularJS, by Xavier Cho
Skeletons
workbench-example-app
A 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
by Vincent Munier
Node.js module with Scala.js
by Rocky Madden
Tools
Scala.js workbench
A sbt plugin for Scala.js projects for live-reloading in the browser (example app), by Li Haoyi
Miscellaneous
- Port of the Dart benchmark harness by Jonas Fonseca
Contribute
Want to contribute to Scala.js? Check out the list of contributing opportunities.
Built with Scala.js
List of websites using Scala.js:
- 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.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