
Scala.js has a new website - lihaoyi
http://www.scala-js.org/
======
raquo
Speaking of bringing nice languages to the browser. Kotlin is a simpler
language than Scala and also compiles to JS. Unlike Scala.JS which seems to be
a completely third party project, Kotlin's compilation to JS is considered one
of the primary features of the language.

Kotlin is barely at 1.0 at the moment though.

~~~
stewbrew
AFAIK javascript support is put on hold until 1.0 is reached. Kotlin/JS
doesn't provide much help to make Kotlin/Java code run without modifications.
So, it isn't there yet. ScalaJS on the other hand is fully functional.

~~~
raquo
Correct me if I'm wrong, but I think the relationship of Java and JS in
ScalaJS and Kotlin is about the same: If your Scala/Kotlin code depends on any
Java classes, you won't be able to compile it to JS. You can only compile pure
Scala/Kotlin code to JS (and that comes with a few caveats in both cases).

It's true that Kotlin's JS support is pretty raw today. There are virtually no
docs for it for example. They do have a basic feature set working though. I
think in a few months it should be in great shape.

~~~
stewbrew
Scala has a bigger runtime, which is supported by ScalaJS. ScalaJS also has
implementations for some Java classes. There are also some Scala libraries
with explicit support for ScalaJS around.

Kotlin relies more heavily on the underlying runtime. Unless they re-implement
a large part of the Java standard library in JS, they'll never achieve that
level of compatibility.

------
prohor
For those from Java world wanting to write client-side, there is obviously
also GWT[1] and another interesting option is TeaVM[2]. Interesting part of
TeaVM is that it translates bytecode, so I guess it could do Scala as well.
But I've never used it, so cannot recommend really.

1\. [http://www.gwtproject.org/](http://www.gwtproject.org/)

2\.
[https://github.com/konsoletyper/teavm](https://github.com/konsoletyper/teavm)

~~~
sjrd
GWT doesn't do Scala. That puts it out of the equation as far as most Scala.js
developers are concerned. Also, it's interoperability story is seriously
lacking behind Scala.js.

TeaVM is a fun and impressive project. However, although they _can_ compile
Scala-emitted bytecode (since a few weeks ago [1]), that's not their main
focus. They are unlikely to ever optimize Scala code as well as Scala.js,
because Scala.js focuses on optimizing idiomatic Scala. They do have an
undeniable advantage over Scala.js, though, which is that they can also
compile Java libraries used by a Scala program.

[1] [https://groups.google.com/d/msg/scala-
js/3jbX9ajIbHM/MbLWIqp...](https://groups.google.com/d/msg/scala-
js/3jbX9ajIbHM/MbLWIqpkBgAJ)

------
jiaweihli
While I love scala, I have 2 concerns that have stopped me from using
scala.js: 1) can I use typescript definitions to avoid writing everything
myself? 2) how much bloat does this add to my app? (from overhead of standard
libs and core)

~~~
ramnivas2
There is a way to transform a typescript definition to Scala.js facade
([https://github.com/sjrd/scala-js-ts-importer](https://github.com/sjrd/scala-
js-ts-importer)).

As for the bloat, it isn't much. Compiled Javascript for our full-fledged app
is about 180KB (gzipped) + external libraries such as React.

~~~
sulam
Don't take this the wrong way, but I've been in the industry for a long
time... and it amazes me that 180KB is considered not much...

If I told you I had a way to remove 180KB from every page load, you'd be all
over it. :)

~~~
spicyj
180KB is comparable to a medium-size image.

~~~
Ciantic
Yes you are right.

Scripting time however can be massive, take for instance this hs.fi (Finnish
daily), they have 354kB of JavaScript, but scripting time with Skylake 6700K
is 1.13 seconds of the page load. With Q6600 it was 3.5 seconds.

With latest chrome it's easy to measure scripting time as pie chart. Go to
"Timeline" tab of developer tools and hit F5. (just few releases back one had
to do it manually by starting timeline and stopping it.)

~~~
girvo
So few people seem to run a profiler on their Javascript nowadays. It's a
shame, really, as the tools are very powerful!

------
haxandra
Also haxe can compile in javascript and have a type System much similar to
Scala. And also macros, conditional compilation and inline functions and
constructors. And can compile also in java, c#, c++, lua, php, python, flash

------
feedme
Should I start learning scala or typescript? I'm developing nodejs + angularjs
apps in my spare time and want to improve the code (native JavaScript 5
currently). Or should I start with babel and ES6?

~~~
lmm
If you're in for the long haul (say 2+ years) I'd go with scala - it's
ultimately a better language with a much more complete and powerful type
system than typescript. It's also good to learn at least one functional
language to pick up the functional techniques (which are ultimately valuable
in any language), so if you've never learnt a functional language before I'd
recommend it.

But typescript will get you most of the "quick wins" of type safety and is
very easy to migrate to, so it's probably a better choice in the short and
medium term (at least in terms of immediate productivity).

~~~
feedme
Thanks for your response :)

I'm more into a long haul so scala sounds pretty cool.

But what just rushed into my mind is that angular 2 will be in typescript so
learning scala would only be relevant for server side code. And using two
languages when one can handle both doesnt sound quite convicing :/ Would you
still recommend scala when I want to work with angular 2 in the near future?

~~~
lmm
Scala can be very good at interop - I still use Wicket (Java) for my Scala web
UIs. And I'm confident that the Scala.js folk will have a good answer for
doing UI, whether that ultimately means Angular 2, another existing framework,
or a native Scala.js UI framework.

All that said, if you're thoroughly committed to Angular 2 (a mentality I
don't really understand - I love Wicket but if an equally OO framework existed
in native Scala then I'd use that instead) then using anything other than
Typescript is probably an unnecessary risk factor.

------
jinst8gmi
This looks pretty neat. I personally hate working with JavaScript directly.

