Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build a scala interpreter in the browser

Tags:

scala

My first contact with Scala was through the SimplyScala tutorial: You don't need to install anything and can just start to code. After some hours I fell in love with the language...

Years later, I have written a web documentation for a Scala library as a Play Application. It would be cool to build something like SimplyScala and integrate it in the documentation, so that the user can enter Scala commands in the browser and get the result back.

SimplyScala works like LotREPLS (old Open-Source-Java-Project with just few LOCs) on the Google App Engine.

Is is also possible to create something like this on my own server without getting security holes (f.ex. the user should not read files from the server...)?

I just need the "base" of the Scala language without any imports just like in SimplyScala.

My first idea is to write an own SecurityManager and handle time-outs so that the user cannot consume too much server time. Is there any easier way or an existing open-source project?

Or is it just more rational to advice the user to install Scala and work with the terminal instead of the browser? ;-)

On the Scala homepage is a similar Play-project idea for the Summer of Code 2012 Scala Projects: but I cannot find any results.

like image 937
Sonson123 Avatar asked Mar 13 '13 13:03

Sonson123


1 Answers

Probably the most secure so far is http://www.scala-js-fiddle.com/ (code on GitHub) simply because it does not even run the code on the server, but on the client!

The gotcha is: it's not truly Scala code, it is Scala.js, which is a dialect of Scala, is still experimental, etc. But it might be enough for your use case.

like image 117
sjrd Avatar answered Sep 21 '22 05:09

sjrd