scalacenter / student-projects

The list of the available projects at the Scala Center for bachelor and master students.
8 stars 0 forks source link

Compiling Scala in a JavaScript environment #2

Closed adpi2 closed 1 year ago

adpi2 commented 2 years ago

Description

Scala.js is an extension of the Scala compiler that can compile Scala code into JavaScript code. The Scala.js project also contains a Scala.js implementation of the JDK, the Java standard library. But some pieces are missing in the Scala.js implementation either because they depend on the JavaScript runtime, for instance the representation of a file, or because they are inherently specific to Java, for instance the java.lang.ClassLoader.

For those reasons it is not yet possible to run the Scala compiler in a JavaScript environment. The goal of this project is to create a limited version of the Scala compiler that can run on a JavaScript environment.

The main motivation is to compile, and then execute, Scala code in a web browser.

Supervisors

Adrien Piquerez(adrien.piquerez@epfl.ch): Tooling Engineer at the Scala Center Sébastien Doeraene(sebastien.doeraene@epfl.ch): Principal Engineer at the Scala Center and author of Scala.js

Milestones

M1 - Compiling dotty.tools.dotc.Main to JavaScript

Link the dotty.tools.dotc.Main class of the Scala 3 compiler in lampepfl/dotty into a JavaScript executable file.

All linkage errors must be solved by one of the possible solutions:

It should be able to produce the SJSIR files of a simple Hello World program.

M2 - Running the scalajs-compiler-tests in JavaScript

The scalajs-compiler-tests project should run in a JavaScript environment. The failing tests should be fixed or they should be ignored for an explicit reason. For example we can ignore the tests that depend on macros.

M3 - Explore and draft a solution for macro resolution

The expansion of macros use class-loading and reflection. This is not possible in JavaScript so we need to find an alternative solution.

Prerequisites

Expected outcome

For a Master semester project, we expect the student to complete milestone M1 and to progress significantly on milestone M2. For a Master's project, all 3 milestones should be completed.

The final state of the code and the report should make it easy for another student to take up the project if need be.

dos65 commented 1 year ago

@adpi2 Hi! We discussed this project with @sjrd and it will be taken by @xxeniaev with my mentorship. Could you add taken label to it?