9 ms·
LLVM's Clang Successfully Self-Hosts
- Locke1689 17y agoBig step, congratulations to everyone who worked on it. When I get some more time I need to look into the code in those projects. It's too bad that they chose to use C++ (as opposed to C) to implement it though (yech, personal preference).
- yan 17y agoTheir C++ is amazing though. Exceptionally clean and well-designed.
- capablanca 17y agoHow can you tell? Did you work on it for a few months or you can just browse the SVN and notice it's well designed? I look and all I see at first is indentation style and directory organization.
- jey 17y agoBy studying the code? If all you noticed from seriously looking through the source is that it is well indented and well organized, you're probably not an experienced enough C++ programmer to evaluate the merits (no offense intended).
- capablanca 17y agoIndeed... So by clean you mean looking for usages of certain C++ features that should be avoided? How can you "infer" the design only by looking at a pile of C++?
- pohl 17y agoOne probably couldn't by merely looking at it. Reading it with the specific intent to understand it, on the other hand, can make design intent pretty clear. (One would hope that the structure of the program is at least homomorphic to the intended design, if not isomorphic.)
- jey 17y agoIt's truly excellently written C++ code, and they don't go nuts with fancy C++ voodoo template meta-trans-factory-programming tricks or whatnot. And have you seen what happens when you write a huge compiler in C? This: http://gcc.gnu.org/wiki/reload http://gcc.gnu.org/wiki/reload And I don't think you can reasonably argue that GCC's hackers are sub-par either. ;-) Language features for abstraction and encapsulation are pretty important for something that huge.
- krakensden 17y agoI'd argue that there is an age factor at play- GCC is older, designed under different (ie, much more stringent with regards to resources) constraints. GCC also has a perennial problem attracting and managing developers, which LLVM seems to have avoided.
- jey 17y agoIt's really not the age or resources that hamper it (from experience hacking it). Well, OK, the age does matter -- but only because it's C. It wouldn't have been so bad if they didn't have to reinvent basic things. GCC has its own garbage collector, a set of bizzare hacks to replace inheritance, amongst other atrocities. None of these have to do with resource constraints, and nearly all have to do with the low-level nature of C.
- beza1e1 17y agoI'm hacking on a compiler written in C, which isn't worse than LLVM: http://libfirm.org http://libfirm.org
- sreque 17y agoAfter doing application-level programming in C for a while at a job, I learned to re-appreciate some of the abstractions that C++ gives you that you have to code by hand in C. Once you get used to the ridiculous compile errors and slow compilation times, isn't it nice to have access to a built-in string library and efficient data structures? To not have to roll your own implementation of a v-table and inheritance if you want OO? To be able to do compile-time generic programming where the compiler can more easily do things like function inlining? I'm no longer certain which I consider is the better language to code in overall. I've heard the C++ hate from Yossi Kreinin, Linus Torvalds, Steve Yegge, and other high profile people, and I've experienced the pain and misery of trying to understand and use its more complex features myself, but in the end, for most applications are you really better off sticking with C than using a "tasteful subset of C++" like the LLVM team does?
- ighost 17y agoI wish someone would publish this "tasteful subset of C++," kind of like Douglas Crockford's Javascript: The Good Parts. Then I could just learn that and skip all the crazy template shit.
- mullr 17y agoThey did, and it's called "Effective C++". Okay, it's not exactly the same thing. But they both tell you what NOT to do.
- haberman 17y agoCheck out the Google C++ Style Guide. I'm biased (being a Googler), but I think it leads to pretty nice and readable C++: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml http://google-styleguide.googlecode.com/svn/trunk/cppguide.x...
- Locke1689 17y agoThis is fantastic. My main gripe with C++ in non-system code is that there are too many features which complicate the code base and should never be used. This seems like great guidelines and a good subset.
- jpcx01 17y agoI've always hated C++ as a language syntax, but I'm coming around. rubinus, llvm, and mongo all use it and their codebases are really well built. So maybe the language isnt so bad after all, as long as you have geniuses using it.
- jlangenauer 17y agoIt's not so much about having geniuses coding in it, it that when you do use it, you use it to make conceptually elegant code. When I work in C++, I simply do not use templates, because I find the make the code impossible to grok - the complexity can overwhelm you (let alone a new developer unfamiliar with a given C++ code base). Treat C++ like Ruby, and try to use it to make beautiful, and elegant code. That's where it shine, IMHO.
- spicyj 17y agoSo did the third compilation produce a binary identical to that of the second one?
- derefr 17y agoIt would be awesome if there were some sort of Trusting-Trust-style "telomeres" encoded into the resultant binary, so that C and C' and C'' would all work identically, but C'''''''''' would suddenly produce different outputs.
- eru 17y agoAnd of course they should be invisible in the source after the first go.
- sp332 17y agoHe means taking the source code for the compiler and running it through the compiler, then taking the same source code and running it through the resulting compiler, etc. Same source, new binaries every time.
- eru 17y agoYes. I know "Trusting trust". And the backdoor will be in the original source code, and after it has passed into the binary you get rid of it in the source.
- mrduncan 17y agoProbably my favorite paper of all time, such a small paper yet so mind-blowing when you first discover it. http://cm.bell-labs.com/who/ken/trust.html http://cm.bell-labs.com/who/ken/trust.html
- snowbird122 17y agoWill someone please explain what this means.
- spicyj 17y agoClang, a new compiler based on LLVM (http://llvm.org/ http://llvm.org/), designed to be faster and more extensible than GCC, is now able to build its own source tree rather than relying on another compiler. This means that the compiler supports a sizable chunk of C/C++ language features.
- raintrees 17y agoThank you. That was way too self-referential for me to follow, as well.
- by 17y agoC programmers often use the free GCC (GNU compiler collection) to compile their programs. clang is a new open source C compiler that may be better for some people because it has a different licence, will be faster in certain circumstances and may give better error messages. The significant milestone the clang project has reached is the ability to sucessfully compile a very large quantity of C code. (Edit: C++ as well as C)
- utku_karatas2 17y ago> because it has a different licence In which manner does the GCC license restrict the user in a problematic way? (well, except GPL's distribution restrictions I suppose.)
- woodson 17y agoThe changes due to GPLv3 (non-discriminatory patent licence etc.) seem to be incompatible with the interests of BSD people [1] as well as perhaps Apple, who is the main sponsor. [1] http://wiki.freebsd.org/BuildingFreeBSDWithClang http://wiki.freebsd.org/BuildingFreeBSDWithClang
- jeff18 17y agoWait does this mean that LLVM supports C++ well now? Last time I checked at WWDC, it had great C and Objective-C support, but C++ was hardly there. It would be great if Xcode can add support for all of the awesome refactoring and static analysis that Objective-C can currently do in C++ now!
- bryansum 17y agoLooks like there's still a lot of work to be done: http://clang.llvm.org/cxx_status.html http://clang.llvm.org/cxx_status.html
- gane5h 17y agoIn my opinion, I believe llvm-g++ is a more promising approach to supporting C++. C++ is an incredibly difficult language to parse, so why not re-use work that has already been done?
- yuvi 17y agoUseful error messages. Even in C gcc is lacking, let alone C++, and I'd imagine that fixing this in gcc wouldn't be/have been much easier than writing clang.
- pieter 17y agoBecause g++ has its own problems that won't be solved by switching backends, like unclear diagnostics. Then there's the license issue, which can be important for some. Clang is also built as a library, so you can link to it and JIT c-code at runtime.
- tbrownaw 17y agoThat's dated December 19, so I'd imagine it's a bit out of date.
- c00p3r 17y agoIs it already imported into FreeBSD as a default system compiler? =)
- meilin 17y agowww.kicksaike1.com sells Nike Air Force 1, <a href="http://www.kicksnike1.com/>Nike http://www.kicksnike1.com/>Nike Shoes</a>, Top quality Nike Air force ones and <a href="http://www.kicksnike1.com/>Nike http://www.kicksnike1.com/>Nike Air Force 1 sneakers</a>, Nike Air Force 1 special!