Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What language features would make C better as a target language for compilers?




By piggybacking off GCC et al you gain very easy portability/access to a bunch of platforms that most languages would never attempt to support.

We used this in production with Nim for embedded firmware engineering at my previous job doing industrial IoT systems, which let us write a much nicer language than C (and much faster, much safer), with code-sharing between the network server (and its comms protocol) and the firmware code itself.

All can be done with C itself of course, but this let us achieve it faster and in a much nicer fashion


Not strictly for compilers (which probably don't need to use macros much), but for normal macro-codegen it would be very useful to have some some way to add line returns in macro-generated code so that it's easier to inspect with gcc -E

In general:

- standardized alloca()

- fine-grained control over struct layout

- some way to perform a guaranteed tailcall

- some way to do stuff like tagged pointers portably without triggering UB


Why alloca?

How else would you do dynamic arrays without heap allocation if the source language has that as a feature?

With VLAs which are standardized, safer, and scoped.

Good point, that would indeed be a better way to do this.

Full VLA support is optional for C compilers though...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: