
Announcing Scala.js v0.1 - llambda
http://www.scala-lang.org/news/2013/11/29/announcing-scala-js-v0.1.html
======
auggierose
This is a game changer. I've used it over the last few 3 or 4 months, and it
is really stable and usable. I am betting an entire (although academic)
project on it: [http://proofpeer.net](http://proofpeer.net) (note that Clojure
is mentioned there as a language of choice, but I switched to Scala since then
as Scala provides a similar level of conciseness with all the goodies of a
powerful static type system with support for both Java and Javascript).

~~~
saosebastiao
I like static typing, but do you ever get the feeling that we've collectively
gone off the deep end with the whole backwards compatibility hacks that
compile-to-javascript languages represent? Think about it...we have
implementations of static languages on top of a dynamic runtime that
translates it back to a static runtime. We have non-GC languages that have
developed ways to compile to a GC language and avoid GC. It is absolutely
amazing, and completely silly at the same time.

~~~
SkyMarshal
Indeed. It's almost as if the ECMA should just freeze all JavaScript
development, and replace it with a standard, low level, high performance
compiler target that all browsers can implement instead, and then just let the
industry/community write competing compiled languages for it. That's
essentially where browsers are heading anyway with asm.js and NACL.

For everyone who still loves JS and prefers it over Coffee/Type/Clojure/etc-
scripts, just make a JS compiler and keep all its quirks and wtfs.

------
dysoco
I remember how years ago I complained about how Javascript was the only
language aviable for the web.

Nowadays you can even run sliced bread on Javascript... though, wouldn't it be
better to focus on developing languages on top of asm.js or PNacl so we
wouldn't rely on JS?

~~~
tkellogg
I completely agree. While asm.js has its problems, its moving in the right
direction. Honestly, it seems like this wouldn't be too hard to add a backend
target for asm.js, if its implemented well.

~~~
swannodette
Note that asm.js (and probably PNaCL as well) currently offers very little for
languages like Scala that need good GC. Until that's addressed simply
targeting JavaScript is going to be best approach for these languages.

~~~
jkrems
I don't think running a garbage collected languages on asm.js will ever make
any sense (since it would mean implementing and shipping your own GC as part
of the application source). So, yeah, you're right. Scala (as-is) is not a
good language to target any of the "native" targets like asm.js.

------
lihaoyi
Fun demos using Scala.js:

[http://lihaoyi.github.io/scala-js-games/](http://lihaoyi.github.io/scala-js-
games/) [http://lihaoyi.github.io/scala-js-
game-2/](http://lihaoyi.github.io/scala-js-game-2/)

The second one has some performance issues, and bugs out initially when first
opened in FF (need to refresh before it works properly) but otherwise it's
pretty fun =)

