
Scala Native with Denys Shabalin – Software Engineering Daily Podcast - lihaoyi
https://softwareengineeringdaily.com/2017/10/16/scala-native-with-denys-shabalin/
======
binarynate
I wasn't familiar with Scala prior to listening to this episode, so I enjoyed
that it provided both a background on the traditional, JVM-based Scala, as
well as the new Scala Native project, which I'm more inclined to use.

~~~
walkingolof
There is a third backend, Scala.js [https://www.scala-
js.org](https://www.scala-js.org)

Based on the same principle as Scala Native, this one outputs javascript.

I've written a couple of projects where both the backend and front end is
written in Scala, using one project, with different sub-projects for
frontend/backend.

Scala.js will probably not convert Javascript developers en masse, but its
very handy for Scala developers that prefer to write Scala to Javascript.

------
thinkingkong
Im actually quite interested in why teams choose to use Scala if youre not
fitting it into an existing JVM shop.

~~~
whateveracct
The only competing production-capable languages are Haskell, OCaml, and maybe
F#

~~~
lmm
I'd include Rust on your list (if we're defining production-capable at a level
where Scala Native qualifies), and maybe even Idris.

I do think Scala still has advantages: higher-kinded type support which OCaml
and F# don't have, strict evaluation unlike Haskell, and better IDE/tool
support than any except F#.

~~~
phazer
I wouldn't say Idris is "production ready" in terms of libraries and tooling.
Unless dependent types is a must, I would choose Purescript instead if I
wanted something Haskell'ish but strict and with nice JavaScript support.

~~~
lmm
Is PureScript really any more production-ready than Idris? That wasn't the
impression I got.

~~~
phazer
It seems a bit more mature, at least in terms of package management and
available libraries
([https://pursuit.purescript.org](https://pursuit.purescript.org)). I'm not
very impressed with the editor/IDE support though.

------
nerdponx
Why would you compile Scala natively itself instead of compiling JVM bytecode?

~~~
densh
JVM startup is really painful for short to medium time running apps, this is
the niche we’re trying to address.

~~~
nerdponx
I meant, "compile bytecode to machine code." The fact that nobody does it is a
sign that it's not a good idea. I guess I was just wondering why.

~~~
pjmlp
Lots of people do it.

Besides ExcelsiorJET named in a sibling answer, the JDKs from Aicas, IBM, PTC,
STMicroelectronics, Google with their ART implementation and a few smaller
vendors for the embedded market.

Also Oracle just added initial AOT on Java 9, with plans to extend it to other
platforms, and eventually (long term plan) rewrite everything in Java as part
of Project Metropolis.

Oracle also had AOT compilers before Sun's acquisition, like JServe and
JRockit.

Why does it seem no one does it?

Sun was religiously against AOT, leaving it to third party commercial vendors.

And since the rise of FOSS most developers think it is outrageous to pay for
compilers, only Fortune 500s buy such compilers.

~~~
nerdponx
Are they all proprietary/closed-source? When I was first learning about
Clojure I really wanted a native JVM compiler, but as a hobbyist I was not
about to go all-in on an enterprise compiler. The only FOSS solution I found
was GCJ.

That, and "the JVM startup is slow!" seems to be a popular argument against
Clojure and Scala here on the Intertubes.

------
stewbrew
I remember that shortly after??? Scala native was first announced, Kotlin
native made the news. How do these two compare today? Which one is better
suited to create native executables now?

~~~
bad_user
The alternative Kotlin compilers are currently at the "proof of concept"
stage, but aren't usable, or supported much by the community.

Scala's JavaScript compiler ([http://www.scala-js.org/](http://www.scala-
js.org/)) on the other hand is production ready and supported by the whole
ecosystem, with plenty of libraries being cross-compiled to both the JVM and
JS.

Scala Native piggybacks on top of the work made for Scala.js — it's harder,
due to not being able to piggyback on another platform this time, so they have
to deal with things like concurrency or garbage collection, but it's
progressing nicely.

Scala Native isn't production quality yet, but it's at that stage where it's
fun to play with it and the Gitter channel has some friendly folks you can
interact with: [https://gitter.im/scala-native/scala-
native](https://gitter.im/scala-native/scala-native)

------
groceryheist
Any reason to use Scala native when Rust exists?

~~~
pjmlp
The language is more powerful, Rust still doesn't have HKT support.

The maturity of the eco-system.

Not having to deal with the borrow checker.

In any case, I would say in such cases OCaml and Haskell are also good
candidates.

~~~
bad_user
Rust is in a different league altogether.

Scala, Haskell, OCaml are garbage collected languages. This makes them easier
to use, but some problems are out of reach.

Embedded development, kernels, native apps requiring performance without
frames dropped, real-time systems actually, including consumer stuff like
decoding video, these have been the domain of C/C++.

Of course, there are projects out there using these languages, pushing the
boundaries, like MirageOS ([https://mirage.io/](https://mirage.io/)) which is
built with OCaml. But those are like the exceptions confirming the rule.

~~~
pjmlp
Java is doing quite well in such domains, including real time control of
battleship weapon systems and missile radar controls.

The ongoing NLL work proves ergonomics are still not there, and it doesn't
cover all scenarios like internal references as done typically for callbacks
in GUI widgets.

It will surely improve, and the best thing for polyglot developers is that we
can easily pick the best tool for the job.

------
xvilka
Still requires Java to build.

~~~
ekrich
Yes, that is true but eventually this could be lifted. There is ongoing work
getting the compiler compiled with Scala Native as well as other work related
to pulling the code related to build out of the sbt build that requires the
JVM. This could make a native build chain possible.

~~~
xvilka
Those are great news, thank you!

------
bluesnowmonkey
Why is the transcript a PDF? It's unreadable on mobile. Do they think people
are going to print it out, like Knuth reading his email?

~~~
chii
there are various tools online to view PDFs without even downloading them. For
example, google docs has one:
[https://docs.google.com/viewerng/viewer?url=https://software...](https://docs.google.com/viewerng/viewer?url=https://softwareengineeringdaily.com/wp-
content/uploads/2017/10/SED439-Scala-Native.pdf)

