Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Continuations in Scala JS #22474

Open
odersky opened this issue Jan 28, 2025 · 5 comments
Open

Implement Continuations in Scala JS #22474

odersky opened this issue Jan 28, 2025 · 5 comments
Labels
Semester Project Good project to be done by an MSc or strong Bsc computer science student in one semester

Comments

@odersky
Copy link
Contributor

odersky commented Jan 28, 2025

This is a follow-on project to Guillem Bartrina I Moreno's master thesis "Lexical Delimited Continuations for Scala 3". The project aims to make continuations supported natively in Scala JS (and possibly also other Scala platforms).

Continuations or coroutines enable many important programming techniques. Examples are direct-style generators or futures. Support for continuations is increasingly widespread, but they are so far missing in Javascript or older JVM runtimes. Guillem Bartrina's recent master thesis developed techniques to implement continuations efficiently by source code rewriting. It opens the route to a practical and backwards compatible implementation of continuations. One new aspect of these techniques is their integration with Scala's capture checker. The capture checker can predict possible suspension points and this can be used to bound the amount of code that needs to be expanded for suspensions.

The aim of the projects proposed in this issue is to take Guillem's very promising work and make it generally usable in Scala.JS and possibly also Scala on JVM or Scala Native implementations. To get there we have to address the issues in the following list. They are roughly ordered in terms of dependencies, where earlier issues should be worked on first.

  1. Prepare a version of the standard library that is compiled by Scala 3 and that can be used as a basis for further work.
  2. Make all parts of the standard library suspendable by compiling them with the existing continuations plugin. So far only collections were compiled in this way.
  3. Develop an API of the capture checker that can be queried by the continuations plugin.
  4. Measure typical codesize increase. Preliminary data look quite reasonable, but this needs to be explored further.
  5. If necessary, develop compilation techniques that lead to more compact code for methods with multiple suspension points.
  6. Benchmark runtime performance against other solutions (Loom, Scala Native, js_of_Ocaml).
  7. Explore implementing the continuations transform as part of the global optimizer of Scala.JS. This might lead to smaller code sizes and more efficiency.

The project can be broken into several semester projects or master's theses.

@odersky odersky added the Semester Project Good project to be done by an MSc or strong Bsc computer science student in one semester label Jan 28, 2025
@ritschwumm
Copy link

can i find this master thesis online somewhere?

@odersky
Copy link
Contributor Author

odersky commented Jan 29, 2025

Guillem's thesis can be found here:

https://infoscience.epfl.ch/entities/publication/5b745359-7d14-4553-a3da-8590f573911c

@nightscape
Copy link

nightscape commented Jan 30, 2025

Here's s NotebookLM summary of the thesis if someone wants a high-level overview:
https://notebooklm.google.com/notebook/36ec528e-877d-40f6-86d5-e232e3406157/audio

The end of the talk sounds quite salesman-like and as if this has already been implemented in Scala. Just ignore that part 😅

@odersky
Copy link
Contributor Author

odersky commented Jan 30, 2025

Amazing! I would like to know what kind of prompt you used to get that.

@nightscape
Copy link

None at all 😅
I just uploaded the entire PDF to NotebookLM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Semester Project Good project to be done by an MSc or strong Bsc computer science student in one semester
Projects
None yet
Development

No branches or pull requests

3 participants