Modern C++ can be confusing
theregister.co.uk/2009/05/07/verity_stob_cplu...Posted May 7, 2009, 1:40 PM UTC
Posted May 7, 2009, 1:40 PM UTC
Ah, good old Verity. Who everyone always assumes to be a male, because she is writing about COMPUTERS, which women are not allowed use. :)
Everyone on the interweb are male until proven otherwise
The Internet:
(Edit: fucking assmonger whore pidgeonfucker shitgargler markdown syntax)
Upvoted for assmonger
Wait, doesn't 200A == 8202?
only the last digit is hex.
How can you tell?
By the pixels, and having read many language standards in my time.
When I first read that, I thought you used the term 'By the pixels!' like 'By the gods!'. In fact, I believe I'm going to use that phrase from now on.
C++ confusing, that's unpossible!
So the guy doesn't like the language and doesn't understand why you need rvalue references or the value of auto or lambdas.
Clearly the author hasn't had to deal with the pain of needlessly slow copy vs. move semantics nor has he had to program with the STL for which the auto syntax for iterators is a godsend.
Stop bitching about what you don't understand, and just take the time to try to understand it. Some times, its there for a really good reason.
I've been bitten by each of these issues, and others, like defined semantics for what 'happens before' means for threaded programs, which are all being addressed by this grandiose perl 6/ecmascript 4/python 3000 of a standard.
The alternative uses of 'auto' come from the fact that they don't dare add keywords to the language. So every new language feature they want has to be worked into the existing grammar somehow. And auto has been sitting around useless for decades. If you don't like it, please, provide an alternative color to paint the bikeshed and drag the process out further.
Languages evolve to meet the needs of their users. Evolve with them or use something else.
Don't mock Verity. I rather think she understands these issues very well.
Very well. I didn't notice quite how deeply her tongue was embedded in her cheek, which is slightly clearer in retrospect and upon reflection on the rest of her writings, but it reeked enough of the "C++ is hard, lets go shopping!" mindset to set me off. I'll go slink off to a support meeting for the humor-impaired now.
I'm staggered. Where's the deeply offended, incoherent rant in return to my snarky reply? Where's the revisionism, comment-editing and general weaselling out?
Are you from some strange, parallel internet which has somehow crossed over to ours after an ill-advised experiment with a tachyon-based wave division multiplexor? What is 4chan like on your world?
I'm not sure about 4chan, but I do have some facts from his world that might give you a hint:
Star Trek, in his world, doesn't have the term "Heisenberg Compensator" and the polarity was only reversed once, to no useful effect.
He never saw Star Wars I-III because all Lucas could come up with as a script for 'The Phantom Menace' was kiddie trash that he didn't think would do the originals justice.
Firefly is in its eighth season, and is good enough to warrant the fanatical interest we see here.
The Matrix series concluded with a resounding philosophical tour-de-force that was the first movie ever rated R because it raised questions too powerful for 13 year old minds.
4chan is home to friendly and helpful people from all faces of life. Nobody actually cares who you are, only how your point is represented. In fact, those who attempt to make a name for oneself are usually just mocked.
I don't want to know about the 4chan on your world.
Reading that GIRL's past pieces might help; it's intentionally playful.
Clearly the author hasn't had to deal with the pain of needlessly slow copy vs. move semantics nor has he had to program with the STL for which the auto syntax for iterators is a godsend.
Languages evolve to meet the needs of their users. Evolve with them or use something else.
Too true. Some day, I hope C++ will have evolved enough features that a decent basic standard library can be finally be written for it.
Clearly the author hasn't had to deal with the pain of needlessly slow copy vs. move semantics nor has he had to program with the STL for which the auto syntax for iterators is a godsend.
Worth the wait by itself.
re: int* p = nullptr;
Anyone know whether you're still allowed to use 0? 0 is a nice iconic thing, instantly digestible with the right brain. nullptr you have to take time to read.
-- edit: duh, yes, it has to be backwards compatible. Also, wikipedia says 0 is still ok :)
The author was joking around. The real point of nullptr is because 0 is assumed to be type "int" if no other information is available whereas nullptr is assumed to be a pointer. So its real use is as a parameter to overloaded operators and similar inferred type situations.
For when (void)0* is just too obfuscated.
Oh, right, C++1998 already borked that part of the syntax. Of course I meant *static_cast<void>(0)**.
Is the int i = {}; correct? Seems pretty wierd.
You've always been able to do that with structs. It's just an extension of existing syntax.
What? Why would I want to do that? That is completely mad. What is that, some politically correct adaptation of C++ for left-handed programmers or something? If I wanted to do that, I would code in Pascal.
Pure comedic gold.
Who else thought that was a pretty good C++0x tutorial?
if by "a pretty good C++0x tutorial" you mean "a tutorial that skimmed through half the syntactic features
s/Modern // and s/can be/is/.
s/Camarade_Tux//
(btw i think he's saying "go away")
Oh, I did, I had to buy some food.
Someone should just tell them to leave it alone.
C++: the malignant tumor of programming languages?
C++: the Cthulhu of programming languages.
C++: or the puppy dies.
unthinking, indeed.
C++0x is a large quantity of sugar coating horseshit. It adds a lot of new syntax to remember but has nothing new to give when it comes to paradigm and libraries. Fuck that shit already, I'd rather program in Lisp than read someone else's C++0x code in the future, and I am not a Lisp fanboy. At least Lisp doesn't require tons of new syntax everytime you want to do something new with it. Considering the fact that you can add object orientation with just macros.
As a programmer, I'd rather learn new language paradigms than learn new syntax for stuff I already know. A language that adds a lot of new complexity without making you think thoughts that you couldn't possibly have before is worthless.
but has nothing new to give when it comes to paradigm and libraries.
Out of curiosity, what additional paradigms do you think C++ should support?
OK, here's a partial summary of new features in C++.
New library features:
thread local storage (thread_local)
flexible function objects (std::function)
threading facilities (std::thread, std::mutex, std::condition_variable)
regular expressions
extensible random number generator library
tuples
hash tables
New paradigm:
There's a lot of new library features -- perhaps not as high-level as libraries provided by .NET and Java, but these are still new to (and greatly needed by) standard C++.
There aren't very many new paradigms added to C++. But C++ was already a multi-paradigm language to begin with. (Procedural, Object-Orientated, Generics/Templates). With lambdas, the only major paradigms missing are reflection and (non-lambda) functional programming. Reflection requires extra space and goes against the C++ concept of paying for what you don't use. Modifying C++ to use functional programming would make C++ unrecognizable. I'm pretty happy with the paradigms supported by C++0x.
Personally I think C++ should die a grizzly death given all the pain, insecurity, nosebleeds and dementia it has caused. But since you asked, it's lacking in useful Smalltalk/Objective C object-oriented paradigms:
Frankly instead of the next version of C++ encompassing even more paradigms under its enormous umbrella, I'd rather have a sane replacement language that adopts the "good things" about C++ to use in the situations where C++ is still the best or only option.
Being able to override class (static) methods in subclasses
That's the name of a paradigm? :)
[deleted]
Too bad C++ will be around for a long long time.
You didn't understand what I said, did you ? C++0x doesn't add anything that I wouldn't know how to do in another language. That is, it doesn't bring anything new to the table, only to its own table.
Func objects, regexp, tuples, hash tables, lambda ? come on. It's only new for someone who spent his life on C++ and nothing else. C++ is not worth being bothering with because it doesn't open your mind to new paradigms, it's only tainting the existing ones with its stench.
I just think that a language that doesn't bring anything, absolutely anything new to the table is worthless, particularly if it has so many syntactic and grammatical rules that no one can truly understand and parse it.
C lets you shoot yourself in the foot, C++ lets you reuse the bullet!
... And it blows off your entire leg.
Whether or not the language's creator actually said that, I don't know. I believe it though, he seems to be able to take criticism.
Incidentally, Stob makes a reference to it in an older article.
APL: You hear a gunshot, and there's a hole in your foot, but you don't know enough linear algebra to work out what the hell happened.
[deleted]
That in itself makes me want to learn it.
Learn D :) It doesn't exactly make the fusion reaction any safer, but it does give you doc-ock style arms to deal with it. Furthermore, syntax that doesn't make your eyes bleed! Um. Wrapped in some joke about guns and feet. Yeah.
Also, in C++ you can shoot each human's foot in a different way.
I would call myself fairly C++ knowledgeable and i use it often for user mode programming. But once i had to debug someone else's code written in C++ and following were my horrors:
After this C++ experience, i became quite anit-complex-C++. I like some of the features it provides like data abstraction using classes etc but it is becoming increasingly complex.
For myself i only use following C++ features:
The things i avoid like anything are:
And yeah, if you really want to know how twisted C++ can be, read Effective C++ series. After reading that i realized how complex C++ can get and how to never get in that trap.
Hmmm, not well thought-out...
nested templates are largely (completely?) avoidable with typedefs. STL uses does that approach nicely.
operator overloading - how else except exceptions do you propose overloaded operator signal errors? Also see 3.
there's no C++ without exceptions. How come anyone fails to see that? First, per standard, operator new can throw. What can you do about that but handle exceptions? Second, STL can't work correctly without exceptions (most notably, without a throw from operator new). Third, string1+string2 can't work correctly without exceptions.
see 1.
I agree that people abuse operator overloading, though. But should we throw baby out with the water?
If one wants to criticize C++, point 0 is compatibility with C. But that's a both blessing and a curse. And if you look carefully, any C++ design decision or a wart is that.
:2. lost's point was that it's impossible to distinguish regular built-in + from overloaded operator+ without having a complete understanding of the entire translation unit (remembering that the declaration of operator+ might have come from a header file or even a clever macro expansion, so grep won't solve all your problems). He didn't start complaining about exception handling per se until point 3.
:3. C++ works just fine without exceptions, for the same reason that C works fine without exceptions. In no-exceptions mode, operator new typically returns NULL to indicate failure (just like malloc in C). You're right that out-of-memory conditions are hard to handle without exceptions, but they're not much easier to handle with exceptions, either. Have you ever had the runtime run out of memory while trying to allocate an object of type std::bad_alloc? :)
Exception handling also complicates the control flow and makes it effectively impossible to write correct code. See Tom Cargill's "Exception Handling: A False Sense of Security".
Argh. Reddit's markdown will turn "2." into "1." if it comes at the start of a paragraph. Stupid markdown. Remind me again why Reddit doesn't use HTML like the rest of the Web?
How so? Exceptions are his complaint. Look:
But the answer to that is simple: he's doing it wrong. He should have started from "+ here? that can throw" (I have a long hard explanation, I'll dig it up if you'd like).
Never tried to. You mean on the heap? That's a clear-cut no-no. If it's not that... Your C++ runtime doesn't handle this case? Change it. It's not a hard problem, really: bad_alloc's message is a literal somewhere in the library, and you don't try to create one with your own text (a clear-cut no-no, too).
You are also wrong about operator new, NULL and no-exceptions mode. Standard library throws, so you at least have to rig operator new yourself. But then none of STL containters or std::string don't work correctly. That's for sure not how I'd like to work.
And... I know about Cargill's paper and I know he's wrong (it's up to discussion, and I really do have all the answers).
BTW, look a the date of it. Things have changed since.
Edit: markown. Arhg, just like you say.
C lets you shoot yourself in the foot, C++ lets you reuse the bullet, C++0x lets you foot yourself in the shoot. Er, chute.
no, that's forth
C++0x lets you auto yourself in the foot -> shoot.
[deleted]