Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Scala compiles down to JVM bytecode. Java also compiles down to JVM bytecode. Scala does not compile down to Java.


sort by: page size:

dude this is so cool. So scala can compile to the jvm right?

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

It might be worth mentioning that Scala now compiles to 3 different targets:

- JVM

- JavaScript (Scala.js)

- native (Scala Native)

The tie to the Java ecosystem has significantly loosened over the last few years.


> Therefore it’s still JVM at the source

Wat. No.

Scala is a language. It has compilers for Java bytecode, JavaScript, and native.


No, but he's arguing that Scala compiles to Java bytecode

Now that I look at it, they essentially do, it's just that they implement it from a more Scala-centric point of view (e.g. implementing traits directly instead of being layered on top of a Java variant). It seems like it shouldn't be too hard to compile JVM bytecode to run on the same runtime.

I'm not sure what you meant here, considering Scala already does run on the JVM.

But this is Scala native we’re talking here. No JVM.

Does written in Scala mean, that you need the JVM to run it? That would make it a no-go for many projects.

I thought you didn't have to use the JVM with Scala. Not so?

Doesn't Scala run on the JVM ? Are they talking about JIT times or are there other Scala 'environment' that are not semi-interpreted ?

>> An attribute of Scala is that the Scala compiler generates fragile byte-code.

Can anybody tell me if this would be true to any JVM targeted language, or is it a specific issue of the Scala compiler?

I'm asking because I just recently decided to abort learning Scala in favor of Clojure.


> Scala

That means being chained to JVM. That is a big downside for me.


Scala isn’t another layer, it compiles to JVM bytecode. Also, what does Scala have to do with JetBrains?

Unfortunately it doesn't. Even though Scala and Java output the same kind of bytecode, these languages have different language specifications. We currently only support what's in the JLS.

> It's not even written in Java for the most part but mostly Scala.

Scala still runs on the JVM.


This is the compiler from Scala to Java bytecode. It does type checking, some optimizations (like inlining, removing some instances of boxing, or converting tail-recursive functions to loops), and converts all Scala-specific features to some Java constructs (e.g. traits become interfaces, classes etc.; lazy values become methods and accompanying values; lambdas get lifted to the class they are defined in).

The JIT works on Java bytecode. Java also has a similar compiler (javac) from Java -> bytecode.


This all sounds right to me - scala needs first class support for what it is doing in the JVM itself - which it doesn’t have. Trying to ASM scala is a pain.

Scala is a JVM language. If it’s Scala.js, as referenced in a sibling comment, it’s still Scala being cross compiled. Therefore it’s still JVM at the source
next

Legal | privacy