Remix.run Logo
pizza 3 days ago

Is there a meta-library someone somewhere has already written for when I just want to write 20% of a compiler, and it more or less takes care for me 80% of the common compiler-building-related things I’m likely to need to do?

coryrc 3 days ago | parent | next [-]

You should read the book Lisp In Small Pieces. It's basically a book about doing that multiple times with every-increasing percentages.

peterkelly 3 days ago | parent | prev | next [-]

https://llvm.org/

https://docs.racket-lang.org/guide/languages.html

PittleyDunkin 3 days ago | parent [-]

LLVM doesn't prevent you from shooting yourself in the foot via a dozen different language details completely divorced from backend implementation. It's only a small, but very important and difficult, aspect of compiler writing. I think languages like go have demonstrated well that this is of limited benefit to the success of the language.

Racket at least provides most of the tooling required (eg dealing with details of namespacing, syntax, runtime/compile-time/evaluate-time distinction, continuations and garbage collection), but if you've ever tried to introduce it into an organization of significant size this very same result of yak-shaving will be considered a liability.

burnt-resistor 3 days ago | parent [-]

You're criticism is an apples vs. oranges strawman. LLVM IR and libraries provide powerful plumbing. It's not meant to be a turn-key or cookie-cutter solution, or inherently memory-safe VM or compiler generator. It's also not formally verified and written in C++, which adds project configuration complexity and C++ pitfalls. It's possible to plug in a custom GC using their strategy model their way, or manage GC yourself like Pony does because it's built around ORCA.

psittacus 3 days ago | parent | prev | next [-]

Depending on the domain, a language workbench might be a good fit.

https://spoofax.dev/

https://www.rascal-mpl.org/

lmm 3 days ago | parent | prev [-]

You could try Truffle (for Graal), then you can leave a lot to the framework.

crustycoder 3 days ago | parent [-]

Was just going to say the same. The integration of JavaScript into the Oracle RDBMS is done using a mix of C, Java/Truffle and JavaScript - https://docs.oracle.com/en/database/oracle/oracle-database/2...

And you can step up a level above in the same ecosystem as well, my current project is written in Scala and directly shares its data structures with the Graal Python interprer that I've embedded inside it, so other people can write the stuff they want in Python.