5 ms·
I find it interesting to compare this compiled JS to the tiny recursive Ray Tracer previously posted here on HN [0]. This Scala->JS compilation is 214k characte
by adamlj 12y ago
I find it interesting to compare this compiled JS to the tiny recursive Ray Tracer previously posted here on HN [0]. This Scala->JS compilation is 214k characters while the tiny Ray Tracer is at <1k characters. It should be noted that the tiny Ray Tracer is heavily optimized and minified.
[0] http://www.gabrielgambetta.com/tiny_raytracer.html http://www.gabrielgambetta.com/tiny_raytracer.html
- virtualwhys 12y agoScalaJS is still in its infancy, I wouldn't expect miracles at this point, particularly in terms of generated JS file size. Note the _experimental_ disclaimer in ScalaJS' home page: http://www.scala-js.org http://www.scala-js.org Assume optimizations will come with time, for now it's pretty cool that one can work in a more or less completely type safe environment on both client and server with Scala. p.s. muddling along with Coffeescript + GruntJS for the time being, but look forward to working in pure Scala once the library stabilizes.
- sixbrx 12y agoYeah this is a great effort that will have a really big upside for developers like me using Play! framework. It means I can define my transfer types in Scala and share them between client and server in a typesafe way. Currently that takes lots of testing to keep the javascript side honest in what it's sending.
- bad_user 12y agoThe source-code linked is only 279 lines of Scala code, including blanks and comments and the code is very readable [1]. However, it is using Scala's standard library, which is somewhere at 16.5 MB - 18.5 MB, depending on version. That the minified code is 209 KB (50 KB gzipped), I find that awesome, as it means that the compression / tree shaking done is pretty aggressive, much better than what people can do by hand. Under the hood Scala.js does optimizations of its own, before passing the result to Google's Closure compiler in advanced mode. https://github.com/lihaoyi/workbench-example-app/blob/ray-tracer/src/main/scala/example/ScalaJSExample.scala https://github.com/lihaoyi/workbench-example-app/blob/ray-tr...