8

I'm going through the tutorial and it looks like Scala.js only runs under sbt.

Are there bits of Scala.js (or the Scala environment generally) that are not written in Scala? Or cannot all the necessary bits go through Scala.js for some other reason? What am I missing?

Michael Lorton
  • 43,060
  • 26
  • 103
  • 144

1 Answers1

10

Mostly, this is because the Scala compiler uses too many parts of the JDK that have not been ported to Scala.js (yet). Some of these parts, most notably related to reading files (in the classpath, and source files), which cannot be implemented in JavaScript as such (though could be implemented for one particular platform, such as Node.js).

There is also the dependency on ASM, a Java bytecode manipulation library written in Java. Even though Scala.js compiles to JavaScript, the Java bytecode is still used for separate compilation (symbol lookup in previously compiled parts, such as libraries).

So, even though the Scala.js specific parts are written in a platform-independent way (e.g., we test that the Scala.js optimizer can optimize itself), there are a lot of parts in scalac that do not work out-of-the-box in Scala.js.

sjrd
  • 21,805
  • 2
  • 61
  • 91
  • I'm not at all worried about file-manipulation -- I just want to be able to type something into the browser and have it compiled and run stand-alone. There is a bytecode-to-js library out there somewhere. I wonder if you use that on the ASM... – Michael Lorton Apr 04 '15 at 18:50