←back to thread

429 points rui314 | 5 comments | | HN request time: 0.227s | source
Show context
tomcam ◴[] No.10731290[source]
I was a little surprised that the author was able to manage both C11 and the preprocessor in that time. The preprocessor is hard. But there was existing code from a previous version of it, which makes sense. Still, a fantastic achievement! Congrats to the author!
replies(1): >>10732574 #
eliben ◴[] No.10732574[source]
Out of curiosity - why do you consider cpp particularly hard? It's easier than the compiler, actually :)
replies(1): >>10734688 #
1. tomcam ◴[] No.10734688[source]
Well... easier than the compiler but very hard to do the last 20% (I never had the time; hobby project) because docs are so hard to find. Or at least were--maybe that's changed.
replies(2): >>10735178 #>>10735830 #
2. eliben ◴[] No.10735178[source]
What docs? It's all in the standard
replies(1): >>10735443 #
3. rui314 ◴[] No.10735443[source]
The standard says too little about the preprocessor. I don't think you can implement a preprocessor that can read system header files only with the standard.
replies(1): >>10737730 #
4. DougMerritt ◴[] No.10735830[source]
There are lots of corner cases that people are unaware of, such that almost all reinventions of the C preprocessor are technically broken, but in ways that typically won't be noticed.

One of the primary authors of the standard posted a corner case where the standard was wrong, and one needed his posting to design one piece of the preprocessor correctly.

Generally when people say "why do you say XYZ is hard? I did it and it was easy!" -- they haven't put their creation into industrial use with millions of users, and hence are unaware of its flaws.

As you say, just doing the metaphorical 80% of most things is indeed easy, but not the remainder.

5. eliben ◴[] No.10737730{3}[source]
System header files usually employ platform-specific extensions not only on the preprocessor side, but in preprocessed code as well AFAIK. That is, the compiler has to support them too.

My comment was not to say that coding cpp is easy - just that it's not a particularly hard task compared to the compiler itself.