gleam icon indicating copy to clipboard operation
gleam copied to clipboard

Draft: Improvements to typescript codegen

Open lucasavila00 opened this issue 1 year ago • 3 comments

lucasavila00 avatar Aug 09 '22 00:08 lucasavila00

Interesting, I wonder what happened here. Perhaps we broke something...

Do you have more you want to do here or should I review thoroughly?

The implementation is not really solid, and the changes I made should be reflected in function names and so on. I created the tests and basically brute forced a fix that did not break anything else, but I don't trust my reasoning enough to say this is an improvement...

Another thing that made it difficult for me was the compile + exec flow of rust, and the rust language itself. I would love if it was possible to build this typescript translation in gleam, not rust :D

lucasavila00 avatar Aug 10 '22 19:08 lucasavila00

Me too! Unfortunately I think we are a long way away from being able to write native Gleam code and link it from the compiler

lpil avatar Aug 11 '22 09:08 lpil

Me too! Unfortunately I think we are a long way away from being able to write native Gleam code and link it from the compiler

A wild thought, but I think there should be a Gleam interpreter written in Rust - this same interpreter would allow const-evaluated functions

const fn double(a) {a *2}
const abc = double(123)

And then, for some parts of the compiler where performance is not deemed important, as in TS codegen, it'd be written in Gleam.

lucasavila00 avatar Aug 11 '22 13:08 lucasavila00

An interpreter would be very handy!

I would consider anything in the compile loop (such as TS generation) to be something where we care about performance a lot so it'd need to be fast in that instance. Could be useful for various tooling commands though.

Another option could be to start a long lived instance of the VM that we can send jobs to over the network.

lpil avatar Aug 15 '22 13:08 lpil

Such an interpreter could also then be used for a REPL?

inoas avatar Aug 15 '22 13:08 inoas

It could, though we wouldn't be able to do anything that involves FFI

lpil avatar Aug 16 '22 17:08 lpil

Is this ready to review? Thanks

lpil avatar Aug 27 '22 16:08 lpil

Is this ready to review? Thanks

For now I fear I won't be able to improve the MR, so it is ready for review.

lucasavila00 avatar Aug 27 '22 23:08 lucasavila00