Periodic reminder: Don’t compile to C.
-
-
Replying to @pcwalton
Why? It's the only way to get native code without only supporting a few popular mainstream platforms.
2 replies 0 retweets 0 likes -
Replying to @RichFelker
Because of undefined behavior, bad error reporting, and never being able to implement proper GC, among other reasons.
4 replies 0 retweets 7 likes -
Replying to @pcwalton
If you generate C you can ensure it doesn't have any UB (assuming no interfacing with unsafe arbitrary C code), & can even do GC if you want (but GC is uhg).
1 reply 0 retweets 0 likes -
Replying to @RichFelker
It’s a big pain, though. Signed integer overflow, float<->int casting UB, etc. are all things people often don’t want in their language and makes the generated C really ugly. And you can’t do *good* GC. :) You need stack and register maps, which are impossible in C.
2 replies 0 retweets 2 likes -
Replying to @pcwalton @RichFelker
TBF LLVM has a lot of obnoxious UB around float <-> int operations, division, sqrt, etc. too
4 replies 0 retweets 1 like -
I think, at a higher level, using *any* language as a compiler target requires thorough understanding of the target language semantics—even assembly language
2 replies 0 retweets 2 likes -
Replying to @jckarter @RichFelker
I agree…so why make life hard for yourself? :) Pick an intermediate language that was designed as a compiler target.
2 replies 0 retweets 1 like -
Replying to @pcwalton @RichFelker
I've written compilers targeting both C and LLVM, and while LLVM does make some things easier, it also makes things like FFI harder (even with C), and like Rich says you give up a lot of portability.
2 replies 0 retweets 2 likes -
LLVM is also a constantly moving target, and integrating it is a pain as a small team or individual without people to dedicate to tracking ToT, whereas C is standardized
1 reply 0 retweets 1 like
That’s fair, as long as you don’t think your project will eventually grow to be large :)
-
-
Replying to @pcwalton @RichFelker
Well if your project gets big enough, then you can hire someone else to deal with the LLVM backend
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.