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.
-
-
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 -
Replying to @jckarter @RichFelker
You give up some portability. Not “a lot” of portability. Compiling to C also makes things like proper debug info and stack maps/register maps for GC harder (and by “harder” I mean “impossible”)
2 replies 0 retweets 1 like -
Replying to @pcwalton @RichFelker
Fair, I've never tried to write a GC language targeting C. The portability situation is better now, sure; back when I started playing with LLVM even Windows support was shaky.
1 reply 0 retweets 2 likes -
A GC language could target C by storing all heap pointers on a shadow stack or similar. Remember how the Factor runtime used macros and later smart pointers for that
1 reply 0 retweets 1 like -
Yeah, you could do that, or you could use conservative GC. It won’t be perf-competitive with the best GCs though.
2 replies 0 retweets 1 like -
Yeah, but if you’re just tinkering with something it doesn’t matter
1 reply 0 retweets 0 likes
Agreed. My concern is that throwaway projects tend to become production projects :) The move from a production conservative GC to a production moving GC is usually too steep of a hill to overcome. It took SpiderMonkey a decade, I think?
-
-
I think for a new language implementation, the odds of it ever seeing production use are rather low :)
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.