9 ms·
It continues to be disappointing (which I think is the least strong word that could be used) that clang's website attempts to demonstrate the superiority of cla
by saurik 13y ago
It continues to be disappointing (which I think is the least strong word that could be used) that clang's website attempts to demonstrate the superiority of clang by comparing against the error messages from gcc 4.2, a version of gcc that wasn't even the most current when that comparison was published. This then leads to people accepting this as fact (especially amongst developers targeting Apple products who don't even seem to realize versions of gcc later than 4.2 exist, as Apple refused to continue work on gcc due to the licensing changes) an turn up in answers like this one as the "most notable" technical advantage of the product.
In fact, the error messages of the two systems are largely a tradeoff at this point, and in a project I work on that compiles using both gcc and clang (targeting MinGW and OSX) simultaneously, on multiple occasions gcc has returned the more useful error messages (even if you discount the times when clang outright crashes while trying to compile my code, something gcc hasn't done to me in a decade). Even to the extent to which clang is better (which is mostly how it will guess what you meant and then compile the rest of the file under that assumption), it is kind of insulting in an open source context to treat that as a competitive advantage when I'm certain gcc would have loved that patch as a contribution.
- aspensmonster 13y ago>as Apple refused to continue work on gcc due to the licensing changes This. As stated in the accepted answer in the linked article, licensing issues are the real reason. Technical differences are ephemeral. The competition between GCC and LLVM has a habit of inducing improvments in both projects. By all means, at any given point in time one project can have an edge over another in this niche or that edge case. But fundamentally this is a philosophical divide between Free Software and Open Source Software.
- JoshTriplett 13y agoThis is a licensing debate, but please don't conflate that with a divide between "Free Software" and "Open Source". Both GCC and LLVM/clang qualify as both Free Software and Open Source software. Both terms encompass both copyleft and non-copyleft (all-permissive) licensing. GCC uses a copyleft license; LLVM/clang uses an all-permissive license. FreeBSD prefers to avoid dependencies on copyleft code, especially in their core; thus, they naturally prefer LLVM/clang.
- aspensmonster 13y agoApologies. That is a better comparison: A divide between copyleft licensing and permissive licensing.
- foobarbazqux 13y agoThen again, copyleft licensing is idiomatic of free software, and permissive licensing is idiomatic of open source software. This essay covers the essential differences: http://www.linfo.org/open_source.html http://www.linfo.org/open_source.html
- air 13y agoThat's a very misleading essay. "It is that, whereas free software is always also open source, open source software does not necessarily have to be free software. That is, software can be open source without granting its users the additional freedoms that free software guarantees." This is incorrect, and the example given was incorrect. The terms are identical in meaning. Open source was coined to be a trademark for free software.
- foobarbazqux 13y agoIf I give you Tivoized BSD code, this is open source but not free software, at least since GPLv3.
- air 13y agoFirst of all, creating a new free software license does not alter the freeness of any software/license. GPLv3 incompatibility does not make software non-free, otherwise Linux kernel would not be free anymore. Second, the Tivoised BSD code is free software. The fact that a piece of hardware exists that refuses to run a modified version of some BSD licensed code, does not make the code non-free.
- 13y ago
- jevinskie 13y ago> Technical differences are ephemeral. Hardly the case when you want to extend/embed your compiler frontend/backend. In this case, LLVM/Clang shine. They are written in fairly clean and comprehensible C++ libraries. Most CLI tools are well under 1k lines! GCC is a real pain to even comprehend, let alone extend/embed!
- belorn 13y agoClang only support a subset of the features that GCC has, so it is naturally easier to comprehend. Reading the user manual, more "tricky" GCC extensions is intentionally not implemented because they would be too hard to implement. If you think this is good/bad for Clang/GCC, depend if you ever used said features, or if one prefer a smaller compiler which has less features.
- chongli 13y agoIt's not really more/less features so much as it is a tradeoff. LLVM is extremely powerful in that it lets you write front-ends for many different languages without worrying about the complexities of native code gen. Likewise, it lets you write backends for other target platforms (i.e. JavaScript), allowing you to gain the ability to port those languages to new platforms easily. Thirdly, you can write optimizers for LLVM's intermediate representation and gain the benefit across most/all front-end languages and back-end platforms. GCC, on the other hand, seems to have a much narrower focus but with a lot more optimizations and weird extensions.
- statusgraph 13y agoThis is exactly GCC's architecture as well, where front-ends are transpiled into a generic language, which is then compiled into native code for a given platform.
- cperciva 13y agoThat's how GCC works internally, but neither the front-ends nor the back-ends are available to use individually. Indeed, RMS specifically avoided having a flexible architecture similar to llvm, because he was afraid such flexibility would be used for non-GPL "plugins".
- saurik 13y ago(Right. I think we are in agreement, but to be very clear for others who might only read these comments: the accepted answer is from where I quoted the "most notable" technical benefit.)
- hcarvalhoalves 13y ago> clang's website attempts to demonstrate the superiority of clang by comparing against the error messages from gcc 4.2 Even if it that doesn't hold true anymore, I think it's valid to highlight since it's one of the motivations, probably one of the original creators' pain points with GCC. The website reads: Some of the goals for the project include the following: End-User Features: - Expressive diagnostics (examples)
- eonil 13y agoClang is targeting specific market - free and non-GPLv3 compiler (with OBJC support). The sales catchphrase superior error message is still true for the people in the market. And comparison with compiler in GPLv3 is meaningless to them. You're just out of target.
- kps 13y agoYou could always submit a patch. talks about the experience provided by the command line compiler, contrasting -Clang output to GCC 4.2's output in several examples. +Clang output to that of GCC 4.2 (current when the Clang project began) +in several examples. <!--
- rsynnott 13y ago> clang's website attempts to demonstrate the superiority of clang by comparing against the error messages from gcc 4.2, a version of gcc that wasn't even the most current when that comparison was published. This is the latest version available by default on MacOS and FreeBSD (for licensing reasons; subsequent versions are GPLv3), the two operating systems where clang sees most use.
- saurik 13y agoAt which point you may as well just point out "clang is maintained; unlike gcc 4.2, which at best will only receive back-ported compilation and security fixes, clang is under active development" ;P. You don't even need to motivate "better": it just needs to be "all least sort of as good". In the end, the only legit reason for this change is licensing, and any references to technical superiority between clang and gcc as a whole are red herrings at best and disingenuous at worst.
- rsynnott 13y agoApple certainly has technical reasons for using clang; good luck getting the degree of integration XCode has with clang with GCC (the plugin system added as a response to clang existing would help, but would not be sufficient in itself). BSD has less clear ones, though I would hope that other C/C++ IDEs will start adding similar levels of integration. Ultimately, clang offers a way forward without having to adopt GPLv3 software, and besides that offers considerable benefit to people making development tools. Its big selling point has never really been speed; that it can generally keep up is enough. EDIT: You could certainly also make the claim that Clang's far faster compilation is a technical feature, especially for C++ programmers. There are actually people who use clang for development, for the fast compilation and static analysis, then build for production with a newish GCC.
- saurik 13y agoMy comment complains about the error handling comparison and then makes assertions about the "only legit reason for this change" <- "this change", of course, being the one to FreeBSD. I am not quite certain how issues Apple runs into with Xcode are relevant (and talking about hypothetical future IDEs, which certainly would not be FreeBSD-specific and which would treat clang as any other library to depend on, doesn't make the motivation any more clear to me). To address your second paragraphs, I am responding to a comment (yours) justifying why clang should spend time on their website making comparisons against gcc 4.2, a stance you defend by stating that that is the version that people are using instead of clang. Now, in your response to my defense against that point, you are bringing up legitimate technical benefits of clang against all versions of gcc... ...but I would never, nor have I so far in this thread, complained that those benefits didn't exist; I especially haven't claimed that those version-independent architecture benefits shouldn't be mentioned on their website. My complaint, remember, is that there are specific nebulous benefits (error output) being touted against gcc 4.2 as the "most notable" (according to the SO answer being discussed) technical be benefit of this project. That specific benefit only exists because of a licensing decision, as gcc after-4.2 does not have error output this bad (not do I believe it did in 4.3 trunk at the time that website was published). The honest reason, if "error output" is important, as to why clang is better than gcc for FreeBSD is thereby "licensing", as if licensing weren't the real reason that benefit evaporates: it is no better than just pointing out that gcc 4.2 is unmaintained. However, and again, you are more than welcome to be happy or excited about any other real benefits, either to other parties or the ones in question, but your comments in this context are anticipating complaints I haven't made and in fact is aggressively arguing with me over something I don't even disagree with: it is as if you see anyone complaining about clang and presume "they must just be a hater" and knee-jerk your way through a muscle-memory argument over "why clang is better" (something I have no strong opinion about).
- 6ren 13y agogcc 4.2.1 was the last version to use GPLv2. Later versions switched to GPLv3, which the BSD guys couldn't swallow. From skimming the answer, I think it's pretty clear that the switch wasn't due to technical reasons, but that Clang/LLVM is now "good enough". It seems reasonable for FreeBSD to favour BSD licensing.
- saurik 13y agoI am not exactly certain what you are disagreeing with from what I said (as I agree that the only legitimate reason is licensing), so I guess I'll justt point out that the answer you apparently only "skimmed" has a section on "technical benefits" that specifically listed a "most notable" example being improved error messages.
- 6ren 13y agoYes, I read that bit. Your objection seemed to be about the comparison with an older version of gcc, and I was noting why that comparison was legitimate, for them. EDIT Ah, I see how: you're talking about clang's website, whereas I'm talking about the submitted link, which is about FreeBSD. Note: the same argument also applies to other companies avoiding the GPLv3, which would explain why clang's website uses gcc 4.2 in its comparison. Though people here mentioned the GPLv3, no one noted that 4.2 was when the gcc license switched to it (I checked the HN comments). FWIW I've seen a GPL project eventually lose out to a BSD-style competitor, and the latter were surprisingly nasty about it, similar to what you're saying. This might be due to commercial interests vigorously supporting the BSD-style version for reasons of MONEY. But apart from nastiness, it makes sense that a more permissive license, being free to a wider audience, will be more popular. OTOH perhaps here, for a compiler, requiring people to give back (GPL) will work better? OTOH2, promising new tech always gets a certain ersatz caché - whether that promise is fulfilled or not.
- saurik 13y agoThe submitted link has a section on technical benefits to FreeBSD for making this switch which directly links to clang's website for what this submitted link's accepted answer considers the "most notable" technical benefit.
- cmccabe 13y agoWell, I like the clang error messages better than gcc's, and I use recent versions. And to refer to the major architectural differences between the two as something that could be bridged by a single "patch" is a little silly. gcc is still better at optimization, though. For now. [edit: wow, people are really confused here. Guys, LLVM was designed from the start to have a clean separation between passes. You can compile some other language to the LLVM bytecode and then just use the code generator, for example. It even includes a JIT! In contrast, gcc is a huge monolith. The projects are written in different languages, too... C++ versus C. tl;dr is that when you say that "the only difference is the license," you sound like someone saying "the only difference between Ruby and Java is the file extension." Pointy haired.]
- illumen 13y agogcc is in C++ for a while now. gcc has been becoming more modular over previous releases, and is becoming more modular in the future. For example, there are plugins since 2010. Your information is outdated, so it makes your opinion seem uninformed.
- cmccabe 13y agoMost of gcc is still written in C. Only a tiny amount of new code is in C++. In my opinion, that's the worst of both worlds-- inconsistent code, plus C++ overheads. I work with some fairly recent version of both compilers-- gcc 4.7.2 and clang 3.2. I also know a developer on the LLVM team. clang is way ahead of gcc in many ways, and the gcc devs know it. We still ship software built with gcc, rather than clang, because gcc is still better at optimization. (gcc also supports more obscure targets, though that's not our biggest concern). We also make use of llvm's ability to dynamically recompile code on the fly in Cloudera Impala. More information here: http://blog.cloudera.com/blog/2013/02/inside-cloudera-impala-runtime-code-generation/ http://blog.cloudera.com/blog/2013/02/inside-cloudera-impala... This would not be possible with gcc no matter how much work we did (license issues-- Impala is Apache 2.0, gcc is GPLv3).
- saurik 13y agoWhen a parse failure occurs, making an educated guess and continuing is not a "major architectural difference". (As for your edit, I now challenge you to tell us how these architecture passed and the JIT help FreeBSD's use cases. That said, my comment you are responding to just expresses bother about the "most notable" technical benefit listed by this SO answer, so I'm not even certain why you feel talking about other things is relevant.)
- lbenes 13y agoThe real disappointment to me is that this decision was made over an irrational licensing issue instead of technical merits. If Clang was superior to GCC in the vast majority of benchmarks, then I would support this decision. But that’s not the case, GCC is still leading in many benchmarks and can be an order of magnitude faster when the commonly used OpenMP library is used.[1] BSD users are the losers here. [1] http://www.phoronix.com/scan.php?page=article&item=llvm_33svn_competes&num=5 http://www.phoronix.com/scan.php?page=article&item=llvm_33sv...