------
jakozaur
For those who haven't heard about it. The initial presentation:
[http://www.parleys.com/play/51c380bfe4b0ed8770356866/](http://www.parleys.com/play/51c380bfe4b0ed8770356866/)

------
wodenokoto
As someone who doesn't really know anything about scala, why is this a cool
thing?

While such an early release is definitely aimed at scala enthusiast, I'd still
like a sales pitch for the rest of us.

~~~
acjohnson55
I'm sure this is going to read as dickish, but I personally would be much more
inclined to give a thoughtful response if your question showed some evidence
of you having attempted to explore this question before asking other people to
spoon feed you answers.

~~~
zschuessler
This is really one of those questions that _requires_ someone to spoon feed
you the answer.

He is asking a Scala expert to describe how a port to JavaScript allows
developers to take advantage of advanced Scala language features or tools. The
alternative is spending hours working with Scala and coming up with the answer
himself.

Being a discussion forum, I don't see why you have a problem giving away
knowledge freely over HN.

~~~
acjohnson55
I've got no problem at all answering people's questions, if you look at my
comment history. I just think this particular question was both vague and
lazily written. It's natural that a question requires more effort to answer
than to ask, but a thoughtfully asked question clues potential answerers into
what the asker already knows and has already attempted to do to educate
themselves. Like "I know Scala is X and Y, but why would these things be
useful on the browser side?" or if you don't know anything about Scala in the
first place, "I read Wikipedia about Scala but didn't understand Z, could
someone explain this?"

------
jroseattle
I'm finding a sort of corollary of JavaScript being a byte-code equivalent for
the web, what with everything being translated to compilation in js syntax.

Maybe the browsers need to move beyond JavaScript interpretation, and think
about things more like a VM to allow actual
scala/java/c#/ruby/python/erlang/lua/something-completely-new/etc. to be
executed in context.

Or, maybe a more forward-thinking approach would be to consider "docker in the
browser" \-- containers that run in execution. Probably a performance
nightmare, but I'm thinking of an interesting compilation of bits -- CMS done
well in Ruby, an e-commerce cart in Python, data charts in Erlang, and
enterprise-based workflows in Java -- all working together, client-side.

Disclaimer: it's a holiday and I'm enjoying a nice cabernet sauvignon. Thought
clarity and consistency may not necessarily be present at this point in time.

------
leokun
I wonder how complicated it is to parse JSON in Scala.js. It's pretty involved
in regular Scala and incredibly easy in JavaScript, so what's it like in
Scala.js?

~~~
jakozaur
Parsing JSON in Scala is very easy with lift-json:
[https://github.com/lift/lift/tree/master/framework/lift-
base...](https://github.com/lift/lift/tree/master/framework/lift-base/lift-
json/)

~~~
saryant
There's also Play-Json, Spray-Json, various wrappers for Jackson and a few
others I don't remember. We use Play-Json and its macros a lot at the company
I work for and I contributed a performance fix for it a while back. I wouldn't
consider Play's JSON inception to be "pretty involved" at all if you're using
case classes.

[http://www.playframework.com/documentation/2.2.x/ScalaJson](http://www.playframework.com/documentation/2.2.x/ScalaJson)

[https://github.com/spray/spray-json](https://github.com/spray/spray-json)

~~~
interstitial
Well, damn it, now I have to bookmark this thread.

------
ShardPhoenix
This is exactly what I've been hoping for - I'd like to write little games/etc
in Scala, but it's a lot easier to distribute JS.

------
krisajenkins
Anyone know how the compilation times compare with regular Scala?

~~~
acjohnson55
Scala's compile times (along with other aspects of its development experience)
are among my biggest annoyances with the language. It just seems like it
should be way better than it is for such an intellectually advanced language.

I've been investing a lot of time in learning Scala because I think that it's
at the head of the vanguard of a software engineering revolution, but with
some of its ergonomic issues, I can't help thinking it's eventually going to
lose out to something that's more elegant from a design standpoint and has
better tooling.

~~~
chris_overseas
Take a look at Kotlin
([http://kotlin.jetbrains.org](http://kotlin.jetbrains.org)), it was designed
to address the issues you mention.

~~~
humpty44
Kotlin seems like a lightly stripped down Scala.

~~~
pkolaczk
Lightly? I'd say one of the most important features were removed - implicits
and most of the typesystem magic. Kotlin feels just like Java with lambdas,
better null checking. slightly improved generics and some minor syntactic
refinements. Most of its "features" will be obsoleted by Java 8.

------
memracom
Too bad that there is not more effort on Scala.NET instead of this. Lots of
people are comfortable with writing Javascript in the browser so all of these
compilers emitting Javascript end up being little more than a technology demo.
But Scala on the .NET vm would really fill a gap.

~~~
romanovcode
Why would you need Scala on .NET when you have F# and C# that are completely
the same thing.

~~~
pkolaczk
Scala integrates OOP and FP in a truly elegant way, F# is mostly FP with some
OO bolted on it as an afterthought, and C# is much closer to Java than to
Scala. You may argue whether Scala is really more expressive than F# (IMHO it
is), but regardless of it, they are _not_ the same thing.

~~~
profquail
F# doesn't have "OO bolted on it as an afterthought". Sure, F# strongly favors
the FP approach to things, but the language's OO features are important --
critical, even. Without support for OO programming, F# wouldn't be able to
easily consume existing .NET (C#, VB.NET, etc.) libraries, nor would you be
able to use F# to implement components/libraries to be easy consumed by C#.
The ease of interop'ing with C# is one of F#'s best features, IMO, and an
important part of the wider adoption it's now seeing.

------
julianduque
It supports Node.js or is only for web applications?

~~~
romanovcode
It supports Javascript. Node.Js runs on Javascript.

Draw your conclusions.

~~~
sjrd
True, but its main target is definitely the browser. The stand-alone
interpreter of Node.js can run code written in Scala.js, and is actually used
for benchmarks (along with d8) [1]. However, Scala.js does not emit Node.js
modules, nor does it provide any built-in way to import other Node.js modules.

[1] [https://github.com/jonas/scalajs-
benchmarks](https://github.com/jonas/scalajs-benchmarks)

------
myth_drannon
So now it's Dart vs Scala. Great to have some good options.

~~~
haosdent
I think it's Dart vs ClojureScript vs Scala.

~~~
solomatov
You forgot about GWT.

~~~
camus2
You forgot typescript ,haxe,JSX, opal ,coffeescript and zillions of languages
that compile to JS.

~~~
danieldk
Or if you write web _applications_ (with emphasis on applications): Zk.

------
coldcode
Is there anything Javascript can't do?

~~~
nickbarnwell
Threads.

~~~
swannodette
Not completely true, you already have WebWorkers, and if you're targeting,
say, JavaScriptCore on iOS and OS X Mavericks then threads are an option via
running multiple JS Virtual Machines - JSValues may be passed between them.

------
macmac
They will be adding prefix notation next...

------
ghostdiver
Fun stuff, but again, doesn't come with any tools. Microsoft Typescript is
much better on that matter.

What javascript universe needs right now is not some more of syntactic sugar
clusterfuck followed by debugging nightmare, but real tools, static code
analysis. I don't want to waste my precious time dealing with closure
compiler+scala something combo. It's fun from programmers POV, but still it
won't make me pay my bills!

reality check, please

~~~
chc
Have you looked into the tools and amenability of Scala to static analysis and
found them lacking?

Also, it seems a bit odd to call Scala "syntactic sugar". It's a pretty unique
language in its own right.

