Live data from Hacker News

Scala.js - Write in Scala for the browser

lampwww.epfl.ch

21–30 of 33 posts

Re: Scala.js - Write in Scala for the browser

#21
First of all, if you watched the slides, you just ran the first `hello world` Scala-js app in your browser. The slides use the scala-js runtime. Developer tools have scalajs-runtime.js at 1.7MB compressed and about 4s to download/execute, then about 1.5s on subsequent refreshes.

Now, having seen the talk at Scala days here are a few notes/thoughts:

This is currently the result of 4 months worth of work, and Sébastien Doeraene, the author of the slides and the code there-in, is going to be working on it at EPFL for the next 4 years or so for his doctorate.

This is being done by replacing the backend portions of the Scala compiler that emit java bytecode with ones that emit javascript.

When the slide showing that it is 16MB came up everyone laughed and the author acknowledged how large a number this is. It is the result of having to bring in the entire the Scala standard lib. He is planning to work on ways of cutting this number down.

At the end of talk Martin Odersky commented from the audience that this is an attempt by the EPFL at making Scala useable for large webapp development. If it proves successful more resources will put towards supporting it.

I plan to try this out for internal sites used by my company. Currently we split and then have to duplicate a lot of our code between Scala / Javascript. Scala for the server software, Javascript for frontends which are webapps. I haven't had time since I got back to do much more than clone the git repo.

Re: Scala.js - Write in Scala for the browser

#22
post #2

16MB runtime is really painful. Having to pack a huge amount of the standard library (List is backed by a lot of other traits for example) into the js is going to be very difficult to reduce.

For applications, that should be somewhat more acceptable than for standard web pages (and to a lesser extent apps) and it won't need to be updated particularly frequently either.

Re: Scala.js - Write in Scala for the browser

#23
I enjoy both javascript and scala.

For work and anything I would want to put on a web site it is more practical to write javascript and when I've had time for my own projects I've enjoyed scala.

For me this is a great direction. The idea that I'd suddenly replace my javascript is silly. But being able to pull in things I'm familiar with from both into the same prototype (and at the same layer) of something and debug it all in the debugger I'm most familiar with (and with correct code line references!) is awesome.

Similarly, for someone who is learning scala and doesn't have/want java+IDE experience, this could lead to learning scala as a language with much less overhead and/or while learning a more useful combination of debugger and editor.

I think the overly negative comments come from those who view javascript as the "problem" that every new way to integrate languages with it must have been designed to tackle. Since every language has trade-offs, there is always ample criticism available from that vantage point...

Re: Scala.js - Write in Scala for the browser

#26
post #13

16MB minified. Ok; for what? "How to scale to Rich Internet Applications?" Good question. They didn't answer it. Is the Scala code going to be much more compact? And what problems scaling JS to rich applications were they thinking of, exactly? They don't say.

Things are very very alpha at the moment. Yes, it's huge now but is going to change in the future. Don't get discouraged by this as it's nowhere near final production version.

Re: Scala.js - Write in Scala for the browser

#28
I think that this is a great project, and would be exactly what I need for ProofPeer (http://www.proofpeer.net) because I have lot's of code that needs to run both on the server and in the browser. I am using Clojure/Clojurescript currently and am pretty happy with it. But I am missing the possibility of defining abstract datatypes in Clojure, so my first choice would have been Scala if Scala.js would already be mature and reasonably production ready.

Re: Scala.js - Write in Scala for the browser

#29

While in principal, I love this... Because JS is not my favorite language... I just don't see the real world benefit. It's going to: 1.) increase difficulty debugging (compiled js -> scala) 2.) decrease productivity, see #1 Why not just write javascript? Though that's my argument against any of these compile to js kits (coffee script being the big one). So maybe I'm just trolling (sorry). Again, super cool. The autho…

Hi,

Quick comment from the author: #1 has already been addressed by emitting Source Maps. With a supporting browser, you can debug your Scala.js application easily. You get positions in the original source code, breakpoints in the original source code, stack traces in the original source code, etc.

Re: Scala.js - Write in Scala for the browser

#30
post #13

16MB minified. Ok; for what? "How to scale to Rich Internet Applications?" Good question. They didn't answer it. Is the Scala code going to be much more compact? And what problems scaling JS to rich applications were they thinking of, exactly? They don't say.

Hi,

The slides shown there are, well, slides. They are meant to support a talk, and that talk addressed your comments, at least partly. It is also worth noting that it was Scala Days, and as such I took it for (almost) granted that the audience is converted to Scala.

The problem is that JavaScript, with its scripting nature, has never been designed to support programming in the large. The lack of type safety is often mentioned as one of the major difficulties of JavaScript. That is why there are other languages targeting JavaScript.

We scale to Rich Internet Applications by using the language Scala, which is a scalable language. I won't try and make a whole point here. Some people have moved from Java to Scala for that very reason.

And, yes, the 16 MB are for the standard library. But minifying was only the first step towards reducing that size. I have at least 4 ideas, which I believe will each divide that size by ~2. That should bring it down under 1 MB.

Post reply on HN