
Scala on LLVM - ddispaltro
http://greedy.github.io/scala-llvm/
======
densh
A small clarification: this an older project that is not directly related to
my upcoming ScalaDays talk [1]. More updates to come in next few months, stay
tuned.

[1] [http://event.scaladays.org/scaladays-
nyc-2016#!#schedulePopu...](http://event.scaladays.org/scaladays-
nyc-2016#!#schedulePopupExtras-7571)

~~~
walkingolof
This sounds very interesting, allot of very interesting develoment is
happening in Scala/JVM land, Dotty, Akka, Lagom etc

For those of you that havnt heard about Dotty, the next generation Scala
compiler, I can recommend this link:

[http://www.scala-lang.org/blog/2015/10/23/dotty-compiler-
boo...](http://www.scala-lang.org/blog/2015/10/23/dotty-compiler-
bootstraps.html)

------
oelang
This project has been discontinued. But fear not, a new scala-native is on the
way, Denys Shabalin a phd student at EPFL is working on completely new
implementation of scala-native. His previous work, scala offheap, a way to use
off-heap memory on the JVM with type- and memory-safety is very impressive.

~~~
thinkpad20
Would native-compiled scala allow for some of the features that have been
prevented by the need for Java semantic compatibility, like guaranteed tail
call optimization?

~~~
duaneb
> like guaranteed tail call optimization?

Isn't this what the @tailrec annotation is for? If it compiles it's tail
recursive. This is separate than actually JIT'ing the call bytecode into a
loop, I realize, but for a pragmatic engineer there's already a solution.

~~~
densh
@tailrec works only for simple cases of tail recursion. For example it doesn't
support mutual tail recursion at the moment.

------
0xFFC
This may sound ridiculous, but I am literally sick of Java/JVM land. I would
beg for native Scala backend (and it would be my first choice for doing pretty
much every thing).I don't know people does share this opinion or not ,but I
literally hate JVM.Slow Start up.Tremendously slow/unresponsive java app(I am
talking about big apps, like android studio). Ridiculously bad font handling
in Swing(there is no way to disable hinting).

Syntactically and semantically Scala is one of the best language's I have ever
worked with (although I spend little time with it).It's middle approach to OOP
and FP is best approach for enterprise projects.It does not try to shove FP in
your throat, but provide best platform to do FP when it is much more efficient
than simple OOP. However when it comes to JVM (especially in Linux desktop).
My answer is big fat NO.

Of course, I am talking about desktop experience.JVM in server side is great
and robust, I don't have anything against it, other than praise.

~~~
niccaluim
Not ridiculous; I'm with you.* I think that Scala is a solid, relatively
modern language and that the Java ecosystem is bonkers. Something like Scala-
the-language + Go-like tooling and deployment would make my day. (Maybe what
I'm describing is Rust, which I admit I haven't taken more than a cursory look
at even though I think it's interesting.)

*Assuming my agreement lowers the probability of being ridiculous, which is an open question… ;)

~~~
the_af
Scala is a modern language unfortunately set back by its need to compromise
and be compatible with Java. If we go native and remove the need for Java/JVM
compatibility, what is there left about Scala? There are many other languages
better at FP, so I guess what remains is the FP+OOP hybrid thing? Which I'm
not sure I like anyway, since it makes the language less tidy than I'd like.

Disclaimer: I work with Scala in my day job, and I like it -- it sure is nicer
than Java -- but I don't know if I would use it in situations where the JVM
wasn't mandated or needed.

------
CheKhovHemingw3
The other announcement[1] from EPFL last week was the establishment of Scala
Center, which is already staffed:
[http://search.epfl.ch/ubrowse.action?acro=SCALA-
GE](http://search.epfl.ch/ubrowse.action?acro=SCALA-GE)

The Center's mission: "Organize open source projects around Scala".

About scala-native, no details are given on whether it targets scalac or Dotty
(which another talk [2] describes as a couple years away from production-
ready). The situation could change if, say, Akka or Play announced a Roadmap
for Dotty.

[1] Martin Odersky: "Scala in 2016".
[http://files.meetup.com/18712511/Scala2016.pdf](http://files.meetup.com/18712511/Scala2016.pdf)

[2] ScalaSphere: Guillaume Martres "Hacking on Dotty: a live demo".
[https://www.youtube.com/watch?v=0OOYGeZLHs4](https://www.youtube.com/watch?v=0OOYGeZLHs4)

~~~
gmartres
If you're interested in Dotty, other talks with more information are listed at
[https://github.com/lampepfl/dotty/wiki/Getting-
Started#talks...](https://github.com/lampepfl/dotty/wiki/Getting-
Started#talks-on-dotty)

------
ninjakeyboard
Apart from startup times, would this really be faster than the JVM? I don't
know how the LLVM runtime stacks up - I'm guessing that there are a few
targets eg traits that might be more efficient to implement in native code as
Scala would be trying to work around what exists in the JVM and Java Bytecode
but I have a feeling that it would be very specific use cases like embedded
systems that would be considering LLVM as a target where as the JVM would
still be preferred in most circumstances? I'm asking from a fairly naive place
- I'm genuinely interested and curious to hear some use cases where LLVM would
be almost strictly better.

~~~
pjmlp
Actually you could already do it today.

RoboVM uses LLVM and quite a few People were using Scala with it.

As "the JVM" there are plenty to choose from.

Embedded vendors do have implementations that run with a few hundred KBs or
1-2 MB depending on the use case.

I would say it is just yet another implementation.

Personally I find healthy that languages have multiple implementations,
specially since it clears the confusion between language and implementation.

------
geodel
The Github and mailing list shows no activity for >3 years. Either the idea
did not work out or all they had was just idea and nobody came forward to
pickup and develop working software.

In any case Scala seems to have large following among those who love JVM and
Java ecosystem libraries.

------
natrius
This is a cool direction. Other than previous Scala knowledge, what are some
advantages of using some sort of scala-native over Rust? I've used Scala and I
always imagined that I'd use Rust if I wanted something similar without the
ecosystem of JVM libraries.

~~~
whateveracct
> Other than previous Scala knowledge, what are some advantages of using some
> sort of scala-native over Rust?

For one, it isn't as low-level as Rust. That can be good or bad for your use-
case.

Also, Scala has a bit more expressive type system than Rust so you get that.
Scala has scalaz/cats and shapeless which aren't really possible in Rust.

------
nkvoll
While interesting in and of it self, it seems to have seen no changes since
mid-2013, looking at its GitHub repository
([https://github.com/greedy/scala](https://github.com/greedy/scala))

    
    
        > This branch is 211 commits ahead, 10086 commits behind scala:2.12.x.
    

Is there any new context / development that makes this extra interesting right
now?

------
__jal
I've clearly been paying too much attention to politics. My first scan of
headlines here left me asking, in which case before the Supreme Court was LLVM
an issue?

Although I must admit I would love to read the late Scalia's opinion of LLVM.

------
ape4
How about compile speed. I found Scala compiled much slower than Java.

~~~
hibikir
Java's type system is barely doing anything for you in comparison with what
Scala does. Higher kinded types, implicit parameters, implicit conversions and
type inference are not free. The type level tools that libraries like
Shapeless use let you do type checks that are unimaginable in the java
compiler.

Guess what: The more work a compiler is doing, the slower it's going to run.
Comparing Java and Scala compilation is like comparing the gas mileage of an
18 wheeler truck and a small city car. Guess what? The 18 wheeler won't do 30
mpg.

~~~
dastbe
The scala type system is incredibly strong (and undecidable) but the
implementation itself is not conducive to compilation speed. Two of the
primary motivations for Dotty are 1) reducing the complexity of the language
and 2) starting clean slate on a more reasonable compiler.

Im of the opinion that most groups don't want the complexity that scala
brings, and we're going to see that in the community growing around spark. The
databricks style guide clearly avoids a lot the complexity of the language,
and the people who are coming to scala for the tech and not the language are
going to follow their lead.

