4 ms·
I agree with you. If you can't get the job done using mostly that language described in the Brown Book (C++ Annotated Reference Manual by B. Stroustrup and Marg
by kazinator 10y ago
I agree with you. If you can't get the job done using mostly that language described in the Brown Book (C++ Annotated Reference Manual by B. Stroustrup and Margaret Ellis), plus a judicious smattering of some newer C++ ranging from C++98..C++03 (at most), you should fucking retire.
The last useful change in C++ was (circa 2006?) making string literals const. That's it.
- andrepd 10y agoOh brother... What about: lambdas, type inference, tuples, robust templates, compile time constants and code execution, move semantics, expanded PoD, initializer lists, range based for loops, user literals, return type deduction... I could go on and on. All features I use daily. And I'm not even getting into C++17.
- kazinator 10y agoHalf-broken, bolted-on garbage that is found in a much nicer form in high level languages which have those things in their core vision from the beginning, or the kind of extensibility which can cleanly support new ideas. > And I'm not even getting into C++17. I'm with you there, in a way.
- matthewaveryusa 10y agoI don't find auto, lambda, and variadic templates, move semantics and smart pointers to be bolted on. You can write Fortran in any language.
- Retra 10y agoYou think rvalue references are a natural and elegant construct? That if C++ were designed with move semantics in mind, this is the road they would have travelled down?
- kinghajj 10y agoThat's the biggest reason that I like Rust more than C++, even more than lifetime/safety. I've been working on a C++14 application, and "std::move" shows up a lot more than implicit copies, which not only makes the code more verbose, but analyzing performance more difficult. (I so wish I could be using Rust, but, unfortunately, the only FOSS DNP3 implementation is in C++.)
- andrepd 10y agoPlease show me the "nice" and "well thought" and "elegant" and "modern" language with the sheer amount of resources, documentation and momentum that C++ has? It's not going to go away for the foreseeable future, even if slightly better options arise (notice the slightly, no language has substantially improved on C++ in a meaningful enough way to make the benefits of migrating greater than the headaches).
- kazinator 10y agoHere is another thing: each time they add this or that cruft to C++, the syntax for that tidbit has to go into the hard-coded grammar. For the past 30 years, they have been missing opportunity after opportunity to somehow make the language internally extensible, so that new rules don't have to be added any more to a hard-coded parser (but, say, defined by C++ programs themselves). So now, check this out, GNU C++ has a hand-written recursive-descent parser ... that is 1195625 characters of C. It's almost 40K lines just to scan some tokens and get an abstract syntax tree. https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/cp https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/cp
- smallnamespace 10y agoAt this point, is there any parser out there that could deal with C++'s grammar? What you're suggesting is tantamount to throwing out C++'s current syntax, which will never happen, or taking the existing parser and making it even more complicated so that it supports extensions.
- gpderetta 10y agoIIRC g++ had historically a machine generated parser (bison maybe?) But it got replaced around 3.0 time because the new hand written parser was faster and more maintainable.
- kazinator 10y agoI think, you cannot beat beats shift-reduce LALR(1) with recursive descent on raw performance on a reasonable syntax. However, parsing C++ with LALR(1) will require unmaintainable hacks in the grammar. Recursive descent accomodates ad-hoc fudging much better than parser generation. In any given rule, you can look ahead as much as you want and invoke any Turing computation to decide the parse. Also, recursive descent approaches support backtracking fairly naturally: try it this way, as far ahead as necessary, or else start again, falling back on this. Let's see ... 28374 /* Commit to the currently active tentative parse. */ 28375 28376 static void 28377 cp_parser_commit_to_tentative_parse (cp_parser* parser) 28378 { 28379 cp_parser_context *context; 28380 cp_lexer *lexer; 28381 28382 /* Mark all of the levels as committed. */ 28383 lexer = parser->lexer; 28384 for (context = parser->context; context->next; context = context->next) 28385 { 28386 if (context->status == CP_PARSER_STATUS_KIND_COMMITTED) 28387 break; 28388 context->status = CP_PARSER_STATUS_KIND_COMMITTED; 28389 while (!cp_lexer_saving_tokens (lexer)) 28390 lexer = lexer->next; 28391 cp_lexer_commit_tokens (lexer); 28392 } 28393 } Bison supports GLR ("generalized LR") via some technique of forking the parser and trying alternatives in parallel, which seems related to this.