So, I understand how the scalac compiler is different from javac - looking at the bytecodes produced, they looked nothing like what javac would produce - e.g. a class without a constructor.
But is the runtime any different than starting java with scala jars in the classpath? I am very certain but can someone confirm that the scala command is just a thin wrapper around java - after all they simply lauch a JRE / JDK.
The scala
command is basically a script that sets up the classpath and then runs your code in the Java Runtime environment.
The relevant line in the scala
script appears at the end:
exec "${JAVACMD:=java}" $JAVA_OPTS -cp "$TOOL_CLASSPATH" -Dscala.home="$SCALA_HOME" -Denv.emacs="$EMACS" scala.tools.nsc.MainGenericRunner "$@"
Basically, this starts java
running MainGenericRunner
. MainGenericRunner
then checks whether you have told scala
to run one of your Scala classes. If so, it starts running that. Otherwise, it stars up the interactive interpreter.
Scala (on linux, anyway) is a script. The contents can be seen by typing more
`which scala
`
You are mostly right, it basically sets up an environment and then runs java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With