Live data from Hacker News

Scala.js 1.0.0-RC1

scala-js.org

1–10 of 59 posts

Re: Scala.js 1.0.0-RC1

#2
Anyone know what's the minimum size of the compiled JS now? Is there any way Scala.js can produce code as compact as BuckleScript/ReasonML in the future?

I like Scala's syntax but the last time I tried Scala.js, the output was several hundred kb for something slightly more than a Hello World -- it used some List and Seq functions. I'd bet the comparable ReasonML output would likely be in tens of kb (including List and Array functions from Belt).

Re: Scala.js 1.0.0-RC1

#4
As someone who has dropped Scala on the backend (not doing FUD, just not happy with the JVM memory reqs)- what keeps me still using scala is Scala.js.

While some argue that there is more readable code with Bloomberg's OCaml.js, I like Scala.js because of Scala itself, which is

1) Very well designed 2) Lots of "functional" constructs in accompanying libraries 3) Good typechecking 4) Fun language to use.

and because Scala.js interop with JS is very seamless.

Do check out ScalablyTyped repo on Github, a Scala.js analogue of DefinitelyTyped.

Being typed- one of the best things I like about Scala is that I can do something like this (provided by a couple of frameworks- Laminar, Scalatags et al)

div( 
   Seq( div( "div 1" ) ),
   div( "div 2" ),
   b( 
      "bold stuff",
      i( "italic inside bold" )
   )
) 

No more mismatching tags, wrongly spelled tags, unclosed tags. Typechecked HTML in some sense.

This would also be a good place to mention some alternatives where a mainstream language can also compile to JS so hopefully people can comment with their experience:

1) F#- Fable 2) OCaml- Bloomberg's BuckleScript 3) Go- Gopher 4) Haskell- GHCJS

Other non-mainstream but compile-to-JS languages

1) PureScript 2) ELM 3) Clojure script (child comment)

... and of course... TypeScript! :)

It should be noted that while Scala.js isn't as popular as some of it's alternatives in "popular" programmer culture, the author is very focussed on correctness and I don't know of anybody who has ever used Scala.js for a project but dropped it. (Happy to be corrected)

Re: Scala.js 1.0.0-RC1

#5

Can this call js libraries and the DOM trivially like typescript? Or does it leverage ffi?

It's exactly like TypeScript. You write type definitions or you find them online, like in TypeScript, then you can call any JavaScript API using the relevant types.

Full relevant docs at https://www.scala-js.org/doc/interoperability/

Re: Scala.js 1.0.0-RC1

#6

As someone who has dropped Scala on the backend (not doing FUD, just not happy with the JVM memory reqs)- what keeps me still using scala is Scala.js. While some argue that there is more readable code with Bloomberg's OCaml.js, I like Scala.js because of Scala itself, which is 1) Very well designed 2) Lots of "functional" constructs in accompanying libraries 3) Good typechecking 4) Fun language to use. and because Sc…

ClojureScript too, if you don't mind dynamic typing.

Re: Scala.js 1.0.0-RC1

#7

Anyone know what's the minimum size of the compiled JS now? Is there any way Scala.js can produce code as compact as BuckleScript/ReasonML in the future? I like Scala's syntax but the last time I tried Scala.js, the output was several hundred kb for something slightly more than a Hello World -- it used some List and Seq functions. I'd bet the comparable ReasonML output would likely be in tens of kb (including List an…

As I noted in another comment, the output is close to unreadable. But you have source maps... (I don't know if Bucklescript has/needs them)

Re: Scala.js 1.0.0-RC1

#9

Anyone know what's the minimum size of the compiled JS now? Is there any way Scala.js can produce code as compact as BuckleScript/ReasonML in the future? I like Scala's syntax but the last time I tried Scala.js, the output was several hundred kb for something slightly more than a Hello World -- it used some List and Seq functions. I'd bet the comparable ReasonML output would likely be in tens of kb (including List an…

The bare minimum for a hello world is 6 KB (before gzip). But of course as soon as you start using Scala collections, it's getting bigger. The minimum for a realistic application is 90 KB (before gzip).

That's less than your typical JavaScript framework, so for any realistic application it shouldn't be a concern.

Re: Scala.js 1.0.0-RC1

#10

Anyone know what's the minimum size of the compiled JS now? Is there any way Scala.js can produce code as compact as BuckleScript/ReasonML in the future? I like Scala's syntax but the last time I tried Scala.js, the output was several hundred kb for something slightly more than a Hello World -- it used some List and Seq functions. I'd bet the comparable ReasonML output would likely be in tens of kb (including List an…

Why these rules are violated?
Post reply on HN