5 ms·
Wow, I am in awe of Jeff Law at the moment :-). I am glad they found the issue and are fixing it. I was helping a high school student learn how compilers work
by ChuckMcM 7y ago
Wow, I am in awe of Jeff Law at the moment :-). I am glad they found the issue and are fixing it.
I was helping a high school student learn how compilers work and we started by opening up GCC and I was astonished at just how mindbogglingly complex it had become. We closed that down and opened up the delightful Bellard "Tiny C"[1] which was comprehensible at the level where this student was working. We created a new 'bool' type for that compiler.
[1] https://bellard.org/tcc/ https://bellard.org/tcc/
- pcwalton 7y agoIf you want a simple modern compiler backend intended for production-readiness, consider Cranelift [1]. It's largely written by Dan Gohman, who is a longtime LLVM contributor (and a colleague of mine). It does a lot of the things LLVM's backend passes do, but it's cleaner and better factored, with the benefit of a decade of hindsight [2]. Cranelift should be great for teaching purposes. [1]: https://github.com/CraneStation/cranelift https://github.com/CraneStation/cranelift [2]: https://cranelift.readthedocs.io/en/latest/compare-llvm.html https://cranelift.readthedocs.io/en/latest/compare-llvm.html
- dhuramas 7y agoI was wondering where I had heard of Cranelift before- seems like it is the default backend for wasmer[1]. [1] https://github.com/wasmerio/wasmer#building https://github.com/wasmerio/wasmer#building
- ChuckMcM 7y agoThat is a pretty neat backend for compilers. Definitely worth using when going to the 'next level' between how do we take text and turn it into binary as level 1, and then level 2, how do we improve the binary we're going to generate by understanding what the ASTs are telling us.
- nickpsecurity 7y agoThanks. I'll check it out. In that vein, what do you think of QBE (open-source) and LCC for understandable compilers? https://c9x.me/compile/ https://c9x.me/compile/ https://en.wikipedia.org/wiki/LCC_(compiler) https://en.wikipedia.org/wiki/LCC_(compiler)
- ndesaulniers 7y agoAny plan to use this in rustc? If so, is there a plan to maintain cross language LTO w/ C++?
- masklinn 7y ago> Any plan to use this in rustc? One of the primary expectations / use cases for cranelift is its use for rustc's debug builds: https://github.com/CraneStation/cranelift/blob/master/rustc.md https://github.com/CraneStation/cranelift/blob/master/rustc....
- pcwalton 7y agoDefinitely, for debug builds. Eventually perhaps for release—LTO is one of the many things we would have to figure out if we go down this road.
- andrepd 7y ago>we started by opening up GCC and I was astonished at just how mindbogglingly complex it had become It's the price of being good ;)
- monocasa 7y agoWell, and just being ancient. LLVM is good too, but a lot cleaner. For instance (from GCC's docs): > Reload is the GCC equivalent of Satan. See [gccsource:reload.c], [gccsource:reload1.c], and [gccsource:reload.h] if you have a brave soul. https://gcc.gnu.org/wiki/reload https://gcc.gnu.org/wiki/reload
- andrepd 7y agoAFAIK, gcc still circles around clang.
- gameswithgo 7y agoNo. Each compiler has its own set of strengths and weaknesses, which is probably why for any of the big 3 (4 if you count intel?) compilers there are people who think one is the best. Whatever circle of internet people I happen to see a lot all think MSVC is terrible for instance, but the one really low level project I happened to work on, it produced the best code for it. I wouldn't say any of the compilers runs circles around another in general There is also a tendency for, whatever compiler you used mainly while developing your thing, it appears the best since you have been tweaking for that target the whole time.
- blackflame7000 7y agoIt would be pretty hard to say objectively that MSVC is terrible without knowing what's in it.
- tempo33 7y agoNo. You can evaluate compiler speed, memory use, quality of error output, generated code quality, ie most of what anyone cares about without knowing what's in it.
- userbinator 7y agoFor a compiler that's even more compact and easier to "chew on", I recommend C4[1] --- it even comes with an interpreter VM, and is only ~500 lines of code. It's also extremely understandable despite being quite terse. [1] https://news.ycombinator.com/item?id=8558822 https://news.ycombinator.com/item?id=8558822