CatalaLang / catala

Programming language for literate programming law specification
https://catala-lang.org
Apache License 2.0
1.97k stars 78 forks source link

Idiomatic C backend #690

Open denismerigoux opened 1 week ago

denismerigoux commented 1 week ago

The current C89 backend (#671) is semantics-preserving and quite fast (as fast as native OCaml without GC allocations) thanks to @AltGr. However, the code it generates is not very idiomatic and might be difficult to adopt by people that really want a C they can read and modify (https://jonathan.protzenko.fr/2019/01/04/behind-the-scenes.html). Thus, we might want to relax semantics-preservation (slightly) in favor of generating C code that looks like man-made. This could be done in an alternative C89 backend that I would qualify as "idiomatic". The gist of the idiomatic backend is that it should use builtin types and avoid boxing at all costs.

To achieve this objective, the following changes are needed from the current C89 backend :