We don’t usually think of Scala as a front-end language, but Scala.js is challenging that assumption. The framework gives you easy access to the DOM and therefore the canvas, making it trivial to develop an HTML5 application.
To demonstrate this, I built an A* maze solver entirely in Scala.js:
A summary of my discoveries:
- Rapid prototyping and development of small web apps
- Fast and highly-optimized code
- SBT is a pain to work with. Versions must line up, and the SBT spell must be incanted exactly to get your project to build.
- You can’t run code or tests from the IDE (well, at least IntelliJ). One workaround I saw is to create two projects: one for Scala and one for Scala.js and integrate them in the IDE. Feels clumsy.
- You can only use code that has been compiled for Scala.js which means that most libraries and any Java code you have won’t work out of the box.
I wouldn’t be ready to recommend Scala.js in production, but it is definitely fun to play with and I hope more people try it out and expand the ecosystem.
Full code for this project available on GitHub.
Sbt is controversial like vi or emacs, you hate it or love it. I only love only the first one. I know it’s not all straightforward, but if it works, it give a lot more efficiency.
So this workbench gives you the right integration with the IDE. Try it.
Leave it to Haoyi to have another handy tool! Thanks for the recommendation, I’ll have to take a look.