7 ms·
This seems like an insane undertaking for one person. I could understand it with C - that would be difficult enough. But a compliant C++11 compiler? It has take
by jevinskie 14y ago
This seems like an insane undertaking for one person. I could understand it with C - that would be difficult enough. But a compliant C++11 compiler? It has taken MSVC, GCC, and clang years to get just partial C++11 compliance! None of them are fully compliant in their current state. How is this course supposed to be tractable!?
- dhaivatpandya 14y agoI agree with this. In fact, it isn't really productive even trying to implement a language as complex as C++ (many might say overly complex).
- niggler 14y ago"More significantly, we are not doing an optimization pass." Most of the legwork in compilers like gcc involves optimizing the output code and targeting multiple architectures -- writing a dumb translator for a single architecture is a far more tractable problem.
- tedunangst 14y agoPoint remains that gcc already has an optimizer and working backend and it's still hard to implement just the necessary changes.
- niggler 14y agoadding C++11 features to GCC is a far more difficult undertaking than it should be because of RMS and his fear of proprietary frontends to GCC (so the plugin system, which is relatively easy to work with in LLVM, is a nightmare in GCC). That was a design decision Quote: "The concern that has long been expressed by the FSF (which owns the copyrights on GCC) is that a general plugin mechanism would make it possible for companies to traffic in binary-only GCC modules. Rather than contribute a new analysis or optimization tool - or a new language - to the community, companies might have an incentive to distribute their work separately under a restrictive license. That runs very much counter to what the FSF is trying to accomplish, so opposition from that direction is not particularly surprising." https://lwn.net/Articles/301135/ https://lwn.net/Articles/301135/
- snogglethorpe 14y ago> adding C++11 features to GCC is a far more difficult undertaking than it should be because of RMS and his fear of proprietary frontends to GCC Whatever you think of RMS's stance on plugins, or gcc's plugin system, they have little relationship with the ease or otherwise of adding C++11 features to gcc. The latter has much more to do with the difficulty of understanding the gcc C++11 front end, the difficulty of understanding the fine details of the C++11 standard sufficiently to implement it, and the amount of manpower available from people who can do both those things (or who have the time to learn). gcc certainly does have a lot of historical baggage in its code base (though this is slowly improving with time), but given its rather complete support for C++11 (on par with clang certainly, and far ahead of MS's compiler and most other proprietary C++ compilers), they're not doing so bad...
- CJefferson 14y agoNo, RMS's stance of plugins does make adding C++11 features to gcc much harder. I have a (basic) understand of clang, which is helped by the fact that there is a very clear, simple and DOCUMENTED boundary into LLVM, which I can ignore the other side of. The interface between gcc front ends and backends is none of clear, simple or documented.
- gsg 14y agoAre you suggesting that C++11 support would be implemented as a plugin, rather than by modifying the existing C++ front end? I'm not sure how seriously to take that.
- CJefferson 14y agoNo, I'm suggesting that understanding and modifying the C++ front end is much easier when the output the front-end produces is in well defined and documented output, rather than the ad-hoc and undocumented results of a gcc front-end.
- 14y ago
- yuushi 14y agoIt doesn't matter, optimized or not, the amount of work this entails is ridiculous. Writing a C++11 compiler requires intimate knowledge of the standard (which is a massive, hard to read tome), implementing pretty much all of the standard library from the ground up, and honestly, good luck writing all of that - that's all the containers (set, vector, list, map, unordered_map, multimap, unordered_multimap, forward_list, stack, deque, tuple), algorithms, time and regex libraries (chrono and regex), threading and thread models, type_traits and so on (actually, I just realized, they have it listed on the right hand side). Honestly, it's worded very poorly. "Compliant with the latest 2011 standard (C++11)" suggests all of this. I have a hard time believing this isn't some kind of joke - there's literally no-one alive that could write all of this in the timeframe of a course.
- Locke1689 14y agoNot only that, but the dragon book is terrible. To quote my adviser, "writing a parser from scratch has no value except as a character building exercise." Anyone who wanted to write their own parser should probably just use a packrat parser (I find it much simpler). Whoever is organizing this course, frankly, is either way out of their depth or holds their 1985 compilers course in far too high esteem.
- wglb 14y agoI disagree about the Dragon book. In particular, the code generation part was very valuable to me in the code generator. But I think I see where you are going with this. Using a parser generator for compiling, in the words of Dave Conroy (author of MicroEmacs and many other things), "A Parser Generator makes the hard part harder and the easy part easier." Edit: Wait--1985? Ah, that is the problem. I used the First dragon book, not the second. I only got the second after I did the compiler work. Was it much worse than the first?
- Locke1689 14y agoNo, even the second edition is hugely out of date. First, note that basically the first half of the book is about parser implementation. Then, it basically just teaches you that there's only one parser and it's called LALR. Of course, they didn't include anything like packrat, but even worse, they pretend like a LALR generator is still better than LR, even though LR was extended to be tractable for large grammars years ago. And even with all that, it's far too high level to be of use in actually engineering a compiler (which, by the way, is a good intro book).
- wglb 14y agoI beg to disagree. For something as complex as C++, writing the preprocessor, the parser, and the code generator is very much beyond a man year.
- niggler 14y agoI wasn't saying that it would take a year or even a few years. I was merely saying that most of the effort in gcc/msvc was related to things like optimizing and maintaining multiple architectures. A simple compliant C compiler that only targets x86_64 and performs no optimization, for example, would be much smaller than GCC.
- wglb 14y agoUnclear to me if that is really the case.
- JoachimSchipper 14y agoConsider tcc, which is indeed much simpler than gcc.
- wglb 14y agoAh, yes. I was still thinking C++ as the discussion seemed to slip over to simple C.
- mossplix 14y agothere are parser generators .. you dont have to build one from scratch
- wglb 14y agoAs noted elsewhere, these usually make the hard part harder. The other part of the issue is building the internal representation so that halfway decent code can be generated, not even thinking about optimization. And, like the syntax and grammar of the language, the semantics of C++ are quite complex.
- pandaman 14y agoIt's kinda like saying that most of the legwork in space exploration goes into space ships and mission logistics so just building a dumb launcher rocket is far more tractable problem. Indeed, building Saturn V is nothing compared to flying men to the Moon and back. Does not mean you can build a Saturn V from scratch. And people who are promising to teach you how either are geniuses or just in denial.
- CJefferson 14y agoLook at clang. In this case they already had, and continue to use, LLVM, so their only job is to turn C++11 into a bytecode, in any way possible. It has still taken a number of the best C++ programmers and compiler designers years to accomplish, and they haven't finished yet.
- damian2000 14y agoThis is a massive undertaking, but the fact you are starting with no baggage from existing systems and don't need to optimise might be some consolation. Assume you're also free to study other compiler designs prior to the course.
- deleted 14y ago[deleted]
- qznc 14y agoAs far as I know, Walter Bright is the only person on this planet who could maybe claim to have written a C++ compiler all by himself [0], though I cannot find an original quote from him. [0] http://www8.cs.umu.se/~isak/snippets/mem.txt http://www8.cs.umu.se/~isak/snippets/mem.txt