News for hackers. Stuff that matters.
Re:C as an Intermediate Language (2012) by pcwalton on Monday May 16, 2016 @12:17AM (#11704214)
Exactly, and this is what most people who work on compilers discovered long ago. It's disappointing to see "just compile to C!" still so popular on HN.

I would cite GC as the most prominent example of a feature that is incompatible with compiling to C. It is impossible to write a competitive high performance tracing GC on top of C. Mandatory register spills at safe points and conservative scanning have huge downsides.

Re:C as an Intermediate Language (2012) by ndesaulniers on Monday May 16, 2016 @02:05AM (#11704519)
> It's disappointing to see "just compile to C!" still so popular on HN.

Posts on C get blindly upvoted on HN and proggit. I guarantee it. Me thinks it's like the history channel for programmers; learning about their forerunners and how they had to bang rocks together to make fire.

It's also how I've gotten all of my karma. Unfortunately, the abyss has also looked into me, as I now write C code for a living...

Re:C as an Intermediate Language (2012) by groovy2shoes on Monday May 16, 2016 @11:09PM (#11711149)
Using C as an intermediary language can still be useful at times. For example, when writing a bootstrap compiler, you can target C and magically support virtually every platform. It's not so great for production compilers for numerous reasons, including performance (poor unless your languages maps cleanly to C) and debugging experience (debugging object code is not fun, and if your object is C, you get stuck with whatever debugging information your C compiler outputs; you don't have any say in the matter). For bootstrapping compilers, I only see three sane options, really:

1. Write an interpreter to host the compiler (probably in C).

2. Write a cross-compiler.

3. Write an X-to-C compiler.

I insist on C here not because of performance, but because it's ubiquitous.