gleam-lang / suggestions

📙 A place for ideas and feedback
26 stars 2 forks source link

Compilation to web assembly and/or native code #128

Open lpil opened 3 years ago

lpil commented 3 years ago

This would be really cool!

Questions

LLVM?

Would we target WASM and then compile that to native? Or use something like LLVM that can do both? Using LLVM may be more challenging to develop and maintain, and may result in a slower compiler, but may be result in faster code. WASM is currently limited in terms of multi-core and OS API access too.

How does one learn to use LLVM?

libgccjit

Same as above!

https://gcc.gnu.org/onlinedocs/jit/index.html

https://github.com/antoyo/rustc_codegen_gcc https://github.com/antoyo/gccjit.rs/tree/feature/rustc

References

TinyGo implementation details

https://tinygo.org/compiler-internals/datatypes/

https://github.com/tinygo-org/tinygo-site/blob/248714f1a5a17a9d80dbabc25ecc6d3370dac266/content/compiler-internals/datatypes.md

Nim's reference counting

Nim has an interesting memory management strategy of non-atomic (single threaded) reference counting with data owned by a thread (so no atomics) and a cycle collector in the background to handle loops not handled by the RCs. Requires the programmer to manage ownership to some degree.

https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html

https://nim-lang.org/araq/ownedrefs.html

https://forum.nim-lang.org/t/5734

https://archive.fosdem.org/2020/schedule/event/nimmovesemantics/

https://nim-lang.org/araq/

Pony's GC

https://github.com/ponylang/pony-tutorial/blob/main/docs/appendices/garbage-collection.md

https://www.ponylang.io/media/papers/orca_gc_and_type_system_co-design_for_actor_languages.pdf

https://www.imperial.ac.uk/media/imperial-college/faculty-of-engineering/computing/public/1718-ug-projects/Daniel-Slocombe-Reliable-Garbage-Collection-in-Pony.pdf

Lean4's GC

https://www.microsoft.com/en-us/research/uploads/prod/2020/11/perceus-tr-v1.pdf

Koka's RC

https://www.microsoft.com/en-us/research/uploads/prod/2020/11/perceus-tr-v1.pdf

Counting immutable beans

https://arxiv.org/pdf/1908.05647.pdf