Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Stroustrup Says C++ Education Needs To Improve

Soulskill posted more than 6 years ago | from the educating-the-edumicators dept.

Programming 567

simoniker writes "Over at Dr. Dobb's, C++ creator Bjarne Stroustrup has given an in-depth interview dealing with, among other things, the upcoming C++0x programming standard, as well as his views on the past and future of C++. He comments in particular on some of the difficulties in educating people on C++: 'In the early days of C++, I worried a lot about "not being able to teach teachers fast enough." I had reason to worry because much of the obvious poor use of C++ can be traced to fundamental misunderstandings among educators. I obviously failed to articulate my ideals and principles sufficiently.' Stroustrup also notes, 'Given that the problems are not restricted to C++, I'm not alone in that. As far as I can see, every large programming community suffers, so the problem is one of scale.' We've discussed Stroustrup's views on C++ in the past."

cancel ×

567 comments

I'm just glad they're teaching C++ actively again. (2, Interesting)

Anonymous Coward | more than 6 years ago | (#22911262)

When I attended college back in 1998 (Purdue), they decided to blindside everyone by teaching Visual J++ instead--Microsoft having "generously" donated the college discs containing the software. I'll never forget those fateful words from the professor: "I don't know this language myself, so I'll be learning it with you as we go." Let's not forget my favorite: "Java is the future of everything."

One semester later I dropped out and never looked back to computer science again as a career choice. In fact, though I bounced around between community colleges for a few years after, I never finished school.

Let me restate this: I'm just glad they're teaching C++ actively again. I wouldn't wish my experience on anyone.

Re:I'm just glad they're teaching C++ actively aga (5, Informative)

thetartanavenger (1052920) | more than 6 years ago | (#22911468)

Where are they teaching it actively again? I'm a student on computer science at the moment and all they teach in any depth is Java. The only reason I know c++ is my desire to learn it, despite the fact that various parts of my course have recently required a fairly in depth knowledge of c++.

My favorite lecturer quote, "Oh, I don't really do any coding at all".

Re:I'm just glad they're teaching C++ actively aga (0)

Anonymous Coward | more than 6 years ago | (#22911568)

Perhaps I should have made sure to include some HTML code in there...something like...oh...I dunno...

Re:I'm just glad they're teaching C++ actively aga (5, Funny)

Anonymous Coward | more than 6 years ago | (#22911920)

Hello Gentlemen,

I'm a first year programming student at an Ivy League school and I've just finished my Visual Basic classes. This term I'll be moving onto C++. However I've noticed some issues with C++ that I'd like to discuss with the rest of the programming community. Please do not think of me as being technically ignorant. In addition to VB, I am very skilled at HTML programming, one of the most challenging languages out there!

C++ is based on a concept known as Object Oriented Programming. In this style of programming (also known as OOPS in the coding community) a programmer builds "objects" or "glasses" out of his code, and then manipulates these "glasses". Since I'm assuming that you, dear reader, are as skilled at programming as I am, I'll skip further explanation of these "glasses".

Please allow me to make a brief aside here and discuss the origins C++ for a moment. My research shows that this language is one of the oldest languages in existence, pre-dating even assembly! It was created in the early 70s when AT&T began looking for a new language to write BSD, its Unix Operation System (later on, other companies would "borrow" the BSD source code to build both Solaris and Linux!) Interestingly, the name C++ is a pun by the creator of the language. When the first beta was released, it was remarked that the language would be graded as a C+, because of how hideously complex and unwieldy it was. The extra plus was tacked on during a later release when some of these issues were fixed. The language would still be graded a C, but it was the highest C possible! Truly a clever name for this language.

Back to the topic on hand, I feel that C++ - despite its flaws - has been a very valuable tool to the world of computers. Unfortunately it's starting to show its age, and I feel that it should be retired, as COBOL, ADA and Smalltalk seem to have been. Recently I've become acquainted with another language that's quite recently been developed. Its one that promises to greatly simplify programming. This new language is called C.

Although syntactically borrowing a great deal from its predecessor C++, C greatly simplifies things (thus its name, which hints at its simpler nature by striping off the clunky double-pluses.) Its biggest strength is that it abandons an OOPS-style of programming. No more awkward "objects" or "glasses". Instead C uses what are called structs. Vaguely similar to a C++ "glass", a struct does away with anachronisms like inheritance, namespaces and the whole private/public/protected/friend access issues of its variables and routines. By freeing the programmer from the requirement to juggle all these issues, the coder can focus on implementing his algorithm and rapidly developing his application.

While C lacks the speed and robustness of C++, I think these are petty issues. Given the speed of modern computers, the relative sluggishness of C shouldn't be an issue. Robustness and stability will occur as C becomes more pervasive amongst the programming community and it becomes more fine-tuned. Eventually C should have stability rivaling that of C++.

I'm hoping to see C adopted as the de facto standard of programming. Based on what I've learned of this language, the future seems very bright indeed for C! Eventually, many years from now, perhaps we'll even see an operating system coded in this language.

Thank you for your time. Your feedback is greatly appreciated.

Re:I'm just glad they're teaching C++ actively aga (2, Funny)

ericferris (1087061) | more than 6 years ago | (#22911972)

Too bad this was posted as AC, it deserved some funny mod points.

Re:I'm just glad they're teaching C++ actively aga (3, Informative)

cbart387 (1192883) | more than 6 years ago | (#22911582)

Where are they teaching it actively again?
My school is. In fact, C++ is the primary language you learn on. There's some Java classes to expose you to it and even brief exposures to some other misc. languages (ADA/LISP/PROLOG). We also program in C for some of the classes geared towards UNIX system programming. It's a nice balance because with Java EVERYTHING is an object and it's likely to confuse freshman. Heck, it first confused me with these static mains coming from a C/C++ background. At least with C++ you can start with just functional programming to get the basis of what is variable/function/const etc and save objects till the second semester. From my experience that seems to work pretty well.

Re:I'm just glad they're teaching C++ actively aga (1)

mcvos (645701) | more than 6 years ago | (#22911746)

It's a nice balance because with Java EVERYTHING is an object and it's likely to confuse freshman.

Actually, one of the problems with Java is that not everything is an object. That's why I think Java will eventually be replaced by something much more Ruby-like (but with a bit more performance, please). But Java was written to replace C++ at the application level, and as such it does a tremendous job.

Re:I'm just glad they're teaching C++ actively aga (2, Insightful)

cbart387 (1192883) | more than 6 years ago | (#22911904)

I'm full of errors today. I wasn't thinking of the primitives (double,int,char etc). I should have said something like 'first-time programmers have to use objects whereas C++ you can get away with keeping a procedural-oriented mindset. Therefore, you can limit what is introduced. Is that better? ;)

Re:I'm just glad they're teaching C++ actively aga (2, Informative)

GringoCroco (889095) | more than 6 years ago | (#22911818)

>> you can start with just functional programming to get the basis of what is variable/function/const
That's imperative programming.
You get functional programming with lisp, scheme, python, ocaml, haskell.

Re:I'm just glad they're teaching C++ actively aga (1)

cbart387 (1192883) | more than 6 years ago | (#22911844)

My bad. I meant to say procedural, I guess I haven't had enough coffee yet.

Re:I'm just glad they're teaching C++ actively aga (1)

SageMusings (463344) | more than 6 years ago | (#22911998)

At least with C++ you can start with just functional programming

I believe you mean to say "procedural or imperative". You can use this paradigm before you start true OO programming in C++. For a functional language, try ML.

Re:I'm just glad they're teaching C++ actively aga (5, Insightful)

skroll82 (935998) | more than 6 years ago | (#22911916)

"My favorite lecturer quote, "Oh, I don't really do any coding at all"." That's not a big deal. Computer Science is not about coding in particular, but understanding the practices to design and implement solutions to a problem. Computer Science is more about applied math then writing in language X. I learned some of the most important concepts in a class that was all done in pseudocode. Understanding how to approach a problem and solve it efficiently is more important then learning a language. In fact, once you know how most things are working, with a few basic concepts such as pointers or how a computer interpret an instruction listing, you should be able to pick up almost any language fairly easily. If you are not capable of learning things on your own without being handheld through a set of power point lectures, even if you knew C++ instead of Java you aren't going to be worthwhile in the real world anyways. You are destined to be a code monkey.

Re:I'm just glad they're teaching C++ actively aga (2, Informative)

RockoTDF (1042780) | more than 6 years ago | (#22911962)

Keep in mind that Computer Science is *not* coding. It's a subfield of mathematics that deals with the theory of computation. The lecturer might have been a theorist.

Java put you on Skid Row? (5, Insightful)

Latent Heat (558884) | more than 6 years ago | (#22911786)

Let me get this straight, that some wieners at Purdue decided to teach Java instead of C++ in their Intro to Programming course, and that you had a wiener of a prof who was teaching you Java without adequate experience, this all put you on the path to dropping school, dropping your CS major, and taking courses at community college without finishing a degree?

I will grant you that if you or the parents are shelling out the Purdue tuition, maybe their CS department should find a better professor for their intro course. I am sorry to hear that this experience dissuaded you from completing a CS degree, and there is probably a lot more to your personal story than can be shared on Slashdot.

But I would like to communicate to others out there that you will have a few good teachers in your educational career who are really inspiring, a vast group of average teachers, and a number of who you consider to be really, really bad teachers. The "bad" teachers are that way (in your opinion) for a number of reasons -- they may be "nice guys or gals" who don't have enough preparation or smarts to teach, they may have admitted to you gaps in their preparation that you have taken upon yourself to hold them in disrespect for, or maybe they assign too much HW and work you too hard.

If one is going to take a passive approach, show up to class and demand, "Here, educate me", that is a good way to fail at getting a degree and also to fail at every other opportunity that presents itself down the road. If one is going to take an active approach, working as hard as one can at learning from all teachers, the good and the bad, supplementing gaps in instruction with self-study, working coding jobs, group study, one is going to be successful at college and everything else.

To suggest that a person can have one "bad" prof means that they are on the street drinking methyl antifreeze out of a jar wrapped in a paper bag, this suggests a very passive approach to not just education but life in all its aspects.

Re:I'm just glad they're teaching C++ actively aga (1)

mcvos (645701) | more than 6 years ago | (#22911816)

Let's not forget my favorite: "Java is the future of everything."

Everything is an exaggeration (Java isn't very big on low-level system/OS programming as far as I know), but on the application level, Java is the biggest, most succesful language ever, so he wasn't far off.

Visual J++ was an obvious dead end, however.

Visual J++ an obvious dead end? (0)

Latent Heat (558884) | more than 6 years ago | (#22911866)

I fail to see how Visual J++ was a dead end. Although they don't call it Visual J++ -- it is now called Visual Studio .NET C#. I had looked at Visual J++, and it is .NET version 0.8 in so many ways.

I completely agree (4, Insightful)

betterunixthanunix (980855) | more than 6 years ago | (#22911278)

I completely agree with Stroustrup. Too many people these days have little or no exposure to C++, and never learn how programming in the absence of garbage collection works. It is especially problematic in our research labs, where computationally complex problems must be solved with very fast code, but the people writing it get completely confused by pointers and memory management. Worse is when a proof-of-concept is distributed, with horrible bugs and completely incomprehensible code.

more to it (5, Interesting)

g2devi (898503) | more than 6 years ago | (#22911368)

That may be so, but there's more to it. It's only been recently fully implemented and a few years ago Stroustrup himself commented that he's constantly surprised that some things (e.g. template recursion) are even possible in C++.

The language is overly complex. The key advice any C++ expert is "restrict yourself to a specific subset of C++". That's the bulk of the difficulty. If C++ were simplified to include only that subset, you'd have a lot less need for training,

Re:more to it (5, Informative)

JohnFluxx (413620) | more than 6 years ago | (#22911456)

Sometimes you need the more complicated parts of C++ - It would be a very bad idea to simplify c++ to the lowest common denominator.

For example, most people don't use the SSE stuff or even know about it. You can, for example, make a vector with 4 numbers in it and multiply it with another vector with 4 numbers in it. The result is that the four multiplications are done simulatanously.
Most people won't use this functionality and thus don't even need to learn it, but when you need an algorithm to run fast, it is essential.

Re:more to it (0)

Anonymous Coward | more than 6 years ago | (#22911928)

Very bad example. I consider "using SSE" one of the more simple features of C++. What do you have to understand to use SEE? Using intrinsic functions, which are for the user not more complicated than any other function call. Or you could use inline assembler which is not very complicated.

Re:more to it (0)

Chapter80 (926879) | more than 6 years ago | (#22911956)

You can, for example, make a vector with 4 numbers in it and multiply it with another vector with 4 numbers in it. The result is that the four multiplications are done simulatanously.
Wow, I thought we had to look to Erlang [wikipedia.org] for concurrency this powerful. Unless "simulataneously" means "nearly simultaneously". Perhaps you meant that the four multiplications can be performed with one operation? Or did you really mean simultaneously? I just find that hard to believe.

Re:more to it (1)

repka (1102731) | more than 6 years ago | (#22912024)

Nowadays I code heavily in C# and occasionally have to modify libraries used by other people. C++ has much better facilities to avoid breaking existing code: typedefs, macros, better implicit cast operators. Even though first two are relics from C era and the last one somewhat complicates the language, C++ wouldn't be C++ without them.

Re:more to it (4, Informative)

smilindog2000 (907665) | more than 6 years ago | (#22911554)

I couldn't agree more! Much of the worst code I've ever had to deal with is C++ code written by smart guys who don't know what parts of C++ to use. How about mixing double inheritance from template classes, with smart pointers and garbage collection, when all you're writing is quicksort? Smart guys can take a 100 line problem and turn it into a 10,000 line C++ solution.

I focus instead on restricting programmers to the tools they need, so they focus their creativity on algorithms instead of coding methodology. I've even codified it all, as an extension to C [sf.net] , rather than C++. Works great for team programming. I had a guy last week write two IC placers: simulated annealing, and quadratic placement, in 5600 lines of hand written code, debugged and working. He did it in 6 days while supporting a difficult client, without working weekends or evenings. I'd estimate his productivity at 10X to 100X higher than average.

Re:more to it (5, Interesting)

shutdown -p now (807394) | more than 6 years ago | (#22911870)

Unfortunately, even if you keep away from the more advanced stuff such as template metaprogramming, there's still plenty of surprising (in a bad sense) behavior in the most basic C++ constructs (mostly inherited from C, but exacerbated by C++ pretense at high-levelness, and with some new stuff thrown in for good measure). Pointer arithmetic, unsigned types, silent implicit narrowing conversions, PODs vs non-PODs (which in turn separate into aggregate types and everything else) and the subtle differences in initialization of those, ability to delete void* and pointers to incomplete types (and the wonders of virtual destructors), etc... The language is a mess, really. It is very powerful, and the existing code generators are very good at optimizing stuff, but writing in C++, or any subset thereof, requires a very good understanding of subtle details.

A simple example: given a vector of ints, calculate the average value, using standard idiomatic C++. Let's give it a try:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <numeric>
#include <ostream>
#include <vector>

int main()
{
std::vector<int> v;
std::copy(std::istream_iterator<int>(std::cin), std::istream_iterator<int>(), std::back_inserter(v));
int avg = std::accumulate(v.begin(), v.end(), 0) / v.size();
std::cout << avg << std::endl;
}
A simple task, and a clean implementation, using the standard library as much as possible. No fancy language features used - no template metaprogramming, no pointers, no virtual inheritance. The kind of stuff a new C++ programmer might write after reading Stroustrop. And yet, it gives wrong result for certain input data. Now, who'll be the first one to spot and explain the problem here, preferrably without actually running it? Bonus points for explaining why we need "istream", "ostream" and "iomanip" headers here in addition to "iostream" (and we do, if we want this to be portable).

Re:more to it (-1, Redundant)

twistedcubic (577194) | more than 6 years ago | (#22911990)

I think you would look less silly if you just stated "C++ is crap!" without trying to give any evidence. Seriously.

Re:more to it (2, Insightful)

Zeinfeld (263942) | more than 6 years ago | (#22911710)

The key advice any C++ expert is "restrict yourself to a specific subset of C++".

Yes, that subset is called C.

Seriously, at this point it is time to call a halt to C++ education. Treat it like COBOL, Fortran or any other legacy language that still has demand for programmers but is long since past utility. It is a good idea for students to understand that they have to keep current with programming languages and not expect to be employed as a programmer if they can only code in one. But that does not mean we should start by teaching an obsolete language.

You don't need to tech kids to write in C++ for them to learn how bad an idea lack of GC is. Just give them some existing code and tell them to chase buffer overruns and memory leaks.

I would not code in any language that does not have a garbage collection feature, period. When I coded C in the 90s I wrote my own garbage collector using macros and some extensions to the memory allocation routines. More importantly I would not allow anyone else to write code without GC because none of them were capable of doing it right.

Second, do not use the null terminated string handling. This was one of the key coding requirements that Tim Berners-Lee set out in libwww. All string catenation was checked. It is one of the reasons libwww was so widely used, it was buffer-overun error proof.

I would certainly specify C for use in a low level O/S platform project, but not C++. I think the language is Algol 68 to Algol 60, worse than the original.

Above that point I would use either C#, Java or objective C. From an education point of view they are interchangeable.

C# is at least as fast as equivalent C++ code. The code generator used is identical. You can switch in your own GC if you choose.

Re:more to it (4, Insightful)

gbjbaanb (229885) | more than 6 years ago | (#22911910)

You don't need to tech kids to write in C++ for them to learn how bad an idea lack of GC is. Just give them some existing code and tell them to chase buffer overruns and memory leaks
You don't need to tech (sic) kids to write in C# for them to learn how bad an idea of GC is. Just give them some existing code and tell them to chase memory leaks [ibm.com] and finalisation issues.

There, fixed that for you.

Re:more to it (2, Insightful)

Chapter80 (926879) | more than 6 years ago | (#22911994)

I agree. C++ served its purpose in the language world. It was a great FIRST STEP toward object oriented programming, but it has outlived its usefulness. Stroustrup should take pride in his great contribution, and not be discouraged because C++ has been superseded by other, better languages. C++ provided a bridge from the world of no objects in C, to the world of objects. But now that there are languages that are designed with objects in mind from the ground up, it's only academically interesting (and of little practical value) to learn C++ except to support (or port) legacy applications.

Re:more to it (2, Interesting)

shutdown -p now (807394) | more than 6 years ago | (#22911922)

The language is overly complex. The key advice any C++ expert is "restrict yourself to a specific subset of C++". That's the bulk of the difficulty. If C++ were simplified to include only that subset, you'd have a lot less need for training,
Yeah. That subset could be called something then to distinguish it; say, "Java". And then you could have a slightly larger subset with more advanced stuff, like pointers and value types; let's call that something more C++-like to reflect it: hm, how about "C#"? And sure enough, once you do that, it's much easier to teach people that, and they write more readable code, too.

This isn't to bash C++; it's still a useful language when you want raw speed of C but with some more decent abstraction mechanisms. It's just not the right language to write high-level stuff in, and it shows now that a lot of GUI applications, which were previously largely written in C++, are being done with C# or even Python.

Re:I completely agree (4, Interesting)

schmidt349 (690948) | more than 6 years ago | (#22911380)

Yeah, but that doesn't sound like the sort of problem that gets fixed by learning C++, which has a nasty habit of adding loads of complexity in all the wrong places. If you want tight, fast code and your project doesn't need OOP, use C.

As for programming pedagogy, I think we'd do a lot better if the faculty of CS departments would migrate away from using Java/C++ as the introductory programming model because so much of what gets said initially just goes in one ear and out the other. I will admit to not remembering at all how typedefs or templates in C++ work, and I can't say it's harmed me much.

Python would be a much better choice in my view for a variety of reasons (and I say this though I'm a Perl nut!), or hell, if you teach them Lisp they'll be horribly screwed up for the rest of their lives but at least they'll understand how registers and OOP work.

In short, novice programmers are not going to learn anything useful if you use C++ as the prescriptive model for how a well-written computer program should look -- they're just going to hit the bottle earlier in life.

Re:I completely agree (3, Insightful)

lexarius (560925) | more than 6 years ago | (#22911454)

Agreed. Also emphasize that, while Python is not as efficient as compiled languages, you can come back later and rewrite important parts of it in C. Then you can teach C with an emphasis on high-performance computing, rather than the typical "here's how we ask for user input, here's how we copy strings" emphasis typically taught in C courses that I've seen. Eventually, you could then show them how to add in assembly code to get at special-purpose processor operations not exposed by C. Probably do this over the course of a few semesters though.

Hell, who am I kidding. Just teach them to code in brainfuck. Or maybe INTERCAL. Normal languages will seem much nicer after that.

Re:I completely agree (1)

itsdapead (734413) | more than 6 years ago | (#22911664)

As for programming pedagogy, I think we'd do a lot better if the faculty of CS departments would migrate away from using Java/C++ as the introductory programming model because so much of what gets said initially just goes in one ear and out the other.

Even better would be if they didn't get involved in ideological wars about languages, and focussed on the *concepts* they wanted to teach. If students really are coming out of these courses with certificates saying "computer science" which should read "Java forms design for data centers" then arguing the merits of Java,Lisp,C++ or Son Of The Return of the Bride of BASIC isn't going to fix anything. If you're gonna call the course "Computer Science" then students should come out knowing a decent wodge of mathematical theory and having some experience of half-a-dozen diverse languages, plus assembly and microcode. Of course, there are plenty of jobs that don't need that level of knowledge - but in that case the candidates don't need CS degrees.

Real Programmers can do Object Oriented Programming in FORTRAN... Well, maybe not, but you can certainly lay out a (regular) C program using some of the basic OOP principles - its just up to you to "enforce" them (like everything in C).

Re:I completely agree (1)

mcvos (645701) | more than 6 years ago | (#22911860)

Real Programmers can do Object Oriented Programming in FORTRAN... Well, maybe not, but you can certainly lay out a (regular) C program using some of the basic OOP principles - its just up to you to "enforce" them (like everything in C).

True, but Real Programmers also know not to use C for things it's not intended to. C is for high-performance systems programming, maintainable application programming is much easier and faster with a higher level language.

Re:I completely agree (1)

CRCulver (715279) | more than 6 years ago | (#22911436)

Too many people these days have little or no exposure to C++...

That might be because it is rare to learn C++ outside of an organized course, and if you don't get such a thing in school, it's hard to do it on your own later. O'Reilly apparently publishes a self-teaching book called Practical C++ programming [amazon.com] , but it's not widely distributed compared to their interpreted language offerings. Every other C++ introduction I encounter seems to be designed for use in schools, not for autodidacts.

...and never learn how programming in the absence of garbage collection works.

Now, that I must disagree with. Isn't C still part of a basic university computer science education? My formal training in programming is two semesters as an undergraduate, but C was a key part of both.

Re:I completely agree (4, Informative)

bsane (148894) | more than 6 years ago | (#22911560)

The O'Reilly books are an example of the problem here.... their C++ books are the worst O'Reilly books I've ever read. It wasn't until I picked up 'The C++ Programming Language' by Strousup that I realized my mistakes and what C++ was really capable of.

I agree with the premise that C++ is a great language, that is poorly understood, and often mis-used. Education would seem to be the answer to that.

Re:I completely agree (1)

roman_mir (125474) | more than 6 years ago | (#22911906)

It wasn't until I picked up 'The C++ Programming Language' by Strousup that I realized my mistakes and what C++ was really capable of. - And if you pickup a similarly named book by this guy, named Stroustrup, your previous realizations will be dwarfed by the new set of information ;)

Re:I completely agree (1)

Midnight Thunder (17205) | more than 6 years ago | (#22911620)

I completely agree with Stroustrup.

I agree and I point the finger (I have to blame someone don't I?) at architects who don't understand what computer code is. Have you ever been presented the next amazing design for a solution and thinking, "am I a magician or a software developer?". If an architect has had some contact with code then the solutions tend to be a little more realistic. ;)

Re:I completely agree (3, Insightful)

gbjbaanb (229885) | more than 6 years ago | (#22911630)

I agree too, to quote TFA: "Conversely, there is now a generation who is firmly convinced that a program is only well-designed if just about everything is part of a class hierarchy and just about every decision is delayed to run-time."

I'm not sure if the problem is bad education or the lazy coders who expect everything to be easy (ie done for them) so they don't have to really think about what they're doing.

Even MS's clever chaps have this problem - "lets have C# and GC so no-one need think about memeory ever again" they cried. Then they realised that objects are more than just memory so you do have to worry about destruction of the non-memory resources held by an object (eg file handle, etc). Then they realised they were getting problems writing code that interacted with the OS, so they introduced reference counting objects [msdn.com] that they could put in their "deterministic" finalisation objects that they could put in their Garbage-collected objects.

Re:I completely agree (1)

thelima (1045360) | more than 6 years ago | (#22911696)

Too many people these days have little or no exposure to C++

Uhm... nowadays too many people have little or even no exposure to math and
actually nobody cares...

Having developing for Years in C++, and having learned
OO in C++, obvoiusly being trapped by most ugly C++ traps I actually am against
teaching C++ as something other than highly specialized course in University. Sure one
can teach C++, but definitely C++ should be put to the Ancient Languages Cathedral
together with COBOL, ALGOL, PL/I, FORTRAN, MODULA etc ideally within the Faculty of Historic Sciences...

lima

Re:I completely agree (1)

mcvos (645701) | more than 6 years ago | (#22911782)

Too many people these days have little or no exposure to C++, and never learn how programming in the absence of garbage collection works.

Most people don't need exposure to C++, because most people don't do any systems programming. C++ is for operating systems and drivers, and was never intended for application programming. I think it makes most sense for people to start on something like Java (or Lisp, perhaps), and once they've figured out they want to do systems programming, teach them C and C++. If, instead, they want to go towards application programming, teach them a higher level language like Python or Ruby.

It is especially problematic in our research labs, where computationally complex problems must be solved with very fast code, but the people writing it get completely confused by pointers and memory management. Worse is when a proof-of-concept is distributed, with horrible bugs and completely incomprehensible code.

Sounds like they chose the wrong language for the job. Computationally complex research problems and proofs of concept shouldn't be written in a language that requires manual memory management. Often, functional languages (Lisp, Haskell) are best for that sort of thing.

Re:I completely agree (1)

bondsbw (888959) | more than 6 years ago | (#22912028)

Learn the tool that suites your needs best.

I'm all for learning programming languages as a general discipline, but I don't see any reason to learn all the ins and outs of something as complex as C++. It is a language that tries to be everything for everyone, but it completely misses when it comes to understandability. More pure languages often sacrifice the "all-in-one" role in order to be something that promotes maintainability. And if they aren't good for your situation, use something else.

Not another I/O Rewrite please! (1, Informative)

Anonymous Coward | more than 6 years ago | (#22911318)

Last time Bjarne changed C++, he broke the I/O libraries which gave many of us the thrill of having to go back through old code and rewrite it for no other reason that Bjarne wanted to change something. We got no value out of the changes. They just wasted a lot of people's time.

Bjarne: C++ should evolve, but there's a mass of C++ code already out there. Improve it please, but don't make us go back and rewrite existing code.

Maybe the real problem... (3, Insightful)

bfwebster (90513) | more than 6 years ago | (#22911350)

...is that C++ is a rather complex and brittle language. :-) ..bruce..

P.S. Feel free to flame away at me, but not only have I developed professionally in C++, I've actually rescued a C++ project by (among other things) drafting C++ coding standards and guidelines for the 30 or so developers working on it.

MOD PARENT UP (Re:Maybe the real problem...) (0, Redundant)

jejones (115979) | more than 6 years ago | (#22911370)

Would that (1) I had moderator points and (2) I could apply all of them to one article.

Re:Maybe the real problem... (2, Interesting)

mathimus1863 (1120437) | more than 6 years ago | (#22911426)

"...is that C++ is a rather complex and brittle language. :-) ..bruce.." That's not so much a problem as it is the nature of computers. Computers and the logic that runs them is complex and brittle, thus why it is important that developers understand a lower-level language like C++. If you don't understand the underlying system for which you are developing, you won't be efficient or effective at doing what you're attempting to do.

It reminds me of this: http://thedailywtf.com/Articles/It-Had-Too-Many-Functions.aspx [thedailywtf.com]

Re:Maybe the real problem... (0)

Anonymous Coward | more than 6 years ago | (#22911512)

Computers and the logic that runs them is complex and brittle, thus why it is important that developers understand a lower-level language like C++.

Lower level language... Fuck Off!


If we want a low level language (typically for performance) we can use asm or C. If we want a high level language and we established performance doesn't matter, we use Java or dynamic languages. For the niche space inbetween and given the opportunity to use ObjC, Vala, or C++ for application programming, C++ would be bottom of the list.


C++ is effectively dead, take a hint from the COBOL guys ;-)

Re:Maybe the real problem... (5, Insightful)

ubernostrum (219442) | more than 6 years ago | (#22911624)

Computers and the logic that runs them is complex and brittle, thus why it is important that developers understand a lower-level language like C++.

...and several previous generations of programmes roll over in their graves at the thought that C++ is a "lower-level language".

The thing is, C++ is huge. Just to have a solid working knowledge of the core language, you need to master whole rafts of things that have nothing whatsoever to do with the low-level operation of the machine, because even the core is a labyrinth of obscure corner cases that make language lawyers drool, and which, if expressed in pseudo-code, would be a bunch of gigantic switch statements with a couple dozen levels of ifs nested inside each case. Now, add the STL on top of that, and add common third-party bits like Boost on top of that, and you're left with a monstrosity. To really understand programming at a lower level, you need at best only a small subset of C++, and unfortunately for C++ that subset is properly called "C".

Re:Maybe the real problem... (2, Insightful)

wrook (134116) | more than 6 years ago | (#22911726)

I wish I had mod points. While I agree with the grand (grand?) parent post, it didn't really provide any information (not sure why it was modded +5 interesting...). This post really explains the issue faced by many would-be C++ programmers. It's a long learning curve to write modern style C++ code. Not only that, but many people don't even realize *why* they would want to program this way. The bash out some horrendous code that nobody on earth can maintain.

C++ is also complex in and of itself, but there are good reasons for almost every piece of complexity in the language. Though severely dated the ARM is still a useful place to learn why the language is like it is. Despite it's complexity, I still think C++ is a very handy tool to have in my toolchest for certain types of problems. However I find myself turning to it less and less over the years.

Re:Maybe the real problem... (2, Insightful)

shutdown -p now (807394) | more than 6 years ago | (#22911976)

The thing is, C++ is huge. Just to have a solid working knowledge of the core language, you need to master whole rafts of things that have nothing whatsoever to do with the low-level operation of the machine, because even the core is a labyrinth of obscure corner cases that make language lawyers drool, and which, if expressed in pseudo-code, would be a bunch of gigantic switch statements with a couple dozen levels of ifs nested inside each case.
Absolutely. This is fairly easy to check, too; here [open-std.org] 's the most recent draft for C++0x, and it's already 1200+ pages! And they haven't even included everything they want to get there yet (such as concepts, which alone will add a lot more; a full list of what's not yet there, but is going to be, can be seen here [open-std.org] ). Now, how do you think, how many developers are going to understand it well enough?

Re:Maybe the real problem... (3, Interesting)

jellomizer (103300) | more than 6 years ago | (#22911760)

C++ is a process of reinventing the wheel over and over. The performance gains of doing things in C++ is usually lost because it wears down the programmer, and leads to sloppy coding. Higher Level Languages as part of the core language comes with many useful functions that are programs relatively good efficiency. Lets say Pythons List Data type where you can do a Sort on it or a concatenate, or get a sub list off of it, and more too. Yes you can do the same functionality with C++ but you need to make it yourself and build the Data Type and add the functions to do it, or get a library that may not work on an other platform or needs more libraries to work. But what will normally happen to a C++ Developer they will make a less efficient hack to the data type they actually want, just to save time. So unless you are really obsessed with performance in your code C++ will often lead to slower application and it will take much longer to code anyways. Higher Level Languages let you focus on getting what you need done and a degree of trust on what you are going to do will do it fast enough.

It will take a lot of effort for someone to make good clean code, fast and efficient, easy to read, easy to update, well commented and bug free. C++ is only a good language if you have the tolerance to code that carefully over a long time.

For real life upper level languages the the job done faster better and easier.

For terms of Teaching Computer Science C++ isn't a good language at all. The problem is the students are focused more on getting the damn thing to compile finding where they missed the ";" vs. Understanding the logic and concepts being taught. I knew C before I started college so doing C++ wasn't much of a stretch, so I got more out of my education then some of the other students who didn't have the background their view is If it compiles then it is done.

Re:Maybe the real problem... (1)

Stochastism (1040102) | more than 6 years ago | (#22911434)

Languages don't kill programs,
programmers do ;)

But I tend to agree that C++ is the kitchen sink of languages, and this leads to confusion. I'm sure even B.S. has shaken his head in appalled wonder at some of the things people have done with expression templates and the such.

Re:Maybe the real problem... (1, Interesting)

Anonymous Coward | more than 6 years ago | (#22911638)

Bruce, you're absolutely right.

One only has to take a look at issues like const correctness and all the different ways one needs to declare "constness" in or out of the presence of pointers and reference variables to realize that Stroustrop gave birth to a monster that should have been aborted.

I've developed in C++ for 20 years now, and I've developed in SmallTalk, Common Lisp Object System, and Java.

Stroustroup should be embarrassed. C++ is complete shit and just gets shittier.

Anonymous Coward because I am currently involved in working a massive C++ system for the Army consisting of probably 200 developers -- and it's complete shit -- not because the developers are stupid and not because the Army is stupid and not because 200 developers is too many -- but because C++ is complete shit and a house is only as good as its foundation.

Re:Maybe the real problem... (1)

JamesP (688957) | more than 6 years ago | (#22911804)

I second that, absolutely.

Up to a point, C++ is a breeze. And then it falls. Hard.

Templates are a great idea, but guess what: strong typing makes it almost useless!! Yes, you can create thousands of different collection types with it, for pretty much everything, but it could be so much more powerful.

Or you build your 'generic thing' for a superclass, which is not generic at all.

Or you go down the 'template specialization'... not pretty.

And then you spend hours and hours trying to get a problem to get into C++ model when it would have already been solved if it was in whatever (other) language. Oh, I see, it wouldn't be OO then - except for Java (rolls eyes)

Re:Maybe the real problem... (0)

Anonymous Coward | more than 6 years ago | (#22911820)

I think you're confusing C++ with Java/C#.

A waste of time (0)

Anonymous Coward | more than 6 years ago | (#22911828)

The paradigm is changing.
People define problems.
Computers develop code.

Evolutionary computation trumps computer language development.

If you want to be a star in the next decades "obsolete skills",
then waste your time learning C or C++ or . . . .

C++ needs to improve (1, Insightful)

Anonymous Coward | more than 6 years ago | (#22911366)

It's way too complex to be managable, resulting in unmaintainable (No IDE can fully go through all typedefs; and if you ever stepped through a program and went into every godam -> operator of boost, you're on my side), unreadable and unneccesary code ("Better declare a private but not implemented copy constructor just to be sure"). It tried to implement all possible paradigmas at once, while trying to be backward compatible at the same time. It's the worst language ever.

Programmers needs to improve (0)

Anonymous Coward | more than 6 years ago | (#22911470)

It's that way because programmers insist on using features they don't have to just because it's there. They read Meyers, and think, "that's cool! I'll do that" I'm guilty of that one.

Education, even at Universities, needs to Improve (4, Interesting)

Lord Byron II (671689) | more than 6 years ago | (#22911398)

I'm continually amazed that the CS majors at my major US accredited university can't program using pointers, object oriented techniques, or parallelism. I think that there is an attitude among the professors that this material is difficult, so it shouldn't be worth a lot of points. As a result, the students don't bother to learn it.

I work in another department and sadly, without formal CS experience, I'm a better programmer than many (if not most) of the CS department's graduates. I don't think, however, that this problem is unique to my school. I've visited other US universities where the situation is very similar.

In fact, I recently took an informal survey of about a dozen CS seniors and found that none (yes, none) of them knew what K&R, the "white book", or the "Art of Computer Programming" were.

Re:Education, even at Universities, needs to Impro (5, Interesting)

IamTheRealMike (537420) | more than 6 years ago | (#22911460)

My university course spent about half an hour on pointers in a 3 year course. Most of that half hour was factually wrong: the slides were full of code samples that wouldn't compile or would always crash.

They did, however, spend two terms teaching Hoare logic. Or rather, they spent one term teaching it, and then repeated the same material in another term with a different lecturer, because their communication was so poor they never realised they had duplicated their teching.

Friends at other universities reported similar stupidities, though not always on the same scale.

C++ is a rather complex language, but simplifying it won't help. The problem is that low quality education is rampant.

Re:Education, even at Universities, needs to Impro (1)

DoofusOfDeath (636671) | more than 6 years ago | (#22911886)

C++ is a rather complex language, but simplifying it won't help. The problem is that low quality education is rampant.

I think you're having a "Tastes great / less filling" argument. Good education can somewhat prepare a person to learn and use an overly complex language. A bad education leaves a person less prepared to do so.

Having programmed in C++ for many years, and having lived through its evolution to include its nightmarish template system with its nearly incomprehensible error messages even for types as simple as strings, I'm ready to at least blame the language design. Feel free to also blame CS education if you've seen bad examples of it.

Re:Education, even at Universities, needs to Impro (0)

Anonymous Coward | more than 6 years ago | (#22911488)

I've seen the same thing at my university, except my skill lies in C rather than C++ (I code ASM and C on a daily basis). Pointers are your best friend when you know how to use them.

Re:Education, even at Universities, needs to Impro (1)

dkf (304284) | more than 6 years ago | (#22912022)

Pointers are your best friend when you know how to use them.
Umm, it's probably fairer to say that pointers are the professional power tools of the computing world. When you need them, they'll do wonders, but they'll just as happily chew big holes in both yourself and passing bystanders. Use with caution, but do use when needed.

Re:Education, even at Universities, needs to Impro (1)

MT628496 (959515) | more than 6 years ago | (#22911490)

Maybe it's not the case everywhere, but here the problems it that the CS department teaches entirely theoretical computer science, expecting you to learn everything else when you get to industry.

This is a horrible attitude, as many students (including myself) are not going into software development. Now, I took the initiative, bought a bunch of books, read articles and practiced using all of the techniques/design patterns etc for both OO and procedural languages.

Of course, students can't be taught everything in school, but if you go and ask a classroom of students here what polymorphism is, you'll get a lot of blank looks. The same goes with memory management in C/C++. People just don't know how to do it.

It's a real problem here and I don't really know the right way to fix it.

Re:Education, even at Universities, needs to Impro (0)

Anonymous Coward | more than 6 years ago | (#22911640)

You wrote:

"I recently took an informal survey of about a dozen CS seniors and found that none (yes, none) of them knew what K&R, the "white book", or the "Art of Computer Programming" were."

This is a nonsense survey. I happen to know what K&R, the 'white book,' and the 'Art of Computer Programming are, but I don't currently know how to program. In fact, I've read the white book several times and read parts of the Art of Computer Programming.

I got my B.Sc. in Comp. Sci in the 1970s and ... (5, Funny)

Anonymous Coward | more than 6 years ago | (#22911416)

I think COBOL and Fortran education needs to improve. Nobody knows how to use it nowadays. These kids and their OO languages... HEY! Get off my lawn.

C++ has issues (0)

Anonymous Coward | more than 6 years ago | (#22911418)

EXCERPT from my blog (I don't want to be slashdotted)

From my blog you may notice I am an inveterate C++ coder. It was the first language I taught myself after pascal and my preferred language for compact, fast code.The downfall of C++ may not be news to many, but often it is written by opponents of the language rather than those who love it and all of its quirks. So from a fan, C++, the prognosis is poor. I could write a book on this, but I tried to distill it down to article size.

Principle of Least Surprise

The first reason is that C++ violates the Principle of Least Surprise regularly and with malice of forethought. What do I mean by this? This compiles:

class ThreadPool{
public:
      ThreadPool(int thread_count); ...
};
int compute_bleah(int i){ ...
}
int compute_blah(ThreadPool pool){ ...
}
int main(){ //oops...
      compute_blah(5);
};

Why does this compile? Because unless you put the word explicit before the constructor taking an int as an argument C++ automatically converts any int to a ThreadPool whenever given the choice. The C++ community generally blames these sort of errors on the user for not being an expert in the language. This is stupid. In a sane language the language should do the most obvious and least damaging thing by default and require explicit permission to do anything else. In this case the language does the most bizarre and stupid thing unless you explicitly tell it not to.

This is not an isolated example. If you are a seasoned C++ programmer you probably still run into something like this once every couple of years you hadn't heard of before. In fact, the language does this so much that people created whole careers around coming up with new examples of C++ code that does something stupid and then explaining why.

Efficiency by default

This is really more of problem #1, but it deserves its own section because although C++ often does non-obvious things because it hates you occasionally it does stupid and non-obvious things because it is trying to save you memory and/or processing power. A classic example of this is:

class A{
public:
    ~A();
    void doSomething();
};
class B:public A{
    ~B();
    void doSomething();
};
void clean_up(A *a){
    a->doSomething();
    delete a;
}
void main(){
    A *b_as_a = new B();
    clean_up(b_as_a);
}

This code will call A's version of the doSomething method and the fail to call B's destructor. Why? because virtual functions have a (very) slight cost in memory and performance so C++ does the most efficient thing by default rather than the least stupid. If you want things to work correctly you the coder have to explicitly tell the compiler to make the destructor and method virtual with the virtual keyword.

Now, don't get me wrong. I know why this is. When C++ came out everyone in the C community was convinced that:

      1. Object oriented code could not be effecient
      2. noone should ever have or need more than 256K of RAM

As it turns out the C weenies were not convinced on #1 anyway and we all know about #2. Unfortunately this causes a long-term problem for C++: Those who want efficiency have stuck with C regardless (embedded world, GNU UNIX, BSD, etc, etc) and those who don't need efficiency but want and OO language (more and more every year) just use a modern language without all the cruft.

I would guess that some of those C weenies are looking at this and feeling pretty good about themselves now so let me just interject that if C++ is like the worst kind of coworker that does a lot for you but so poorly you wish they hadn't, C is the coworker who can be relied upon to do nothing for you at all. Yes, C has less of the annoying issues in terms of automatic resource management, exceptions, virtual methods because it makes you do everything yourself. Tables of function pointers anyone? Non-portable custom exception mechanisms? Memory errors due to lack of encapsulation? Yet I digress...

The other problem is that C++ is now going to have to fight with languages like D for the chunk of territory left to it. D has most if not all of the benefits that C++ does (apart from being mature I suppose) but has done away with a lot of the stupidity mentioned previously. If D doesn't do it then some other language will.

Not Created by a Despotic Organization

Funnily enough a lot of people think this is a good thing and make snide asides presumably aimed at Java and C#. C++ was designed and standardized by committee rather than an evil empire and I don't really see that the process has helped things. C++ has a lot of useless features. I would propose the best example of this being exception specifications (don't know what they are? In short: useless.).

More damning however is that there were and to some lesser extent are a number of compilers for the language not a single one of which actually implements the standard. This is supposed to be the benefit of a standardized language! This is a huge problem for C++ because it basically means you can't use almost any features and retain portability.

If you don't believe me take a look at mozilla.org's Portability Guide. I can sum it up for you if you'd like: if you have to write C++ please use as little of it as possible. Oh and another list of all the stupid reminders you have to continually provide to compiler to minimally reduce unexpected behavior. I actually work on embedded software at NASA and they have pretty much the same thing.

Despotic organizations happily do not have this problem. There is one official compiler and if your code compiles then it is correct. Done. No having to search through lists of standards or buying expensive third party tools and then writing incompatible code anyway.

No Standard Libraries

Again I understand the historical reasons for this, but this isn't an article about how C++ would be great if it was still 1990. C++ has very little in the way of a standard library. What is does have you can't use anyway because as per the previous point it wasn't implemented consistently across compilers because they don't support many of the features of the C++ language.

No threads. No sockets. No GUI. No big integer.

Now there are a large number of libraries provided by a number of different groups (boost and Microsoft being good examples). Unfortunately because C++ doesn't provide anything approaching a solid foundation for large libraries none of them share enough to play well with each other. Each has its own pointers, template meta-programming libraries, etc.

To some extent java and C# have this same problem but it happens at a much higher level. Also given the less complicated nature of the language adapters are usually relatively easy to design.

Instruction

This is the final nail in the coffin. Basically, C++ is being taken out of the computer science curriculum. Even my own alma mater University of Maryland has removed it and frankly the professors were pretty C++ illiterate anyway. (This sounds worse than it is given that the point of this article is that becoming an expert in C++ is very difficult and useless). There has been a lot of hand wringing about what this means for our new programmers and in some cases I agree. The bigger picture is that even those who have some reason to learn C++ will not be the sort of C++ experts that are required to avoid all the traps that C++ has set for its users.

Libraries like boost will be to some extent usable by those non-experts, but it isn't going to be maintainable by them. Using smart pointers is somewhat straight forward. Maintaining a cross platform compatible, template-based library us not. And given all the other issues why would you bother if you don't already have some skin in on the language.

Conclusion

So will C++ still be around 5 years from now? Of course it will. There is a pretty good code base out there using it and there are still those that cling to it like limpets. If you have something to prove, C++ provides a lot of pointless opportunities. On the other hand those who jumped ship from C to C++ are increasingly jumping from C++ to Java or C# (just look up some of the old C++ gurus and see what their blogs are about now) and those who still haven't dumped C aren't likely to suddenly get a passion for object oriented design.

I do want to briefly address the new C++ standard. it is now 2008 no one has implemented the last version. I am unwilling to wait another 10 years for someone to bother to implement the new C++ standard. And when they do I'm still not willing to forgive C++ its innate flaws as a language.

Re:C++ has issues (5, Insightful)

IamTheRealMike (537420) | more than 6 years ago | (#22911500)

C++ isn't going anywhere. Nearly all serious desktop software outside of Mac-land is written in it because the alternatives (Java? C#?) suck rocks. Large amounts of high performance code is written in C++. I don't know where you got the idea that people who care about performance use C from, that's flat wrong in my experience. I agree that D is a very nice language. It will make great strides in the next five yeras. However, maturity counts for a lot.

Re:C++ has issues (1)

EsbenMoseHansen (731150) | more than 6 years ago | (#22911730)

So let's see. While I will readily agree that C++ really needs a sane syntax, which would include having explicit the default, the real problem with the first program is poorly named functions and classes. Explicit would have saved you that time, but the poor naming would have killed you later anyway. The error in the second one is some programmer's inability to read warnings from the compiler, though again I agree that the default is a backwards. Yet, I have never been bitten by the either,eh, feature, though I have programmed C++ for some years now. (5? I forget).

So will C++ die? Someday, I hope. The problem is that very few languages support the features I need and want. I always forget some, but a short list would be

  1. Ability to make domain-specific libraries reasonable. No, matrixA.times(matrixB) is not good enough, it really must be matrixA*matrixB or similar.
  2. Polymorphy --- static and dynamic, of course.
  3. Lambda functions (closures for extra points) with a simple, inline syntax.
  4. LALR or similar simple syntax (for making programming tools easier to make)
  5. Metaprogramming
  6. Reflection
  7. static typing, divorced from inheritance of course.
  8. target agnostic (the language really shouldn't assume the target. I want to compile to i386, JVM or power5 as I wish
  9. Reasonable performance. Say, no less than a 50% slowdown.
  10. Direct, easy callable to C. JNI is a good example of how not to do this :o)
  11. At least simple lambda calculus. I want to be able to take two functions and make a third from them, given the arguments and return types a compatible.

I do not think these requirements are unreasonable. Yet no language comes close to doing all of these. I've found C++ to be the closests match, but especially the LALR, reflection and lambda functions are sorely missing.

I'm always interested in hearing about languages who comes close to this ideal, btw :)

C++ too ich and is fast becoming a niche language. (0, Offtopic)

MadHungarian (166146) | more than 6 years ago | (#22911424)

I do believe that most people who learned C++ did not do so in an academic environment. It was more on the job training. When I interview a candidate, one question is "How do you rate yourself as a C++ programmer on a scale of 1 to 10?" It is amazing how many of them in the 8-10 range cannot explain the difference between a reference and a pointer, and how you initialize a reference in a class. Or what mutable means, or what templates are, or even what the three key elements of object oriented programing. C++ is a very (too?) rich language. I think many of the features will become less and less used and atrophy like our appendixes. Eventually C++ will be come the next FORTRAN.

BTW I've worked with C++ since 1992, but not any more. I can be 5 times more productive in C#. I actually dread having to go back into C++ code to fix a problem. 90% of the code that was done in C++ can now be done in C#.

Re:C++ too ich and is fast becoming a niche langua (1)

UtucXul (658400) | more than 6 years ago | (#22911674)

Eventually C++ will be come the next FORTRAN.
Well, I'm finally moving from working on a FORTRAN 77 project to a C++ project in a few months, so I'm curious what you mean there. Maybe that like FORTRAN, C++ will never go away no matter how much we wish it would. And even worse that after using it for a while you secretly think it does some thing better than the more dominant languages but people look at you like you are crazy if you say so. For example, FORTRAN 77 has a better system for simple file IO than C/C++. There, I said it.

Re:C++ too rich and is fast becoming a niche lang. (1)

MadHungarian (166146) | more than 6 years ago | (#22911794)

C++ will continue to be used in very few specialized applications, but it popularity will decline. Like FORTRAN or COBOL, it will live on. Not like some languages that died a well deserved death (anybody remember APL?)

C++? Er det ikke dødt endnu? (0)

Anonymous Coward | more than 6 years ago | (#22911462)

Bjarne, du lukker lort ud igen. Dit sprog er så godt som ubrugeligt. Hvad med at starte på en frisk uden al det gylle, du har lukket ud om C i alle de år?

Det ville også klæde dig, hvis du lærte noget C, før du begynder på at "forbedre" det.

På forhånd tak.

Right on (0)

Anonymous Coward | more than 6 years ago | (#22911476)

I am with Bjarne on this one.
Bjarne Stroustrup, creator of the C++ programming language, claims that C++ is experiencing a revival and
that there is a backlash against newer programming languages such as Java and C#. "C++ is bigger than ever.
There are more than three million C++ programmers. Everywhere I look there has been an uprising
- more and more projects are using C++. A lot of teaching was going to Java, but more are teaching C++ again.
There has been a backlash.", said Stroustrup.

He continues.. ..What would the world be like without Google?... Only C++ can allow you to create applications as powerful as MapReduce which allows them to create fast searches.

I totally agree. If Java ( or Pyhton etc. for that matter ) were fast enough why did Google choose C++ to build their insanely fast search engine. MapReduce rocks.. No Java solution can even come close.
I rest my case.

He should go work for Microsoft ... (5, Funny)

Pinky's Brain (1158667) | more than 6 years ago | (#22911496)

"The standard will be finished in late 2008, but it takes forever to go through all the hoops of the ISO process."

They have a solution for that ...

Bjarne Stroustrup doesnt have a clue (0)

Anonymous Coward | more than 6 years ago | (#22911520)

After reading numerous articles from this guy it is clear to me that Bjarne Stroustrup has no idea what he is talking about in regards to C++.

Not just C++ (1)

ErichTheRed (39327) | more than 6 years ago | (#22911528)

Disclaimer -- I'm a systems guy. I think I have a unique perspective though -- I get to deal with lousy software after it's been released.

I came into IT through the back door. I was a science major in college, messed with computers all the time as I was growing up, and realized I could make a better living in IT than I could in science. So yes, I don't have a ton of programming experience. I have picked up a lot of information over the years on how operating systems actually work under the hood though.

  If I'm given another internally-developed desktop application that does simple database calls requiring a dual-core processor and a minimum of 512 MB of RAM to run, I'm going to go crazy.

I agree with Stroustrup. There really isn't enough good computer science education these days. Computers have gotten so fast and powerful that there's no need to optimize code anymore. This explains why everyone's programming in Java and .NET. Without super-fast computers, any programmer would shy away from compile-at-runtime software. The solution for making a program run faster these days is to throw a bigger box at it. I deal with this every day, trying to explain to project managers and CIOs why we need more money in the hardware budget again.

And I agree with everyone who correctly points out that this isn't 1981. Sure, we don't have to squeeze an entire video game into a 4K Atari 2600 cartridge anymore. But I've seen stuff written internally that's just total garbage, and all of it could be solved by thinking a little bit before attacking the problem. Most of the stuff I deal with is straight from http://www.thedailywtf.com./ [www.thedailywtf.com] Think of massive switch() statements that check hundreds of possibilities, iterating over each entry in a million-row database query result, etc. Everyone in corporate-land has dealt with apps like these...click the Submit button and wait 3 minutes for a result. :-)

Some of this can't be avoided. Most corporate IT departments don't understand the difference between good and bad applications. But I think that if we get people interested in embedded systems or something, things may fix themselves. I highly recommend not teaching CS students Java as their first language....

Re:Not just C++ (1)

skrolle2 (844387) | more than 6 years ago | (#22911654)

Computers have gotten so fast and powerful that there's no need to optimize code anymore. This explains why everyone's programming in Java and .NET.
I was with you up until the above. What? No, no. Java and .Net are popular because you get the power and flexibility of C++ and other compiled OO languages, but you get the increased productivity that managed code gives you. It is a *lot* easier to create an application in Java or .Net that is good enough, runs fast enough, and has no memory leaks, than it is to create the same application in C++.

There is a bunch of stuff where C++ is a much, much better choice than Java or .Net, but for the majority of corporate applications, it is overkill.

That people create stupid applications and don't know the basics of efficient algorithms isn't something you can blame managed languages for, if those people had to do their stuff in C++, it would still be horribly inefficient, only now with more memory leaks.

I highly recommend not teaching CS students Java as their first language...
Me neither, Lisp is a much better choice.

Re:Not just C++ (0)

Anonymous Coward | more than 6 years ago | (#22911896)

My first language at Univ. was ML.

C++ outside of SYSTEMS programming is the WRONG choice of tool. It is NOT an APPLICATION language.

Anyway, there are far better choices for domain specific tools.

C++ was designed as a SYSTEMS language, not for anything else.

If you find you pushing or using C++ for applications, then somebody made the WRONG choice. Fanboism does not belong in software development, anyway developement is a BLUE collar job anyway, unless you are a domain specialist in which case these are just tools and fanboism is not a factor.

What I hear on slashdot regarding C++ is 90% fanboism.

Re:Not just C++ (1)

gbjbaanb (229885) | more than 6 years ago | (#22911980)

Teaching lisp, prolog, simula etc at university is an excellent idea. Make them think.

As for .Net being better - tell the Princeton university DARPA team that C# doesn't have memory leaks. Read Chris Brumme's blog [msdn.com] for all the grubby hacks that MS made in the CLR to make things work.

the thing is, if you tell a less-capable programmer that he doesn't have to worry about memory, he'll think christmas has come early and he will stop worrying about memory... as a result his code will become poorer, resource consumption will increase dramatically, performance will tank and scalability will be non-existent. And his code will become even less maintainable.

Now make him program in a language where he is punished for cocking things up, he will *have* to become a better programmer or nothing he does will get released.

Now, that's an ideal, in the real world poor code will still get shipped to customers regardless of how it was developed; but the code written in an 'easy' langauge will still contain bugs.

eg. I saw a recent question on our internal tech mailing list - someone asked why his code was failing to connect to the DB, he was told "oh you have to put gc.collect() in any loop tht connects to the DB to fix that".

C++, the assembly language of today (0)

Anonymous Coward | more than 6 years ago | (#22911580)

The fact is that, in C++, OOP is purely a structural thing, not a conceptual thing that goes through the environment.

With this freedom, you have to device enormous amounts of information just to cooperate with other programmers, and just so people can begin to do the work.

OOP hasn't been slow, however, the earliest implementations of this concept was dynamic, and was done in virtual environments, so that would explain slowness.

C++ is basically the assembly language of today, with its performance-oriented level of interaction with the machine. Throwing more concepts on this platform is not going to improve it, HOWEVER, if you give it at least 20+ years, when people aren't taught the other paradigms from the start, a behemoth framework is has been tacked on it, so it's basically #include and start coding. C++ is basically Windows on MS-DOS.

I know, I've been programming in C++ for eight years now, and assembly language before that.

-Ray

Note to Bjarne, please stop! (0, Troll)

tralfaz2001 (652552) | more than 6 years ago | (#22911586)

Dear Bjarne,

Your language is broken. It was broken very early on, but at least it could be described in 200 pages of densely printed text. Now it has grown to insane proportions in ever more elaborate attempts to add feature upon feature in an effort to satisfy every possible programmers syntactic fetish. Until it is at the point where anyone attempting to use the language spends more time trying to master the tool, rather than using the tool to create the end result.

Because of the absurd feature set, it has become nearly impossible to master the full breadth of the language. This manifests itself in the worst way when you have a group of coders each knowing different features of the language, with only a small subset that makes up the intersection of every coders C++ skill. The end result is that programmer A spends half his/her time trying to figure out what programmer B did with the language, rather than the what problem the code was trying to solve.

The most important thing to teach about C++ is how not to use it. By that I mean teachers should be telling their students, "This language has a 1000 features (or is it 5000 now I lost count), you should only learn about 100." The key is which 100. It is great for low level coding, an improvement over C if used judiciously. If used to construct complex object systems it is a horrible choice. Higher level dynamic languages are the way to go.

Bjarne if C++ is to continue to be used, you need to stop dumping more garbage into the putrid landfill that C++ has become. Instead it should be stopped in its tracks, and the programming community should restart a new C extension that takes some of the useful ideas of C++, simplifies them, and carefully limits any attempt to add features without any real value. In short do what you completely failed to do.

Oh and Bjarne your language deity status is here by revoked due to abuse of power.

Re:Note to Bjarne, please stop! (1)

twistedcubic (577194) | more than 6 years ago | (#22911932)

One of the reasons C++ will never die is that it is extremely useful to people who write highly specialized code. There are A LOT of people/groups who do this (and you will never believe this, but that's your problem). For some things, even doing quick proof-of-concepts in Python/Perl/C/Whateever would be a pain because representing basic objects is so complicated that they can only be expressed easily in certain languages. It seems to me that people who are turned off by C++ see its misuse in corporate environments, where any simple, general-purpose programming language will do. In other areas not as visible to the typical contract/corporate programmers, scientists and engineers need a language powerful enough to reasonably represent almost any concept they need. C++ is the best thing we have.

Re:Note to Bjarne, please stop! (2)

gbjbaanb (229885) | more than 6 years ago | (#22912004)

Seeing as you're counting the STL in that list of features, I trust you do the same for Java or C# - how many do they have if you count the innumerable library features they support?

Too little too late syndrome (0, Troll)

thelima (1045360) | more than 6 years ago | (#22911600)

For me it's typical "too little too less" syndrome. C++ played its important role years ago. Since then world has hanged dramatically. Current buzzowords dynamic languages, lambda expressions, clsoures and all this stuff and nobody cares if it makes sense or not. Sure - having known C or C++ it gives a lot advantages - You understand difference between heap, stack and pointers memory management - and gives You *real* understanding what, for example, closure is. But, on the other hand - who cares nowadays, except some really specialized areas like system development (actulally done in C), game development (partially) or HPC development (also partially). Actually nobody. That's said. Noody cares about C++0x or whatever it's named... Having 10+ years of core C++ development I actually even don't wanna read this spec. Word's going forward, languages going forward and nobody cares nowadays about unicodes support build in language or huge and convenient standard library (oh, maybe Ruby still do, last time I checked Ruby lacked unicode support also...). So far well C++ but don't expect people be excited now.

lima

Still builds too slowly (1)

ahornby (1734) | more than 6 years ago | (#22911608)

C++ header files basically guarantee a slow build due to reparsing. Precompiled headers only help if you don't change a prototype.

If you could have C++ but pull class/function prototypes out of the object files like with Java or C# it would fix a lot of build time problems as you would never need to reparse a header.

http://gcc.gnu.org/wiki/IncrementalCompiler [gnu.org] may be of use if you still hold out hope of faster C+ builds...

Poor use of C++ (0, Troll)

MosesJones (55544) | more than 6 years ago | (#22911610)

I think that most poor use of C++ can be traced to the use of C++. C++ was about the fifth or sixth language I worked with professionally and without a doubt it was the biggest load of crap out I've ever had the misfortune to come across. Things like "friends" which enabled muppets on the project to complete subvert the principles of the project. The brain dead syntax (inherited from C like Java and C#) which values keystrokes over clarity. Unlike PHP or Perl where only the clinically insane would use them on a large scale (30+ developer) project C++ was habitually used on just that sort of development.

C++ education should be short and sharp....

If you want speed do C or assembler.

If you want OO do Eiffel or Smalltalk

If you want a job do C# or Java

Don't do C++.

Re:Poor use of C++ (0)

Anonymous Coward | more than 6 years ago | (#22911712)

If you want to fuck the world with MS dependency, use Java.

C and assembler are poor in optimizations, dude. I guess if you really knew shit you wouldn't make these lame mistakes.

level of abstraction complexity. (1)

3seas (184403) | more than 6 years ago | (#22911658)

There seems to be a direct relationship between level of abstraction meaning complexity required in application and the learning curve.

A trade off of higher learning curve for faster programming with more complex abstractions vs. lower learning curve for less abstract complex language application.

In the simplest example and using the basis of common computers:
When you mark a switch with a symbol of a "0" and a "1" what does it mean? On/Off or a variation inbetween these like standby, sleep, or any other thing besides on/off?
What is function overloading of this switch? How many users of computers don't know about the 5 second button push? Isn't the symbol consistant with its use on other devices like TV's ...

I just told my neighbor, who is retired and had been dealing with computers for a long time, how to shut the computer off by holding the switch/button in for five seconds.

There is a reason why C++ usage is what it is and its not due to failure to explain the way the designer was thinking, but rather that it is to abstract for the pace and change rate of today.
In other words, those who use it correctly have managed to learn to think like the designer. But not everyone thinks in the same way (i.e. some people think primarily in terms of words, others in terms of numbers and still others in terms of visual images or sounds.)

Arrogance is hard for one to see of themselves. A matter of inherent subjectivity. That is what he fails to see, Not what others fail to understand of his mindset.

In other news... (2, Funny)

192939495969798999 (58312) | more than 6 years ago | (#22911686)

Profs. Einstein and Hawking are upset that people don't know more phyiscs, James Gosling is upset that people don't code better Java, and Picasso is upset that more kids don't take art class.

OK I'll say it.. (1)

CrazyTalk (662055) | more than 6 years ago | (#22911768)

Does anyone still USE C++ any more? Seems the only ones around where I work who even know C++ are the old timers. Recently, the consulting company I work for had the opportunity to hire a number of C++ programmers for a legacy project - we had one guy on staff, and couldn't find ANYONE else with the necessary skills.

mod dow8 (-1, Offtopic)

Anonymous Coward | more than 6 years ago | (#22911810)

FreebSD h8ad long

I wholeheartedly agree with Stroustrup (1, Flamebait)

rolfwind (528248) | more than 6 years ago | (#22911852)

C++ education needs to improve.

The best way to go about it is to stop teaching it. That would be a major improvement right there.

Coding a C++ compiler... (2, Interesting)

GNUPublicLicense (1242094) | more than 6 years ago | (#22911854)

... even a basic one, non optimizing one, is an insane task (compared to a C one for instance). Around me, computer science students have to code a fully featured toolchain to reach for their diploma... and quite strangely, only C is able to make it... as soon as you talk C++ (not even its runtime library...), usually it is followed by "mentally ill" or "crazy" or "monstuous project" or ... well you get the idea. The C++ (or any similar language/framework) price in term of toolchain complexity (I'm not talking about gcc complexity but the complexity of writing a full featured one from scratch) is, for many coders, unreasonably high.

I've written some educational C++ articles (4, Informative)

MichaelCrawford (610140) | more than 6 years ago | (#22911880)

They're at GoingWare's Bag of Programming Tricks [goingware.com] , and are more in depth than most online tutorials.

The articles are:

  • Sermon at the Soup Kitchen: On C++ Software Quality and Institutional Resistance to Change
  • Pointers, References and Values: Passing Parameters, Returning Results, and Storing Member Variables with Musings on Good C++ Style
  • On Refactoring C++ Code
  • Pointers to C++ Member Functions
I'm no Stroustrup, but I've received quite a bit of praise for writing these.

He could start in his own department... (0)

Anonymous Coward | more than 6 years ago | (#22911926)

At Texas A&M University (where Stroustup is), the professor who "teaches" C++ could use a lot of improvement. I took it several years ago, and it was mainly just Dr so-and-so rambling on about general topics to programming and trying his best to ensure there is not a moment of silence in the room.

The half-dozen assignments were mostly to make small changes to an existing program that took maybe 3-4 hours to complete in TOTAL. And the program itself was badly factored, with a mismash of header files that did not match the .cpp files, no error reporting whatsoever, no clear pattern of which parameters are input vs output, etc., in other words a code style that I would have been physically beaten for using in the Real World.

The prof has such a low bar that anyone with two neurons can get an A, so naturally his ratings at pick-a-prof and whatnot are very high.

32 year programmer -- use C++ (0, Troll)

mlwmohawk (801821) | more than 6 years ago | (#22911944)

I have been programming computers since 1976, and back then it was BASIC on a PDP-8e. Depending on your perspective, that either makes me experienced or a dinosaur. Keep your opinions, and enjoy them. Unless tragedy strikes, you too will hopefully gain some experience in life and be forced to listen to those who don't know 1/10th of what you do, and be forced to look back on your own behavior and wince about things you've said and thought to be right that were actually misinformed.

OK, "off my lawn" speech over.

IMHO everyone who complains about C++ is a pedantic fool. Nothing is perfect, no language, no computer, nothing. I loved what Stroustrup said in the article about becoming "language lawyers," rather than programmers. I am frequently amused about java vs c++ or .net vs c++ arguments. With the [java | .net] proponents focusing on ambiguities in C++ or (gasp) pointers.

I come from a more renaissance period of computer science. Practitioners found it both necessary and valuable to know and understand "how" their programs actually worked. We needed to know how macros in the assembler worked. How addresses in labels got fixed up by the linker. How machine instruction permutations were constructed based on the assembler instructions. How to write an efficient "divide" function because the processor only added and subtracted. Forget floating point. Not to mention the mathematical efficiency of algorithms and so forth. Most of this stuff is black magic to most programmers today.

C++ has its flaws, absolutely. However, if you use "C" constructs, it is as efficient and as readable as C. If you conceptualize the logical constructs of your application as a hierarchy of objects, it can do that too. You can even easily and efficiently use assembler and pure C functions.

The root cause of bad C++ is bad C++ programmers. It is not COBOL and it will not protect you from doing something stupid. Just because you can do something syntactically correct, doesn't mean it is logically correct. A good rule of thumb to think about is this: If you don't understand how it will work, don't do it.

The argument that some features shouldn't be in C++ because of these problems sort of misses the point. A bicycle falls over without training wheels but is useless for serious riding with them. C++ without the features that can be misused would merely be a bicycle with training wheels.

Stop wanting everything to be "easier" to learn, some things become "easier" with learning.

Sadly... (2, Funny)

Kingrames (858416) | more than 6 years ago | (#22911968)

When trying to point the blame, his pointers went everywhere, and his program terminated abruptly.

Strostrup is the problem (5, Interesting)

Animats (122034) | more than 6 years ago | (#22912000)

The big problem with C++ is Strostrup. He's in denial about the fact that the language is fundamentally broken. But he's still influential in C++ circles. Thus, no one else can fix the mess at the bottom.

The fundamental problem with C++ is that it has hiding ("abstraction") without memory safety. This is the cause of most of the world's buffer overflows. No other major language has that problem. C has neither hiding nor memory safety, so it is still vulnerable to buffer overflows, but they're to some extent visible at the place they occur. Pascal, Modula, Ada, Java, C#, and all the interpreted "scripting languages" have memory safety. C++ stands alone as a language where you can't see what's going on, and the compiler doesn't have enough information to check subscripts.

The reaction of the C++ standards committee has been to try to paper over the problems at the bottom with a template layer. That didn't work. The template classes just hide the mess underneath; they don't make the language memory safe. There are too many places that raw pointers leak out and break any protection provided by the templates. The template language itself is deeply flawed, and attempts to fix it have resulted in a collection of "l33t features" understood and used by few, and too dangerous to use in production code.

The fundamental cause of the trouble comes from C's "pointer=array" equivalence. That was a terrible mistake, borrowed from BCPL. The trouble is that the compiler knows neither which variables are arrays nor how big the arrays are. You can't even talk about arrays properly. I mean, of course,
int read(int fd, char* buf, size_t len);
That's just trouble waiting to happen. "read" has no information about how big "buf" is.

C++ added references to C, and should have added syntax like
int read(int fd, char& buf[len], size_t len);
to go along with it, so that arrays became first-class objects with sizes. But it didn't. There are some other things that have to be done to the language to make this concept work, but this is the general idea. This is the elephant in the living room of C++, and Strostrup is in denial about it.

Every time you have another crash from a buffer overflow, every time you install another patch to fix a buffer overflow, every time you have a security break-in from a buffer overflow, think of this.

Why? (1)

EddyPearson (901263) | more than 6 years ago | (#22912002)

Why? Market forces dictate demand for a skill or service, this is simply shameless promotion of his own language.

If we really DID need better/more C++ coders, then they would appear.
Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...