Interpreting Scala in the Browser
That's great advice - but can't we do better? What if we could share actual running, hackable code?
Turns out we can: there's a number of 'JSFiddle'-style projects around, and I'll take a brief look at some of them.
This allows you to create beautiful visuals while running your applications. This could be an awesome teaching tool. Be sure to check out their documentation, which comes generated on-the-fly by a Scala snippet!
The downside of using Scala.js is of course that you're restricted in which libraries you can include.
Even though this tool is not restricted to Scala.js, only a limited number of libraries is included.
While again you don't have control over which dependencies are available, a nice collection is included.
Unlike other options Scala Kata does not show the output of the program, but the value of the expression on each line, which might be familiar if you've ever worked with the 'notebook' feature of Scala IDE. While sometimes constraining, this encourages a nicely functional style.
Scala Kata is currently my online Scala environment of choice, though unfortunately it doesn't provide an easy way to store and share your snippets.
Scala Notebook looks pretty clean, but unfortunately does not appear to be available in hosted form anywhere.
The project takes its inspiration from the IPython notebook, which is indeed a great example.
An interesting aspect of Scala Notebook is that, somewhat like scala-js-fiddle, it allows rich output: when a command returns HTML or an image, it will be rendered/shown.
Users of scastie will have to do without fancy features such as advanced highlighting and completion, but gives you complete control over the sbt configuration - making it a very powerful alternative.
|intermediate values||completion||git(hub)||dependencies||scala version|
|Scala Notebook||yes||no||no||full control|
Some desirable features, like a more 'direct' REPL-like interface, are not widely supported. Also, none of the available offerings appear to be particularly easy to embed into an existing site or blog.
If these services would become wildly popular, I wonder whether making sure there is sufficient back-end computing power available might become a challenge. On the other hand, computing is rapidly becoming cheaper, so this might not be an issue after all.
I was amazed by the number of projects that managed to make a functional Scala programming environment available in the browser. While there's more work to be done, there is amazing potential here.