News for hackers. Stuff that matters.
Re:LLVM's Clang Successfully Self-Hosts by Locke1689 on Friday February 05, 2010 @12:21AM (#1102776)
Big 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).
Re:LLVM's Clang Successfully Self-Hosts by sreque on Friday February 05, 2010 @12:40AM (#1102804)
After 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?

Re:LLVM's Clang Successfully Self-Hosts by ighost on Friday February 05, 2010 @01:51AM (#1102943)
I 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.
Re:LLVM's Clang Successfully Self-Hosts by haberman on Friday February 05, 2010 @02:33AM (#1103016)
Check 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.x...

Re:LLVM's Clang Successfully Self-Hosts by Locke1689 on Friday February 05, 2010 @05:57AM (#1103273)
This 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.
Re:LLVM's Clang Successfully Self-Hosts by ighost on Friday February 05, 2010 @02:31PM (#1104544)
thxu.

Too bad it assumes knowledge of C++. I hope I can still follow it with my limited C++ knowledge.

Re:LLVM's Clang Successfully Self-Hosts by mullr on Friday February 05, 2010 @02:20AM (#1102997)
They did, and it's called "Effective C++". Okay, it's not exactly the same thing. But they both tell you what NOT to do.
Re:LLVM's Clang Successfully Self-Hosts by jey on Friday February 05, 2010 @12:34AM (#1102789)
It'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 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.

Re:LLVM's Clang Successfully Self-Hosts by krakensden on Friday February 05, 2010 @01:29AM (#1102895)
I'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.

Re:LLVM's Clang Successfully Self-Hosts by jey on Friday February 05, 2010 @07:26AM (#1103370)
It'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.
Re:LLVM's Clang Successfully Self-Hosts by beza1e1 on Friday February 05, 2010 @01:57AM (#1102954)
I'm hacking on a compiler written in C, which isn't worse than LLVM: http://libfirm.org
Re:LLVM's Clang Successfully Self-Hosts by eru on Friday February 05, 2010 @06:44AM (#1103309)
Why do a compiler in C at all? I mean, why should a low-level systems language (that values speed above everything) be particularly suited to transforming programs from one language into another?
Re:LLVM's Clang Successfully Self-Hosts by nvoorhies on Friday February 05, 2010 @01:04PM (#1104269)
Because this allows you to compile in places and times where a language with more suitability towards compilation but heavier time or memory needs would be unsuitable.

One example that pops to mind is shader programs on a GPU.

Re:LLVM's Clang Successfully Self-Hosts by eru on Friday February 05, 2010 @03:43PM (#1104763)
Where (and when) would the compiler for the shader run?
Re:LLVM's Clang Successfully Self-Hosts by yan on Friday February 05, 2010 @12:31AM (#1102785)
Their C++ is amazing though. Exceptionally clean and well-designed.
Re:LLVM's Clang Successfully Self-Hosts by capablanca on Friday February 05, 2010 @05:18AM (#1103227)
How 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.
Re:LLVM's Clang Successfully Self-Hosts by jey on Friday February 05, 2010 @07:28AM (#1103373)
By 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).

Re:LLVM's Clang Successfully Self-Hosts by capablanca on Friday February 05, 2010 @10:35AM (#1103744)
Indeed... 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++?

Re:LLVM's Clang Successfully Self-Hosts by pohl on Friday February 05, 2010 @11:43AM (#1103941)
One 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.)
Re:LLVM's Clang Successfully Self-Hosts by jpcx01 on Friday February 05, 2010 @02:08AM (#1102977)
I'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.
Re:LLVM's Clang Successfully Self-Hosts by jlangenauer on Friday February 05, 2010 @04:33AM (#1103176)
It'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.