3 ms·
This year I wrote the latest compiler for jank[1] to be in C++. Originally, this new version was being written in Rust, which I prefer, but I ran into a serious
by Jeaye 4y ago
This year I wrote the latest compiler for jank[1] to be in C++. Originally, this new version was being written in Rust, which I prefer, but I ran into a serious limitation. In the C++ world, we have Cling[2], so I can easily JIT compile arbitrary C++ code and link it to my running process. This is exactly what I need for jank's REPL and JIT capabilities. In the Rust world, such a thing doesn't exist and trying to use rustc as a crate is not well supported at all, all on top of the ABI instability issues.
I model most the C++ code around Rust's semantics for things like option<T> and result<T, E>. Currently working on replacing my boost::intrusive_ptr usage with an equivalent which is non-nullable, to be combined with option<T>. Even with value semantics, RAII, and hefty TMP for type-rich APIs, C++ still bites in many ways. It's still so easy to have UB compile, including anything from iterator slip ups to interdependent static globals in different TUs with undefined ctor/dtor orders.
1: https://jank-lang.org/ https://jank-lang.org/
2: https://root.cern/cling/ https://root.cern/cling/