| 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) <pre>
div(
Seq( div( "div 1" ) ),
div( "div 2" ),
b(
"bold stuff",
i( "italic inside bold" )
)
)
</pre> 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) |
I'm curious if you did any measurements and what you prefer instead.
The managed heap is very efficient. I have a web server (built in Scala) configured on my own VPS to run with a 10-100 MB heap. To this you add the JVM's memory used for managing OS threads, opened sockets, JNI, GC overhead and I end up with a process using 190 MB (RES), which is reasonable for a server-side process, because you can actually do a lot in it, Java processes being able to be fat.
In my experience a well grown Java process will be much more efficient and predictable in terms of memory used than Node.js, PHP, Ruby, Python, at the very least.
The only problem I've experienced is the startup time, plus depending on use case I might prefer native binaries. GraalVM looks promising.
Scala.js is useful on the sever for example if you need to work with "serverless" tech, e.g. AWS Lambda, for which startup time is important.