Bjarne Stroustrup Reflects On 25 Years of C++
eldavojohn writes "Today roughly marks C++'s first release 25 years ago when about six years of Bjarne Stroustrop's life came to fruition in the now pervasive replacement language for C. It achieved ISO standardization in 1998 and its creator regularly receives accolades. Wired's short interview contains some nice anecdotes including 'If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it' and 'I'll just note that I consider the idea of one language, one programming tool, as the one and only best tool for everyone and for every problem infantile. If someone claims to have the perfect language he is either a fool or a salesman or both.' There's some surprising revelations in here, too, as his portable computer runs Windows."
C++ is to C as Lung Cancer is to Lung.
Truer words have never been spoken.
For some reason, I read that as "Bjarne Stroustrup Comments On 25 Years of C++".
// I had a reply all set to go...
No, no. You're thinking of C#!
My first language and I wish my only. I don't know if it is because it was my first, but it's the only one that I feel like can accomplish everything I need in a very logical and clean fashion. Java comes close because it feels close, but the extra layer of syntax pisses me off. Anyways, I remember the project in high school that I was working on when it clicked in my mind as a language I can read rather than a bunch of mumbojumbo that I had to try to interpret. Thank you, recursive merge sort project.
And if anyone thinks C++ is the perfect language they're an idiot.
Only 25 years? When I was in college, we learned C. No "plus plus", no "objective", no "sharp"... just "C".
Aye, as a matter of fact, I am feeling than a wee bit like Scotty in the TNG episode "Relics".
http://alternatives.rzero.com/
For job security, that is, would be C++ modules glued together with Perl.
I've got a headache just typing this post.
Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
They why make a not-really-object-oriented language that seems to be the result of you getting really high and having programmer's munchies -- throwing in every single feature you could think up, no matter whether it fit or was redundant? Why not create something cleaner and with some sense of purpose and editorial discretion?
I know he said it in jest, but the devices wouldn't have had any C++ in them at all. Only binaries, generated by assemblers, which took output from the C++ compiler. :) A couple layers of abstraction away is all...
Better known as 318230.
I've been writing C++ for 20 of those years and produced an awful lot of performance critical systems code in that time. To this day I find it the most liberating language, whatever is in your mind, you can express it, without the language compromising your intent. I can't see myself moving on until D becomes mainstream, and that may not be before I retire in ten years. I check out all the pretenders as they come and go, nothing else comes close.
Yay, happy birthday, my favorite language :)
Sometimes, it is more important to have the right problem than the best solution.
This is certainly true in more ways than he intended. C++ is as awful as it is useful: Extremely. I will remember this quote next time I have to make an implementation recommendation: "C++ is the right problem for this job." Fucking terrible syntax, loaded with gotchas, requires inordinate amount of expertise to avoid subtle errors--and utterly indispensable when a high-performance general purpose programming language is needed.
C++ FQA (frequently questioned answers)
(Defective C++ is a summary)
'There are only two things wrong with C++: The initial concept and the implementation' - and other quotes
Why C++ sucks
And, previsibly: http://cplusplussucks.com/
C++ - the language which everyone loves to hate. Every time there is a story posted about it on /. (or any other technical forum), you see all kinds of posts ranting about how crappy it is, how Objective-C (or whatever is the fad of the day) is so much better etc.
And yet - it is still the language in which most desktop software and games are written to this day, and this doesn't show the signs of changing. Not only that, but some of the biggest and most prominent FOSS projects - Firefox, OpenOffice, KDE - are written in it.
Ever wondered why?
Doom was written in C, not C++.
+0 Meh
Videogames like Doom, ...
Correct me if I am wrong, but I am pretty sure the first Doom was written in C.
trollface.jpg
I'm sure "SlashdotMedia" will improve on all the wonders that Dice Holdings blessed us all with
Alan Kay said "Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind."
C++ seems like an awful stopgap solution that got out of control.
So that's exaggerating a bit, but even if I enjoyed writing some C++ programs, I still find it hard to dive into C++ source code and understanding what it does.
For example... If you're reading a piece of C code and see a function call, you can find the function definition with a simple textual search. With C++ you have to look at the argument types (due to function overloading), you have to check what the object type due to derived classes, etc. What a mess it is just to find out precisely what code is behind a function call.
It's really a pain in the ass to read C++ code that you haven't written (or maybe even that you wrote some months ago).
The AACS key is NOT 0xF606EEFD628B1CA427BEA93A9CA9773F
That statement works as both a positive idea and as a negative one.
The positive being the more capable you are the more time you put in.
The negative being the trend towards techno dogmatism among programmers.
Programmers tend to be afraid of technology they are not used to, so everything that isn't their core thing tends to be labeled as "crap".
I would love to learn more languages........time!
I think I'd actually like the language if it didn't try to do so much.
Adding classes to C was great. Operator overloads are really useful, virtual functions mean you can frequently avoid C's rather cryptic function pointer syntax. There are so many clever tricks you can do with scoping that makes C++ extremely useful.
After that things start to get a bit nasty. Template programming seems like such a nice idea, but it's so cryptic, and totally unreadable - and why use the triangular brackets!? . The syntax to differentiate pre and post increment seems completely arbitrary, and the headaches caused by multiple inheritance and default parameters make me wonder if they're really worth the trouble. The try/catch construct is also useful but it feels so unwieldy.
I can't stand C++, it's all but unreadable to me.
That's because just about every C++ coder wants to be the guru (and maybe find the error that gets the $2 check from Bjarne - I actually saw one and the guy who got it framed it!) so, what do they do? Ever frick'in chance they get, they have to use some esoteric feature of the language in their development regardless if it's appropriate - I've done it too. For example, how many of you fellow C++ guys made a template class even though the class would only deal with one data type for ever and ever and ever? Or overloaded an operator just for the sake of overloading it - operator overloading back in my day was the most over used and abused feature in C++.
When I got over the guru thing, I always tried to keep my code well documented and used features sparingly.
For the record, templates can be awesome such as when using the STL - that saved so much grunt work!
RIP America
July 4, 1776 - September 11, 2001
Does Bjarne Stroustrop think of women as objects?
"Trademarks are the heraldry of the new feudalism."
When was this written, 1978? "Portable computers" are called laptops or netbooks.
I do believe that anyone that claims to actually like working with C or C++ is either
1) Unfamiliar with any languages that don't let you shoot yourself in the face so easily.
2) More like a machine than a man.
3) Trying to show off his "hacking skillz".
4) Being overly nostalgic.
5) Hasn't actually used C or C++ in about a decade.
IMHO using C or C++ when not necessary displays a depressing amount of machismo and masochism. Why do it to yourself?
First there was the "red" album: straightforward rock-n-roll with some interesting wordplay, but with only a few general themes. C++ was the same way: create some objects, work with 'em, pass 'em around. All good.
Then C++ discovered acid and got into its "blue album" phase: multiple inheritance, templates, operator overloading, namespaces. To read C++ now is like listening to the later Beatles: obtuse, baffling, with a fair amount of brilliance that makes you wonder "how did they do that?????" It confirms that there are always smarter people than me if only to be able to make sense of it all...
Bjarne Stroustrup hated C++! Any day now, C will rise again and be the dominating force!
TFS: "There's some surprising revelations in here, too, as his portable computer runs Windows"
Very well, I am a long-time supporter of FOSS too, but I'll feed your troll: How is BS's use of M-Windows a surprise?
Is it because M-Windows has bad C++ development tools?
Is it because M-Windows is not the dominate OS?
Is it because C++ should only be used in FOSS?
Is it because BS should share your opinions or be damned?
Rich And Stupid is not so bad as Working For Rich And Stupid.
"There's some surprising revelations in here, too, as his portable computer runs Windows."
This is some kind of revelation? The revelation would be if he didn't run any instance of a Windows setup. The submitters bias is being overlayed onto Stroustrup for some reason, but for the sake of the rest of us he should only pose it as his (the submitters) revelation rathar than giving what seems to be a false impression that Stroustrup is anti-windows in some way.
If all you write is C with Classes, you'll get a leaky mess full of crash bugs that you'll never be able to do away with.
But if you write C++ the way C++ wants to be written, it's actually a very easy language to write leak-free, bug free code with. Memory management in particular is very easy with RAII - Resource Allocation Is Initialization. Smart Pointers are RAII applied to heap blocks, but it should be applied to every allocated resource, such as database locks or file handles.
A while back I wrote a style guide that summarizes much of what I know about C++: Pointers, References and Values.
Request your free CD of my piano music.
C++ is successful for one big reason: it provides most of the advantages of C with the conveniences of an object-oriented language. Performance is excellent (close to C, which with a good compiler is close to hand-written assembly in most cases) and there's enough capability that you can write just about anything in it, including things that you would never consider writing in manged languages (like device drivers or the VM for those managed languages).
The problem is that the developers of C++ have trouble saying "no". There are a bunch of C++ features that aren't really necessary, but that exist either out of legacy or because someone thought it would be a good idea.
Look at Google's C++ style guide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Inheritance
Like most users of C++, Google uses a severely restricted subset of the language. The thing is, most of what Google has left out is quite frankly unnecessary for 99.9% of C++ users. But we're all stuck with it anyway.
Once you get past some of the C-legacy anachronisms and restrict C++ to a small subset of its functionality, it's actually a nice language. The problem is that we can't take things out at this point.
Anyone who outright dismisses C++ as a generally bad language to use in any situation is matched in their ignorance only by someone who swears by C++ as the best solution in every situation. I can't imagine keeping a straight face while using the term "engineer" in any capacity to describe a person made uncomfortable by such a powerful language. Ugly? Yep. Stopgap solution that got out of control? Pretty much. The [i]only[/i] language in its class? Yep. Bad C++ code can be very, very bad. Good C++ code is surprisingly elegant and extremely powerful. Its unique mix of expressive features, performance capacity, programmer flexibility and sheer volume of libraries far outweigh any argument about its semantical shortcomings.
It seems appropriate to bring up that C++ was all one big joke: http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html
He runs fast.
--
"Outlook not so good." That magic 8-ball knows everything! I'll ask about Exchange Server next.
I started up with C++ later in my career, and despite the difficulty you face working it, I appreciate the ingenuity it took to create the language in the context it was written. It's not like creating Java or C# with a clean slate and years of experience with the pros and cons of their progenitor on the books. I came to C++ from the Java world and the ubiquity, power, and performance you get with it are well appreciated in my book, though that beautiful bride comes with a dowry of deficiencies.
I swear to God...I swear to God! That is NOT how you treat your human!
What I thoroughly enjoyed as a programmer learning C/C++ in the early 90's was the chance to read Kernighan and Ritchie's The C Programming Language and Stroustrup's The C++ Programming Language cover to cover. Both were literate, well-edited and thankfully free of screen shots (I hate screen shots in "how to" books). Compared to the hundreds of cookbooks and step-by-step guides I've consumed since, these two books educated me in PROGRAMMING in a deep way.
Say what you like about C++ itself, there was an exceptionally lucid mind behind it.
I've never actually read anything written by him. He sounds like some dumb 15 year old high school programmer.
Boggle.
C++ seems kinda kludgy. Until you start writing programs in assembly. After that C++ looks elegant.
"I'm not a quack, I'm a mad scientist! There's a difference." - Dr. Cockroach
ObjectiveC is what C++ and Java were trying to achieve but failed. The C++ books keep getting thicker and thicker to the point that they are increasing in width faster than the speed of light. (this is allowed because they contain no information and consume rather than create energy.) C++ reminds me of the woman in Terry Gilliam's Brazil that kept getting more plastic surgery to correct the mistakes of the last one till she was reduced to goo.
Meanwhile ObjectiveC has stayed lean and effective, while having the major advantages of java available.
try it before you lash out at me.
Some drink at the fountain of knowledge. Others just gargle.
I'm not a programmer in any sense of the term - not even that of a hobbyist, outside of simple bash/python scripts I use to aid my research. I've learned quite a few languages though, and I think learning C++ (university class) was the most painful. The syntax was a nightmare to learn (and this is from when I already knew C and Java) and all the complicated rules made it seem more like a cultural festivity than some tool used to accomplish a task. Not only that, but the C course was just 3 weeks whereas the C++ course was a full semester (and I still feel like I learned nothing).
I'm sure it's useful once you learn all of it, but it's quite arcane and difficult to get used to on first pass. Then again, maybe my course wasn't taught as well as it should have been, or I didn't approach it the right way. Of course, I certainly understand that it's a very powerful language if you use it more often than I did. But probably my least favorite language of those that I've learned.
I have left slashdot and am now on Soylent News. FUCK YOU DICE.
I don't loathe C++ as much as some people, but I am not much of a fan either. To me C++ (and Java) is too much of a middle road between lower level languages (like C) and higher level languages (Python, Perl, etc). I prefer to write the bulk of my code in a high level language like Python, profile the code, and then rewrite performance critical sections in C (which is relatively easy to integrate with Python). This gives a good balance between performance, development speed, and maintainability.
There certainly is no perfect language but I find any programmer that really spends time learning Ada, or Python or other language really well ends up being a better C++ programmer in the end too. Brief interludes don't really cut it either.
--- Liberty in our Lifetime
...that the creator of C++ runs Windows. C++ is a barely-stomach-able OO implementation, and Windows is a barely-usable GUI & OS. I look forward to using neither, but often must do so.
Does it hurt to hear them lying? Was this the only world you had?
Brad Cox liked C, but it was missing OOP. So he created Objective C, a pure superset of C that embraced the C-ness but added a smalltalk inspired runtime and OO.
Bjarne Stroustrup wanted to create a new OO (or whatever) language, but he knew that creating an entirely new language was a dead end. He hated C, but it was popular, so he embraced and extended.
Do you even lift?
These aren't the 'roids you're looking for.
Millions and millions of lines of commercial grade C++ code running from gigantic enterprise systems to can't fail for years systems to real time system down to tiny embedded systems over the past 25 years.
But some random idiot on Slashdot running his mouth off 'sez it sucks'.
I won't bother speculating why C++ became dominant (any more than I feel like rehashing VHS vs BetaMax), but I will say this: any language that needs a series of books explaining how NOT to use the language (lest you create obscure bugs) is an inherently flawed language.
With assembly there's an excuse - you have no boundaries (no pun intended). You realize you're operating on bare metal, or at least one step above it. But with C++ you have this belief that you have the illusion of power and safety, but the reality is you have a jumble of constructs and tools that can easily be used wrong (and often are by novices and intermediate developers).
I daresay you could teach an intermediate coder how to do OO in straight C and get better results than if they were trying to use C++.
And yeah, I'm in the camp of "Obj-C is better than C++". But then, I like Ruby, Lisp, Clojure, and Scala too. C++ really needs to die. Any further energy spent on C++ needs instead to be put into JVM and other abstraction technologies.
.sigs are for post^Hers.
I know they say it for marketing, but the devices wouldn't have had intel in them at all. Only chips, generated by 3rd party plants, which took specs from Intel. :) A couple layers of abstraction away is all...
After 25 years, the core concepts of C++ are still misunderstood. This is not surprising since people jumped into C++ from C and saw C++ only as a syntactic sugar over C.
The key concept of C++ is stack unwinding with orderly destruction of scoped objects. In C++, the data best reside on the stack - the heap is for shared data or really large data, and should always be tracked by some object on the stack. No other commercial language has this concept of predictable and orderly resource management.
Once this concept is fully grasped, one can produce very robust and clean C++ code.
Just glad I don't need to read their code!
I don't see how well-written C code is so much harder to read than well-written code in Python, Java, or whatever..
27 years ago I watched my wife code C and I laughed, because she was trained in COBOL and her C looked so much like COBOL it was funny.
Now, the joke's on me. 27 years later her stuff is still easy to read & modify. There's not much other C code you can say that about, in the otherwise known as "write-only language".
(Yeah, she forgave me for laughing. She knew how the story would end.)
--
.nosig
NOW IT MAKES SENSE!!!
I pushed and poked registers in assembler and compiled IBM punch cards. Fortran was fabulous, then, Pascal was global, and Basic was child's play. C was just too much for me!
Only someone who didn't know both languages would make such a stupid mistake. c and c++ are complementary languages.
The pre-processor is one of c and c++ strengths. It enables a type of workflow that languages w/o it could benefit from.
-- Barbie
Bjarne and the Community's creation was the bona fide beginning of my career. When I started, I thought I was a 7 in C++. Several years later, I was a 5. I wrote my best and worst code in the language, over 15 years, and I am still running into issues in the language that challenge me today. C++ helped me learn a lot about myself along the way, and I am grateful to Bjarne and the Community at large for that. A good article and interview, if not a tad brief.
Sadly, every time C++ is mentioned on Slashdot, we get a flood of unoriginal, boring comments about how bad it is. These usually come from people who either don't understand why the language exists, or have just plain never used it. But they heard it sucks somewhere and all the cool kids in the gang are saying it sucks, so they should join in the bullying.
So far, no language can replace it. If you don't understand this, you don't understand the class of programming problems it solves. C++ is a language designed for static compilation. It doesn't run in a VM. It isn't managed. This makes it great for system code (drivers, kernels), high performance, and "raw" environments. It is designed to be "wysiwyg": a line of code will translate to a sequence of unsurprising assembly if the programmer is experienced enough. It is designed to allow all that and still have high level features to reduce lines of code, improve type safety, and increase modularity.
There are good reasons it's still one of the most commonly used languages for games, kernels, embedded devices and high performance apps: it really is good at them. It's not just momentum and "lock-in". There have been plenty of languages with bigger backers that died because they were bad or just merely obsolete: Pascal, COBOL, Fortran as quick examples. Ada is still out there simply because the military backs it, and I wouldn't be surprised if that changes.
There are plenty of languages which are better in some domains: Java has the advantage of a managed VM, and Python has a neat syntax and can achieve a lot in few lines of code, as just two examples. However, you'd never write system code in Java or Python. You'd never write something high performance in Python. You'd never settle for the critical path of a high performance application being written in Java. Well, some people do, but they're either kidding themselves, or they don't really have a high performance application.
I really, really would love someone to design a language which fulfills everything C++ does, but at the same time fix up its sometimes arcane syntax and removing the shotguns constantly pointing at your feet. But until then, I'm happy with the language that makes my every day job that little bit easier. If you find that funny, then you're the target of Stroustrup's interview: you need to stop being foolish and give it a chance. I pity all the people I've met over the years who are convinced they know the "best" language and will stick with it forever. Or those who consider C better for every problem which C++ would be suited. Happy job hunting to them - that attitude will catch up with you some day.
I don't understand why Objective C is considered a good alternative to C++. Why not use both? You get the advantages of C++ type checking and encapsulation, while also having the runtime dynamic binding of Objective C.
Where can I get an archive of back issues of the C++ Report? It had a nice run during the 90's as one of the hippest magazines in software development. Then, Java and web scripting came along, followed by XML and .NET, and it withered and died.
He used to actually participate in holy flame wars in the usenet about C++. I am sure he is a slashdotter. Should he be allowed to use his mod points on this thread?
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
Not to say there are no bad languages out there, but the quality of code (from elegance, maintenance, and performance standpoints) has MUCH more to do with the person who wrote it than the language it is written in. At the expense of being momentarily arrogant, the code I write in C++ kicks ass, not because it was written in C++ but because it was written by me. Similar to how my Python kicks ass or my C# kicks ass. It's because I kick ass, not the language I'm using.
I am only a few weeks in on C++. I like the idea of classes and a true object oriented language over C, but the syntax is so damn bad for everything.
I believe it has mostly to do with C++'s legacy with C and trying to be backwards compatible. It feels like it breaks so many general convensions in how things are written in C, you don't know what the hell it is going to do. "std::string mystring()" took a while for me to comprehend. My first thought was that it was something like "char mystring()" until I realized it was an object initalization and declaration all in one.
Templates? I really don't know what to think of them yet. Should they really be built into the language? I can't shake this feeling they are serving a purpose better met by perhaps a Makefile which copies and replaces the variables in a file.
I will probably have C++ grow on me more over time once the syntax stops pissing me off. Haven't tried Obj-C yet. But I have a feeling that or D would piss me off less. Only one way to find out...
Once you start despising the jerks, you become one.
You linked "C++'s first release 25 years ago". I didn't want to read about the first release of C++, so I didn't click it. Similarly, you linked "creator regularly receives accolades", which I'm also uninterested in. However, you mention a new interview by Wired, which I'm very interested in, but there was no apparent link to the information.
Linking really isn't hard -- you link the bit of text that represents what you're linking to. It seems like 75% of the articles these days just link random substrings in the text instead of something contextually relevant.
Except C++ is not slower than C... It's actually equally fast, and can give a lot of performance optimizations with a fraction of the code needed to do the same on C.
It's even better than that. There's extra type checking and tighter rules on aliasing in C++ (unless you turn them off), so it can actually generate faster code. If you trivially convert a C program to the slightly less relaxed rules of C++, you should expect at least the same performance (if not, file a bug with your compiler provider), and often better.
I agree with the sentiment that anyone who thinks C++ is slower then C understands neither. It perfectly demonstrates their lack of understanding.
Totally agree. I do the same thing when giving interviews.
It's because Bjarne Stroustrup spent 23 years at Bell Labs, and ran the Large-Scale Programming Research Department there.
Bell Labs was the birth-place of Unix, and was always Unix central. Anyone even cursorily familiar with these facts would be a bit surprised to see someone who was so close to such a Unix stronghold for so long running a non-POSIX compatible system for day-to-day use.
Bjarne Stroustrup Reflects On 25 Years of C++: My bad
I like templates, besides the generalization of types, I find it ends up replacing a lot of #define macros which are infinitely more evil because of the lack of namespacing and typesafeness. Default parameters (template or otherwise) have bitten me so many times that I can't help but hate them, and I tell others not to use them, but every once in a long while....
Also template specialization (and partial template specialization) can be very useful for optimizing specific versions of routines for a given type or size.
refactor the law, its bloated, confusing and unmaintainable.
Real men code in Assembler.
Probably because, as a Bell Labs alum, Stroustrup undoubtedly had a heavy immersion in the Unix tradition.
That he would choose the only major non-Unix-y OS for his portable would strike me as surprising as learning that Bill Gates had just bought an iPad.
Unfortunately, although Linus Torvalds is an excellent leader of technology development, he sometimes exhibits unsophisticated social behavior.
In the linked message from Linus, *YOU* are full of bullshit, he gives good reasons why he doesn't like C++, but he does not fully analyze the entire situation.
For example, he says "C++ leads to really really bad design choices". That's true in many cases, but C++ programming could be limited to the features that work well. Many of the problems with C++ are caused by programmers using features that they don't fully understand, only so they can get some experience using them. Often, it seems, programmers just want to experiment, and don't care about the long-term end result of what they are coding.
Another problem with C++ is that, while Bjarne Stroustrop was a good leader when C++ was introduced, he has basically exercised too little power in the last 20 years in making sure the C++ language and libraries developed rapidly enough, and in the correct direction.
Still, as bad as the situation is with C++, what is better? Java and C# are easily decompiled; both suffer from ugly politics. C++ is better than C in that it helps programmers control the scope of variables, for example.
When Linus Torvalds says "*YOU* are full of bullshit", he is acting out his anger, he is not acting like a leader. He is not helping make the situation better.
Unfortunately, the people on whom we rely to be our leaders are not always good leaders. We can, however, be thankful for everything positive they have done for us.
Objective-C is a caricature of Smalltalk, combining all the disadvantages of C with only few of the advantages of Smalltalk. It also lacks pretty much all the advantages of Java: Objective-C is not type-safe, it does not provide runtime safety, it does not provide sandboxing, and it does not allow you to safely load extension modules.
C++ started out as a simple set of fixes to problems in C, and for the first few years, it was a pretty good tool. That's why it won over Objective-C, which came out around the same time. Eventually, C++ bloated beyond recognition, while Objective-C stagnated from disuse, and that's the state we're still in. There are still a few valid use cases for C++, but I see none for Objective-C.
What should you use then? As far as languages that you can realistically use, I think the best ones around are C#, Go, Python, and Ruby. There is nothing (zero) new ideas in those languages compared to what's been available for decades and their implementations are mediocre and bloated at best. The evolution of programming languages has been a big, fat disappointment.
Does C give you
In short: You just don't know what your missing.
Problems with "smart" pointers:
But this is all corollary to the main thing: RAII is a solution to a language design problem.
My exception safety is -fno-exceptions.
"C++ advocacy on the net seems to be dominated by such newbies, or then they are the gurus who know obscure C++ quirks inside out and have written a book on that."
Interesting point.
Could you please explain to me why Fortran is not a good language to do lots of math for complex, multi-dimensional problems?
It does have:
-default pass-by-reference
-intrinsic complex types
-intrinsic multidimensional arrays, including simple global operations on arrays (scalar*array, array+array, etc.)
-with modules very thorough type checking (and whoever does not use them needs to be shot. Twice)
-almost intrinsic parallelism [e.g. forall statements, pure procedures, etc.]
-all features of C++ [operator overloading, classes, types, pointers, procedure pointers, etc.]
Of course, if you use it for anything else you will run into its limitations and quirks, but then you are using the wrong tool.
What if they want real programmers instead of engineers that do a little bit of programming?
I'm an "actual real world C++ engineer" but I'm shit at coding because I know more about hardware and thermodynamics than I do about C++.
Feels like fifty.
Oh, how convenient: a theory about God that doesn't involve looking through a telescope.
intel actually owns its own plants...
People, what a bunch of bastards
Things like give me an example where a struct would be a better choice and where a class would be better.
Few people get that one right. The only difference between struct in class in C++ is that struct defaults to public, whereas class defaults to private. In other words, the choice between struct and class is purely cosmetic and can only depend on your coding guidelines.
The only case where it does matter is if you want to mix C and C++. Then any data structure that should be shared between the two obviously has to be a struct, because a C compiler does not recognize the keyword class.
What really killed C++ for me was when a student created a situation like this:
As others have pointed out, most compilers give at least a warning about this or even fail to compile, which is well within what the standard allows. And it is quite reasonable for the C++ standard to make this an undefined behaviour, because it is impossible in general for the compiler decide whether the flow of control can leave a function via the closing brace. If a compiler could decide that, then it could decide problems like the halting problem that are known to be undecidable (in a computability sense).
Now of course, the standard could instead have defined the correct behaviour of the compiler to be that if it cannot decide this, it should introduce code that throws an exception. But that would be introducing code that the programmer has not asked for, e.g. if the programmer has proven that control flow cannot fall off the end of the function, but the compiler is unable to follow that proof. That goes against the philosophy of C++ as a systems programming language.
Whether anybody should write code where the compiler is unable to figure out stuff like this is another question, of course, and obviously compilers should do a best effort to catch the obvious cases - but they already do that. So this is a pretty lame argument against C++ as a language.
I daresay you could teach an intermediate coder how to do OO in straight C and get better results than if they were trying to use C++.
I have done OO in C, and it's not pretty... with my own hacked up implementation of a virtual function table that you have to explicitly fill with the right pointers. This was some kind of expression evaluation code where the only alternative really was a huge switch statement, so it might have been better than the alternative, but I wouldn't advise, let alone teach, anyone to do this.
From Stroustrup, in the article:
"Know your fundamentals (algorithms, data structures, machine architecture, systems) and know several programming languages to the point where you can use them idiomatically.
Know some non-computer field of study well — math, biology, history, optics, whatever. Learn to communicate effectively in speech and in writing. Spend an unreasonable amount of time on some difficult topic to really master it. Try to do something that might make a difference in the world."
I guess he wouldn't do to well on Slashdot.
:)
That was a simple example for economy of words. Let's take a more complex example. Suppose I have an area function that takes inputs like height (H=5) and width (W=6) and length (L=7). In objectC you might write the following where W,L, and H are just floats to get the area of the side of the object:
[object area width:W height:H]
simple and you could do that in C++ by typedef W is type width, and H is try Length.
but now you want the area of the top and bottom:
[object area width:L height:W ]
But you can't do that in C++ without casting because L and W are not floats but rather are type defs that don't match their positions.
But that's not an example of polymophism just using labels instead of type defs which is what you really wanted in the first place, since the values were logically floats and you don't need to proliferate the type defs and make it a typically C++ mess. On the other hand if you really did require type safety then you could give them types.
THe other thing is that there are a proliferation of ways you might write the call in c++. IN most of these you would just have a list of arguments separated by commas:
object.area(L,W)
or
object.area(W,L)
Notice there is no enforcement of self documentation here. Can you recall which order the arguments are supposed to be in? L then W or W then L? In objectiveC the labels are enforced automatically.
People who write in C++ try to make up for the lack of labels by name mangling the method name like this:
object_area_L_then_W(L,W)
but there's no consistency in how that is done, and it does not enforce that the arguments are actually in the order required.
None of this has been about polymoprhism. I was just backing up to show you that trying to use typdefs to do the job of labels is why C++ code is so damn hard to write, debug and read, and has no consistency from person to person. Notice that ObjectiveC is doing this without any bloat: THere is only way way to write the method not a proliferation. We did not have to create some library to hand in maps to fake labels as we would in C++. it's all very natural. The fact that you then get polymorphism directly emphasizes how natural it was: methods with different labels are different methods. No typecasting required. The signatures could be identical.
"... unless you strictly adhere to naming conventions like m_ on every member."
"The people who come up with protective C++ coding conventions are the true thinkers and designers."
In my opinion, strong coding conventions should be part of any language. Presumably Bjarne Stroustrup is a careful coder. However, he has not been a strong enough leader in the social issues of coding C++. To be fair, however, getting programmers to cooperate fully is more difficult than herding cats. It's like herding a group consisting of alligators, rhinoceroses, and leopards.
A lot of people are bitching about C++ here; whether it's sour grapes over its success, a lack of understanding of the language, a lack of discipline to work in such a low level language, or honest criticisms, one thing has to be remembered: C++ was created to solve problems because its creator thought he could make a better language. One of my favorite ways to compare languages is What Languages Fix. It's a good, short read, but I'll spoil you and let you know that C++ was created to fix the problem of C being too low level. This implies many things, not the least of which is that Stroustrup wanted to leverage C's popularity, and of course that limited his options when designing C++. You'll also notice in that essay that Java was created to fix the problem of C++ being a kludge. And of course, C# was created for no other reason than Microsoft doesn't control Java ;)
Nathan's blog
The guys who ported Quake to Mac, say objective C, is C. It runs just as fast as C. ObjectiveC allegedly has slower method dispatch (as opposed to C-function calls) but tests show it's fast or faster than C++ (i.e. a tie as far as apples and oranges can be comapred)
Some drink at the fountain of knowledge. Others just gargle.
Real men code in Assembler.
Real Men code themselves a FORTH environment in assembler.
Stick Men
"... an octopus made by nailing extra legs onto a dog." -- Steve Taylor
"When in doubt, use brute force." Ken Thompson
This is interesting, but not as interesting as the interview where Bjarne Stroustrup explains the real reason for inventing C++.
(Yes, it is satire, but very sharp and insightful satire.)
"When in doubt, use brute force." Ken Thompson