a three lines program generates 95 lines of error messages; let's throw a template into it, so that it goes up to 112 lines, but look: at the beginning you'll see the error we added!
coupled with the: "To be fair, this doesn't entirely replace decltype. auto doesn't perfect forward. But it seems to work as expected, most of the time" it goes a great way to instil me a sense of safety.
not.
that post should be taken as an example of why C++ has become a liability, and the day won't come too soon when this joke on the whole industry finally gets dumped like COBOL in the nearest ditch, along with the corpses of all the projects that made the mistake of actually using it.
if it were a living thing, I'd shoot C++ in the face to put it out of its misery.
I don't get all this C++ hate from people that has never even used it.
Personally I want a better C and C++ satisfies most of what I want.
1. Type level polymorphism (generics/templates/etc)
2. Easier ways to manage memory (constructors/destructors, auto/shared pointers)
3. A modules system (namespaces)
4. Lambdas, etc to make life easier (C++11)
5. A standard library with useful data structures
6. Fast
It seems all to me all these haters still think that C++ is just C with classes, but C++ is a fairly vast language and OOP is just a small part.
C++ is blazing fast, it has an elegant standard library and templates do make sense if you know what you are doing.
You are trying to use cutting edge features that aren't properly standardised yet and complain that the error message is a bit long? Granted, template error messages aren't always the one liner you are expecting, but they are readable.
> a three lines program generates 95 lines of error messages; let's throw a template into it, so that it goes up to 112 lines, but look: at the beginning you'll see the error we added!
95 lines of error messages sounds terrible, no doubt. But which language is better in the real world? I am currently consuming a JSON web service written in Java, and I get no less than 30kb of stack trace back when something blows up. Rails' stack traces are filtered by default, but sometimes you still have to jump in there.
And C++ has the advantage that much of this can happen at compile-time.
I agree that almost everything about C++ is broken, but the verbosity of error messages is the smallest of it IMHO.
I read that blog a bit and it seems to have the following pattern overall: elegant 5-line Haskell program. Then follows 100-line unreadable C++ implementation.
My conclusion is that C++ is a very bad language to try to do Haskell :-)
This doesn't mean that C++ doesn't have its uses, but for your sanity's sake don't use it for high-level metaprogramming.
The issue you describe is more a compiler-specific issue than a language specific issue. Yes, the language allows a lot of flexibility and therefor in some situations it's hard to nail down an error to a nice, specific error message (mostly when templates are involved), but it's not impossible, as clang++ shows.
Believe it or not, there are people (like me) who actually enjoy coding in C++.
What many people don't understand is that C++ has at least two target audiences: (1) people writing low level libraries using templates and other esoteric stuff; and (2) people writing application code. (1) is needed because C++ is a language that can target multiple environments and operating systems. The template craziness is necessary to make the system fast and easy to use for application developers. If you are writing applications, however, you should try to use only bread and butter features, along with standard libraries such as STL and semi-standard stuff like Qt. Once you understand this, your life will be much easier with C++.
I was just about to make a similar comment. There isn't much about C++98 I don't know, but having ignored C++11 for too long I feel utterly lost looking at stuff like this now.
What concerns me even more is that it must be pretty much impossible for a beginner to pick up C++ today.
You know when you get in a really fancy sports car and sit down and look at the console and go "What the fuck?" as your brain tries to parse the myriad of options relating to everything that are usually highly non-intuitive and often buried under many layers of cruft and you need to sit and read the manual that's as thick as a phone book? That's kind of what C++ is getting towards.
There's a simple solution, don't touch all the fancy and extreme language features, use the core, keep your sanity. I code in C++ professionally using Qt, the last time I wrote any code using anything overly fancy was probably when I was in University. It's often not needed, it's guaranteed to make your code base a nightmare, and it's usually horrid to read back over. If you're sensible and put some constraints on what you're doing C++ is a great language choice, but often people stray into using all these areas of C++ that basically make the code an unmaintainable mess.
(note, defining core as the things guaranteed to work on 95%+ of current compilers, if it's non-standard I would really, really thing twice about using it)
Coverity, maker of c++ static analysis software, and where I used to work, has published a paper about their experience trying to parse customer code. It turns out that 'The language people code in? The strings their compiler accepts'
So yes, it is quite common to use syntax not available in other compilers. Most code is vetted against only one compiler to begin with.
This particular feature isn't offered by anyone else, so I would not write a program with it and force anyone else who wanted to compile the code to use an unsupported, bleeding edge version of GCC. But I /will/ create a branch of a project or two, using this auto deduction, and send bug reports back if necessary.
I, and many others, have been writing code in Clang and GCC for years that could not be compiled in MSVC. But that code was standard c++11. This is experimental and people should be aware of that while using it.
In my (limited) experience, it is not that popular, compared to the use of semantics not available elsewhere (is char signed? Can you cast a void* to int and back without data loss? What happens when you right shift a signed int? etc) and to the extreme use of third party libraries (why the #%$! do I need that GUI library in this json parser? Half an hour later: oh, so it is only for these three typedefs, a few macros, and this convenience debugging function), but it surely does happen.
I also think programmers do regret the decision. Unfortunately, that is unlikely to change, as the programmers regretting the decision almost always are not the ones who wrote the software. It is way rarer for a code base to move compilers within a project/team than for a team wanting to incorporate a third party library into their codebase/compiler.
It depends on your environment. If you completely control all the environments your application is deployed in (for example, when you provide a SaaS), it's fairly common.
I wonder how many times programmers are even aware that they're using syntax not available in other compilers. I remember the first time I used a non-gcc C compiler and was greatly surprised that things I'd taken for granted and simply assumed was 'C' didn't work.
[+] [-] ebassi|13 years ago|reply
coupled with the: "To be fair, this doesn't entirely replace decltype. auto doesn't perfect forward. But it seems to work as expected, most of the time" it goes a great way to instil me a sense of safety.
not.
that post should be taken as an example of why C++ has become a liability, and the day won't come too soon when this joke on the whole industry finally gets dumped like COBOL in the nearest ditch, along with the corpses of all the projects that made the mistake of actually using it.
if it were a living thing, I'd shoot C++ in the face to put it out of its misery.
[+] [-] verroq|13 years ago|reply
Personally I want a better C and C++ satisfies most of what I want.
It seems all to me all these haters still think that C++ is just C with classes, but C++ is a fairly vast language and OOP is just a small part.C++ is blazing fast, it has an elegant standard library and templates do make sense if you know what you are doing.
You are trying to use cutting edge features that aren't properly standardised yet and complain that the error message is a bit long? Granted, template error messages aren't always the one liner you are expecting, but they are readable.
[+] [-] gurkendoktor|13 years ago|reply
95 lines of error messages sounds terrible, no doubt. But which language is better in the real world? I am currently consuming a JSON web service written in Java, and I get no less than 30kb of stack trace back when something blows up. Rails' stack traces are filtered by default, but sometimes you still have to jump in there.
And C++ has the advantage that much of this can happen at compile-time.
I agree that almost everything about C++ is broken, but the verbosity of error messages is the smallest of it IMHO.
[+] [-] wladimir|13 years ago|reply
This doesn't mean that C++ doesn't have its uses, but for your sanity's sake don't use it for high-level metaprogramming.
[+] [-] stingraycharles|13 years ago|reply
Believe it or not, there are people (like me) who actually enjoy coding in C++.
[+] [-] shin_lao|13 years ago|reply
Feel free to shoot C++ in the face. Don't forget to rewrite most of compilers and operating systems in use in the process.
[+] [-] neumann_alfred|13 years ago|reply
You mean stuff like Unreal Engine... ?
[+] [-] coliveira|13 years ago|reply
[+] [-] indeyets|13 years ago|reply
How many years would you give it to stay ubiquitous? I bet on 15 years
[+] [-] udp|13 years ago|reply
What concerns me even more is that it must be pretty much impossible for a beginner to pick up C++ today.
[+] [-] pjmlp|13 years ago|reply
[+] [-] nicholassmith|13 years ago|reply
There's a simple solution, don't touch all the fancy and extreme language features, use the core, keep your sanity. I code in C++ professionally using Qt, the last time I wrote any code using anything overly fancy was probably when I was in University. It's often not needed, it's guaranteed to make your code base a nightmare, and it's usually horrid to read back over. If you're sensible and put some constraints on what you're doing C++ is a great language choice, but often people stray into using all these areas of C++ that basically make the code an unmaintainable mess.
(note, defining core as the things guaranteed to work on 95%+ of current compilers, if it's non-standard I would really, really thing twice about using it)
[+] [-] kombine|13 years ago|reply
[+] [-] unknown|13 years ago|reply
[deleted]
[+] [-] rbanffy|13 years ago|reply
[+] [-] mdonohue|13 years ago|reply
So yes, it is quite common to use syntax not available in other compilers. Most code is vetted against only one compiler to begin with.
http://www.stanford.edu/~engler/BLOC-coverity.pdf
[+] [-] splinterofchaos|13 years ago|reply
I, and many others, have been writing code in Clang and GCC for years that could not be compiled in MSVC. But that code was standard c++11. This is experimental and people should be aware of that while using it.
[+] [-] Someone|13 years ago|reply
I also think programmers do regret the decision. Unfortunately, that is unlikely to change, as the programmers regretting the decision almost always are not the ones who wrote the software. It is way rarer for a code base to move compilers within a project/team than for a team wanting to incorporate a third party library into their codebase/compiler.
[+] [-] stingraycharles|13 years ago|reply
[+] [-] dagw|13 years ago|reply