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.
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.
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.
Thanks for your reply. I would be interested to read the whole argument. I don't know what "scripting nature" is. JavaScript has first-class functions and is nearly syntactically identical to Scala. It doesn't have a type system, but I'm not convinced that's a problem for scalability. Java has a type system, and you say people are moving away from it because it's not scalable, so...
Definitely a strange mindset. How does JS not scale to rich applications? I'd rather use modular JS and a MV* framework than try to use GWT equivalents or things that compile to Java from other languages where the idioms don't translate.
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.
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.
Yeah, and I'm not sure scala will be that useful without the standard libs, much like C# or Java.
Seeing the presentation, I'm thinking more of using it with something like node-webkit[1] though. Didn't LightTable use clojure-script or something? But then, why don't just use one of JVM's GUI framework?
I'm doing something for fun with Clojurescript and node-webkit and for me it's mostly that I want the fast start up time, but also to get to just work with html instead of having to learn a gui framework.
Also I just want to mention that Clojurescript compiles to javascript that's compatible with Google's Closure compiler, which can do dead code elimination and will remove the parts of the standard library that you don't use.
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.
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 author is waaay smarter than I for implementing this, but... The real world.
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.
It will be long before someone implement this in the real world (website). It needs 16MBs download for the standard libs. Even twitter only downloads around ~2MBs before showing page.
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...
Interesting! Maybe it can learn from Scala on Android:
For Android development, install Scala runtime into rooted phone, so you don't need to "minify" your code (faster roundtrip). For Scala.js, maybe use Chrome Extension?
For production, ProGuard (removes unused code in Scala) and Closure Compiler (optimizes JS).
I have not used Scala before. What's the motivation for this? I can think of two reasons - a) to make native Scala programmers feel home with Javascript and b) Scala is a superior language than Javascript, will therefor make many things easier.
I've used javascript for many many years and, as of 6mo ago, started using Scala (I do a lot of distributed programming on hadoop, storm, and recently spark). Scala is now one of my favorite languages because of Spark (http://spark-project.org/). Scala very nicely blends the functional and imperative styles and it always favors programming without side-effects. Anything you can do in java you can do in fewer lines and you will see fewer bugs.
That said- it's not a superior language, just a different paradigm. With Scala you get very strong typing, functional constructs (so incredibly powerful), matching, options, very clean closure syntax, etc.. You'll eventually fall in-love with _, too.
I haven't used scala.js yet, but here are some downsides to Scala proper:
* slow the compile
* tooling isn't great (this true of anything jvm to some degree though)
> tooling isn't great (this true of anything jvm to some degree though)
Well, you have plenty of very decent tools to inspect a running JVM state, and that's priceless. Eclipse is alright if you manage to set it up once with the tools you need and don't fiddle with the setup afterwards. Although slow, it packs a lot more features out of the box than Visual Studio. The debugger is pretty good too (including remote debugging).
If you compare it to state-of-the-art tooling for more fringe languages like Python or Haskell, it's lightyears better, really.
If you ask me, this is all about (b) if you consider only JavaScript vs Scala.js.
If you compare Scala.js to similar languages (CoffeeScript, TypeScript, ClojureScript to name a few), it definitely helps to have the same language both on server and client, especially if logic must be replicated on both sides. So in that sense, there is some (a) too.
But that is only my opinion. Any developer or team can make up her own mind on the matter.
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.
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.