Enable compilation in the client's browser and natively on bare metal by abstracting over the compiler's execution context #17768
Replies: 5 comments
-
This is perhaps also relevant to Almond? @alexarchambault @sbrunk |
Beta Was this translation helpful? Give feedback.
-
It would be really cool to be able to compete with dynamic languages such as Python by providing the Scala compiler as a portable thing that could be executed like a function... |
Beta Was this translation helpful? Give feedback.
-
Excellent idea. I'd like to add a few example usage if we're able to run dotty on the web.
|
Beta Was this translation helpful? Give feedback.
-
Cool use cases @contrun ! I guess this all boils down to a trade-off between 1) how valuable this would be for the community and 2) how much effort it would take by core compiler contributors. So every input on the value of this as well as what it would take achieve it from a technical point of view is valuable. |
Beta Was this translation helpful? Give feedback.
-
Having a Scala Native Scala compiler would mean that a JVM would not be needed to compile Scala. In general people would still need a build tool and currently Mill and sbt are JVM based. There is an effort to cross compile the Scala Native tools project scala-native/scala-native#3233 which would allow the rest of the Scala Native tool chain to be native as well. Updated: Not sure how possible this is for general purpose but a super hacked and crippled version could compile at one time. https://twitter.com/scala_native/status/893192456002469888 |
Beta Was this translation helpful? Give feedback.
-
It would be a game-changer if the compiler could be executed on more platforms:
This would open up for many more use cases, for instance better web-based development environments.
One example use-case is using Scala for programming by kids in school who often only have a locked down machine with browser only; relying on fast and reliable enough network and sponsored server infrastructure such as Scastie or KojoJS is not always feasible (e.g. someone needs to sponsor the compute + certificates etc and there can be server congestion if many students compiles simultaneously, and some schools requires https-servers etc).
Another use case might be execution of the compiler on bare metal when the JVM is not available; @WojciechMazur @ekrich is this use case relevant to the Scala Native community?
This would also open up for a NodeJS-only server execution without the dependency on sbt and JVM etc.
If I understand input from @sjrd, there are some obstacles that need workarounds:
Achieving the goal of plug-able execution platforms would perhaps not necessarily mean a fork of the compiler if the actual execution platform could be abstracted over as a context? Perhaps the things that are specific to the JVM step-by-step can be moved to a
CompilerExecutionContext
and the mechanics that are very platform-specific then be implemented in different given contexts? This could be an interesting, incremental modularization of the code base, perhaps with other benefits as well...This issue is based on previous discussions here with @julienrf and @sjrd :
https://teachers.scala-lang.org/t/web-based-development-environments/18/4
Beta Was this translation helpful? Give feedback.
All reactions