LWN.net Logo

Re: Will therefore GDB utilize C++? Not.

Re: Will therefore GDB utilize C++? Not.

Posted Apr 15, 2012 12:27 UTC (Sun) by jwakely (subscriber, #60262)
In reply to: Re: Will therefore GDB utilize C++? Not. by jzbiciak
Parent article: Re: Will therefore GDB utilize C++? Not.

> It also demonstrates what talented hackers can achieve with mechanisms that were never intended to be used this way.

But those clever hackers influenced the future direction of the language, making metaprogramming an integral part that _is_ intended to be used that way now, so C++11 provides variadic templates and extended SFINAE and cleans up a number of warts, all making the mechanisms more regular and more powerful. (Which may well make some people like C++ even less, but noone forces you to use those features, they're there for library authors to simplify writing the kind of libraries found in Boost.)

> It's a cute and useful hack when it works, but anyone who's looked at three pages of error-spaghetti when they make a 1-character typo understands that it's incredibly fragile.

Things should (I hope) improve. The ability for library authors to remove functions from overload resolution (à la enable_if) are a sort of "concepts-lite" that can prevent cascade of unrelated errors, static assertions can reduce an invalid instantiation to a single error. Library writers have more tools available to make more robust template libraries with more user-friendly failure modes. And compilers can do more to help too.


(Log in to post comments)

Re: Will therefore GDB utilize C++? Not.

Posted Apr 15, 2012 14:20 UTC (Sun) by jzbiciak (✭ supporter ✭, #5246) [Link]

Hopefully things will improve. But, for much of the C++ I write (on an embedded DSP, or on an embedded ARM using an outdated version of RVCT), C++11 will remain a fairy tale for some time. I don't expect to be able to write a lambda expression on either for another few years at a minimum.

But those clever hackers influenced the future direction of the language, making metaprogramming an integral part that _is_ intended to be used that way now, so C++11 provides variadic templates and extended SFINAE and cleans up a number of warts, all making the mechanisms more regular and more powerful.

It will remain true, though, that they had to fit within the existing C++ framework, and not break (too much) existing C++ code. If you were to design a powerful metaprogramming language to overlay onto a C++-like language from scratch, would it look like C++11? (Say, start with C++ of a few years ago, subtract whatever you like, and then add a proper metaprogramming environment of your own design.) There is some ugliness in C++ that can't be deprecated without breaking compatibility with C++ as it is.

Scott Myers' books are invaluable for understanding the best ways to use these features, IMHO. C++ definitely gives you more than enough rope to let you shoot yourself in the foot. In fact, it can take your whole leg off while you trip over it.

Re: Will therefore GDB utilize C++? Not.

Posted Apr 16, 2012 11:58 UTC (Mon) by jwakely (subscriber, #60262) [Link]

It might look like Vandevoorde's Metacode, but that stalled
http://www.vandevoorde.com/Daveed/News/Archives/000015.html

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds