Beta
×

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!

Bjarne Stroustrups and More Problems With Programming

Zonk posted more than 7 years ago | from the nothing-pleases-a-programmer dept.

Programming 313

Phoe6 writes "As a follow up to the first part of his interview, Technology Review Magazine has another article running titled 'More Trouble with Programming'. Bjarne Stroustrup shares his point of view on good software, bad software design and aspect oriented programming." From the article: "Technology Review: Name the coolest and lamest programs ever written in C++, and say what worked and didn't work. Bjarne Stroustrup: Google! Can you even remember the world before Google? (It was only five years ago, after all.) What I like about Google is its performance under severe resource constraints. It possesses some really neat parallel and distributed algorithms. Also, the first Web browsers. Can you imagine the world without the Web? (It was only about 10 years ago.) Other programs that I find cool are examples of embedded-systems code: the scene-analysis and autonomous driving systems of the Mars Rovers, a fuel-injection control for a huge marine engine. There is also some really cool code in Photoshop's image processing and user interfaces."

cancel ×

313 comments

Sorry! There are no comments related to the filter you selected.

Coolest and lamest! (4, Funny)

Anonymous Coward | more than 7 years ago | (#17179176)

It is,

int main()
{
      cout "Hello World" eol;
      return 0;
}

Very cool at first, then it just goes down from there.

Re:Coolest and lamest! (1)

gangien (151940) | more than 7 years ago | (#17179228)

as cool as html parsers?

Re:Coolest and lamest! (1, Funny)

Anonymous Coward | more than 7 years ago | (#17179368)

Very cool at first, then it just goes down from there.

You are of course referring to int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow). Hello World! just doesn't feel the same when you have to write 100 lines of code to get it to work.

Java (5, Funny)

goombah99 (560566) | more than 7 years ago | (#17179418)

Javac is the coolest program written in C++ :-)

Re:Java (0)

Anonymous Coward | more than 7 years ago | (#17179464)

Javac is written in Java. The JVM is written in C++.

Re:Java (0)

Anonymous Coward | more than 7 years ago | (#17179574)

Javac is written in Java.
Really? I wonder why I never see the JVM start up when I compile with javac.

Re:Java (0)

Anonymous Coward | more than 7 years ago | (#17179674)

Ever hear of a java compiler?

Re:Java (2, Informative)

Iffy Bonzoolie (1621) | more than 7 years ago | (#17180004)

What do you mean by "see the JVM start up" ? It doesn't have an animation or anything - javac is a native stub that launches the VM and invokes the compiler. It's all within that "javac" process. Now, there is a native Java compiler: Jikes. But last I checked it was pretty outdated. Also, GJC will compile Java to native code, and it is also native, but I haven't played with it yet.

-If

Re:Java (1)

Wavicle (181176) | more than 7 years ago | (#17180934)

I wonder why I never see the JVM start up when I compile with javac.

Because you aren't paying attention. Javac is in the package com.sun.tools, see documentation here [sun.com] .

When you're done reading, download jikes [sourceforge.net] and use that instead.

Lamest - Slashdot HTML parser (2, Funny)

Anonymous Coward | more than 7 years ago | (#17179438)

Where in "Plain Old Text" you have to escape < as &lt;

Re:Lamest - Slashdot HTML parser (0)

Anonymous Coward | more than 7 years ago | (#17179460)

slashdot (and their HTML parser) are in perl.

(it probably would be even lamer if they wrote it in C++, though).

Re:Coolest and lamest! (1, Funny)

Anonymous Coward | more than 7 years ago | (#17179540)

No, you have already used C++ syntax. At this point, it is not too late to correct your ways, but otherwise, it really is downhill from there.

Stroustrups (5, Informative)

abshnasko (981657) | more than 7 years ago | (#17179188)

Please... he's one of the most influential people in the field of computer science today, at least spell his name right.

Re:Stroustrups (0, Troll)

WilliamSChips (793741) | more than 7 years ago | (#17179260)

No, he has nothing to do with computer science. Programming, yes, but computer science doesn't use C++.

Re:Stroustrups (2, Informative)

abshnasko (981657) | more than 7 years ago | (#17179316)

Programming, yes, but computer science doesn't use C++.

Unless you get your CS degree to try to develop a faster sorting algorithm, you are going to be doing some type of programming. He is head of the CS department at Texas A&M, to say he "has nothing to do with computer science" is ridiculous.

Re:Stroustrups (1, Insightful)

WilliamSChips (793741) | more than 7 years ago | (#17179472)

Programming, yes, but not in C++. Generally, Computer Scientists use languages like Smalltalk, Scheme and Haskell which aren't bundles of watered-down paradigms.

Re:Stroustrups (4, Interesting)

macshit (157376) | more than 7 years ago | (#17179694)

Actually the vast majority of recently written (last 5 years) code I've seen from CS departments (at very good schools) has been in Java, with C++ a somewhat distant second. This seems to apply across the board, from hard-core long term research projects to undergrad frameworks to quick experimental coding.

I don't particularly like java (and it's particularly painful watching the hoops people jump through to make it perform well), but while it doesn't seem to really be the best at anything, I guess on average it turns out pretty well -- it's pretty safe, pretty fast, pretty readable, pretty well supported, pretty widespread, ... One important point that many people seem to ignore is that java seems to have huge number of freely available libraries, often for somewhat specialized subjects.

The languages you mention are all great languages, and have carved out productive niches, but they seem to remain niche languages, even in academia...

[Disclaimer: I have never written a java program (!), though I have read many...]

Re:Stroustrups (1)

another_fanboy (987962) | more than 7 years ago | (#17180142)

One important point that many people seem to ignore is that java seems to have huge number of freely available libraries
The biggest argument I have against C++ is the disorganization of the libraries. Having used Java, I find them (generally) well structured and easy to use with minimal previous experience required. I will admit, however, that the libraries often feel bloated in their generality.

Re:Stroustrups (2, Insightful)

mrchaotica (681592) | more than 7 years ago | (#17180584)

You know why schools teach Java instead of C++? So they don't have to teach pointers first. At least that's how it seems to work at Georgia Tech...

Re:Stroustrups (1)

cnettel (836611) | more than 7 years ago | (#17180792)

Well, you really can get away get quite well without using pointers in C++. It won't be fast, it won't always be pretty, but you really can write non-trivial stuff with only references and STL containers doing the allocation. What's really hard is to do C++ without both pointers and non-trivial use of templates...

CFG (2, Interesting)

sadler121 (735320) | more than 7 years ago | (#17181182)

What is a language anyways but a context free grammar? The school I goto teaches Java as the primary language, but once you get into the junior, senior classes you branch out into C and C++ (they even teach Cobol, ewww, I know). Once you take on Automata and Computability, and learn about CFG's then the language isn't the problem. On the other hand, learning a paradigm (like OO vs Structural) can be a bitch.

Re:CFG (3, Informative)

BitchKapoor (732880) | more than 7 years ago | (#17181310)

What is a language anyways but a context free grammar?

Semantics.

Re:Stroustrups (2, Interesting)

Nataku564 (668188) | more than 7 years ago | (#17179758)

As a bit of anecdotal evidence, I offer up my university - UW Milwaukee. All required programming courses are C++. Electives exist for most of the languages you mention, but no student is required to learn any of them. From what I hear of people I have hired from UW Madison, that school is a Java shop - again, with electives for the more obscure language.

But then, of course, this is Wisconsin we are talking about. We tend to be practical up here, and have students learn stuff they will actually use in the industry. Learning the other stuff helps with the theory, since most of them have better models - but no significant real world usage.

Re:Stroustrups (2, Informative)

Anonymous Coward | more than 7 years ago | (#17180270)

That's education, not research. Computer science gets done in a variety of languages. Everything from asm on up gets used. C and C++ included. To say that "computer science doesn't use C++" is incredibly ignorant. Plenty of evidence to the contrary [google.com] . Not that it's entirely relevant, but keep in mind that a lot of computer scientists don't write

Re:Stroustrups (-1, Troll)

Anonymous Coward | more than 7 years ago | (#17179914)

Real Computer Scientists use MIX [wikipedia.org]

Re:Stroustrups (0)

Anonymous Coward | more than 7 years ago | (#17180204)

Generally, Computer Scientists use languages like Smalltalk, Scheme and Haskell which aren't bundles of watered-down paradigms.

Serious ones, sure. Most CS students just want a programming degree so they can get a job. They're not really serious computer scientists.

Re:Stroustrups (4, Insightful)

EvanED (569694) | more than 7 years ago | (#17179506)

Programming, yes, but computer science doesn't use C++.

Bull. At least sort of.

First, it depends in part on what your definition of computer science is. Most CS courses are taught in a C-like languages. At my undergrad institution, most of my programming assignments were done with C++. Sure, there was exposure to ML, but my impression is that most places that's mostly confined to the PL classes. (There are some notible exceptions that use ML or Scheme for intro courses.) Even at those institutions, I expect that later classes have assignments in a C-like language.

Second, there's a lot of CS that relates to C++. Compiler theory of how you implement things about it, and language design. It's not about C++ specifically, but it certainly relates.

Third, there is a fair bit of work in PL that directly relates. Not all PL is people in ivory towers coding in ML and Lisp. CCured is a very nice bit of work, though it's only C because it's built on top of the C Intermediate Language (CIL). There's early work now to create a CIL++, and I'm sure that it hasn't escaped anyone there about the potential to extend CCured to C++ once that's done. The parser for CIL++ will be something called Elsa, which was a major part of the research of one of the people there. My own research is indirectly related even. I'm looking at static analysis of binary code. Earlier work done in my group was explicitly directed to being able to find vtable pointers that C++ compilers produce.

You're right to the extent that the core of CS is really in some sense applied math, and is entirely language-neutral. However, to say that C++ has no relation to CS because it's just programming (which CS isn't about) is just wrong.

Re:Stroustrups (1)

sunwukong (412560) | more than 7 years ago | (#17179756)

Bull. At least sort of.

That's probably the most succinct description of academics, ever.

Your three points just clarified that it was CS you're specifically talking about.

Re:Stroustrups (3, Insightful)

Watson Ladd (955755) | more than 7 years ago | (#17180760)

Penicillin. Lisp. BSD. Shannon's information theory. Smalltalk. The Web. The Internet. All of these came out of academia. Saying that academia is bull is saying that pure research counts for nothing. Well, look at number theory. Once considered unsullied by practical applications it now is used in cryptography. The atomic bomb started as pure research.

Re:Stroustrups (2, Interesting)

Anonymous Coward | more than 7 years ago | (#17179864)

Agreed.

There is also another little spoken of field of Computer Science called Systems. Many people claim that all systems research is dead, but there's really still much more to do. In systems they care ALOT about languages like C++. More recent experimental OS' like L4 are often implemented in C++ (often ignoring the bulk of the language features). PL people even are actually very interested in languages like C++. Yes they blelieve such languages are the bane of our very existant and the fact that any systems written using it work is nothing short of a miracle (a point I actually happen to agree with). But they also still have to look down occasionally at what is actually used and what does work, and figure out what bits of those systems are and aren't interesting.

Yet another huge point here is that when C++ was designed and written it really had one goal in mind, which was to bring the wonders of object orientedness to the unwashed masses of computer programming. At the time real code was written in C, Fortran, Pascal, Lisp, and Cobol primarilly. The more practical of these are very unstructured languages. C++ was an attempt to add structure to C, without breaking it's fundamental usefulness as a systems lanaguge. This was, in a very real sense, a research project. Someone invented a language and set it loose on the world to see if OOP could really hold it's own. Much to the anguish of many PL people it appears to have fluroushed in the jungles of industrial programing, but this was certainly an experiment.

Now as it happens I personally detest C++ (though I've certainly coded in it from time to time), but it's invention was most certainly well within the realm of computer science. Arguing that it's not is like arguing that Von Neumann wasn't a computer scientist because he was just an "systems guy" not a hard-core mathematician.

Re:Stroustrups (1)

rolfwind (528248) | more than 7 years ago | (#17180938)

Arguing that it's not is like arguing that Von Neumann wasn't a computer scientist because he was just an "systems guy" not a hard-core mathematician.


Um, Von Neumann was a hard-core mathematician.

Re:Stroustrups (1)

oldhack (1037484) | more than 7 years ago | (#17180620)

Computer science is an applied math where programming is essential. If you can't program a computer, i.e., there is no programming, CS should just be a sub discipline within math dept (mechanized math?).

Re:Stroustrups (1, Flamebait)

TrappedByMyself (861094) | more than 7 years ago | (#17179288)

This site is about new spam, not accuracy, so keep your hopes down. Gems like this hidden in the muck of Microsoft bug articles (which are needed to pay the bills) still make Slashdot useful.

Re:Stroustrups (1)

maxume (22995) | more than 7 years ago | (#17180090)

itsatrap.

Re:Stroustrups (1)

Scrameustache (459504) | more than 7 years ago | (#17179988)

spell his name right.
Yeah, but... Couldn't he have choosen a coller alias? Like Commander Taco or something, anything but Smurf Stirrups.

Re:Stroustrups (1)

Durandal64 (658649) | more than 7 years ago | (#17181146)

Why don't we just dereference him and call him 'B'?

Google's in C++? (2, Informative)

feijai (898706) | more than 7 years ago | (#17179202)

My understanding was that much of Google was in python.

Re:Google's in C++? (4, Informative)

say (191220) | more than 7 years ago | (#17179240)

Googlebot is mainly written in Python. Google is mainly written in C/C++.

Re:Google's in C++? (4, Informative)

Anonymous Coward | more than 7 years ago | (#17180210)

No Google bot is written in C++
http://www.robotstxt.org/wc/active/html/googlebot. html [robotstxt.org]

When you need high performance, C++ is better choice than any other language. Google(or Yahoo) wont have a single language framework to run its platform. Always it will be combination of languages. Whatever have I read so far Google's core search engine is in C++ and several C++ libraries are available as python modules. Standalone products may be written in specific languages. Gmail and Google Calender are written in Java.

Re:Google's in C++? (2, Interesting)

Marcos Eliziario (969923) | more than 7 years ago | (#17179254)

No, not the data-crunching engine, not the indexer, not the ranker.... Python (and java, and ruby) is cool, but, frankly... sometimes you need the most of your hardware.

Re:Google's in C++? (2, Insightful)

abshnasko (981657) | more than 7 years ago | (#17179268)

How could something that large and efficiency-dependent be written in non-native code?

Re:Google's in C++? (1)

dubbayu_d_40 (622643) | more than 7 years ago | (#17179996)

Continous/adaptive compilation. Like Java Hotspot.

Re:Google's in C++? (1)

AuMatar (183847) | more than 7 years ago | (#17180626)

While those techniques are better than pure interpretation, they're still a good 40% slower or more than native code.

Re:Google's in C++? (1)

IamTheRealMike (537420) | more than 7 years ago | (#17180866)

There are at least two reasons why GoogleBot isn't written in Python. Firstly it's a very large and complex piece of code. Anecdotally, for very large codebases a statically typed language like C++ seems to work better with respect to allowing many developers to work together, because it requires and allows you to specify interfaces in a checkable way. Secondly it's performance sensitive. Your suggestion of continuous/adaptive compilation doesn't work because the resources that are used to redundantly compile/optimise a program "in flight" many times for each machine/run of the program could be better used to, say, crawl the web. Generally, it's much more efficient to compile something once on a developers machine and let the compiler ponder the program as a whole, then upload the finished result to the machines.

Re:Google's in C++? (0)

Anonymous Coward | more than 7 years ago | (#17179324)

This is a common misconception that is usually toted out by the Python crowd. So far, Google uses Python primarily for small scripts and a couple of simple applications that are internal to the company. Everything that is of any significance is written in C, C++ or Java. C and C++ are usually used for stand alone applications and systems programming, while Java is used for the back end for most of their web applications.

Re:Google's in C++? (1)

j3richo (674251) | more than 7 years ago | (#17179440)

Greg Stein has said there is more Python code in Google than Java during one of those Q&A at Pycon, so it's not accurate to say it's only used for small stuff.

Re:Google's in C++? (1)

chris_mahan (256577) | more than 7 years ago | (#17179722)

Maybe java is used for even smaller stuff?

j/k

Re:Google's in C++? (5, Informative)

LauraW (662560) | more than 7 years ago | (#17179706)

What I usually say when interview candidates ask about this is that back-end and data crunching code tends to be C++, web GUI front-end stuff tends to be Java and Javascript, and scripts tend to be Python. Whatever tool works best for the job. It's not much different from what I've seen at other jobs, except for using Python instead of something like Perl. But there are no hard and fast rules. For example, there was a slashdot article [slashdot.org] last week about an internal web app written in Python. Here's an older article [acmqueue.org] that talks a bit about Google's philosophy for choosing tools. There are various articles [google.com] on Google technologies floating around on the web site too. Before anyone asks, I have no idea what the relative size of the code base in each language is.

Disclaimer: I work for Google.

Re:Google's in C++? (0)

Anonymous Coward | more than 7 years ago | (#17180914)

Disclaimer: I work for Google.

Are you getting a kick out of these replies?

Can you imagine the world without the Web? (4, Insightful)

Larry Lightbulb (781175) | more than 7 years ago | (#17179236)

Why try to imagine it, can't we just remember it?

Re:Can you imagine the world without the Web? (5, Funny)

Skim123 (3322) | more than 7 years ago | (#17179974)

I remember back when I was a young lad, and the only access to pornography we had was through a friend's dad's discovered "collection", or, in some less proud moments, the Victoria Secret's catalog. Kids today don't know how good they have it.

Re:Can you imagine the world without the Web? (2, Funny)

csguy314 (559705) | more than 7 years ago | (#17180812)

Why try to imagine it, can't we just remember it?

Maybe you can. Some of us aren't that old... or have ingested massive amounts of memory modifying substances [about.com] .

This line explains a thing or two (1)

gangien (151940) | more than 7 years ago | (#17179278)

I do not believe that a paradigm completely replaces previous paradigms in one revolutionary moment (or "shift"). Instead, each programming paradigm adds to what worked previously

I think that line explains a thing or two about C++..

He then goes on to say that Java and C# go on to further this, and I don't believe that. Java (and my C# experience is limited, but I believe it applies to C# as well), does not augment C/C++. In fact wasn't it originally called C++-? Java did shift the paradigm, and as a java developer, I am thankful.

Re:This line explains a thing or two (0, Troll)

WilliamSChips (793741) | more than 7 years ago | (#17179318)

Remember that you're talking about a guy who thinks that if something is designed correctly then it becomes stillborn.

Re:This line explains a thing or two (3, Insightful)

gangien (151940) | more than 7 years ago | (#17179320)

I should probably add that i 100% agree with this statement

I think that would be misguided. The idea of programming as a semiskilled task, practiced by people with a few months' training, is dangerous. We wouldn't tolerate plumbers or accountants that poorly educated. We don't have as an aim that architecture (of buildings) and engineering (of bridges and trains) should become more accessible to people with progressively less training. Indeed, one serious problem is that currently, too many software developers are undereducated and undertrained.

Very interesting read all together!

Re:This line explains a thing or two (1)

cryptoluddite (658517) | more than 7 years ago | (#17179592)

I guess he's never heard of Home Depot or Lowes. The basic idea behind those stores is that yes people can be their own plumber, electrician, mason, handyman, etc, for many basic tasks and that people want these things to be more accessible to them. Millions of people can write things in Java or its kind without lots of training and expertise.

This must be threatening to Bjarne for some reason. I submit that it is only in C++ where even a few months training is dangerous.

Re:This line explains a thing or two (5, Interesting)

MoralHazard (447833) | more than 7 years ago | (#17179700)

Ooh, but your analogy can extend! Sure, I can go down to Home Depot and buy some interior paint to spruce up my living room, or some 2x4s to build a new deck, or something like that. But have you ever heard of building inspections? Anytime you do serious work, like an addition or a new building or even heavy electrical, you're probably going to have to get permits, submit plans, and then have a licensed building inspector come out and check your work. And it if ain't done to code, you're going to have to rip it all out and hire somebody who know what they're doing.

The reason behind all this bureacratic, intrusive government oversight is that building codes are written in blood. Code specs have emerged over time because people died when buildings collapsed, or bad electrical wiring caused fires. The lesson is that if you're not doing something that could cause injury or death, go ahead and do it yourself. If not, you'd either better learn the right way to do it or hire somebody.

Code divides into similar categories, although I the decision point is different: Is the failure of this application tolerable? It may be a question of lives at risk (avionics, air traffic control, miliary systems, automotives braking/control, medical) or it might just be economic (my business stops and I lose money when our servers bug out). It's only prudent to analyze your situation and come to a rational decision about whether you want to tolerate the risks of hiring professionals (or learning professional methods and implementing them yourself), versus playing pickup ball.

Having lived through a couple of start-ups, both successful and unsuccessful, I can tell you that the different approaches do make a difference. I think that's what Bjarne is getting at: if the application matters, you'd better do it right.

Re:This line explains a thing or two (1, Insightful)

Anonymous Coward | more than 7 years ago | (#17179730)

Having lived through a couple of start-ups, both successful and unsuccessful, I can tell you that the different approaches do make a difference. I think that's what Bjarne is getting at: if the application matters, you'd better do it right.

True, but there are huge classes of applications which are tremendously useful, for which a failure is tolerable, and which are relatively easy to write. So I strongly favor the existence of languages which allow people to write code with only a few months training. And as a professional software developer/computer scientist, I don't feel threatened by it - I wouldn't want to write those applications. When they need something more complex or more robust, they'll come to me.

Re:This line explains a thing or two (1)

imaginaryelf (862886) | more than 7 years ago | (#17179812)

Actually, when lame programmers all over the world has made a total mess of things using that weak language, people will call on you to clean up his shit. Yes, they'll pay you more, but is that really worth your while?

Re:This line explains a thing or two (1)

Fulcrum of Evil (560260) | more than 7 years ago | (#17180156)

I believe that for $75/hr, I can overlook a lot of bad code/design. Actually, I'd be happy to clean up messes for that rate (possibly more if it's really horrendous). The only real condition is that I be allowed to actually fix things, and the management can't act as though it's my fault. Naturally, we set the deadline after an initial evaluation and negotiation over the scope of the work.

Professionals... (2, Insightful)

Savage-Rabbit (308260) | more than 7 years ago | (#17180266)

True, but there are huge classes of applications which are tremendously useful, for which a failure is tolerable, and which are relatively easy to write. So I strongly favor the existence of languages which allow people to write code with only a few months training. And as a professional software developer/computer scientist, I don't feel threatened by it - I wouldn't want to write those applications. When they need something more complex or more robust, they'll come to me.


Severe ranting ahead, you have been waned...

That's just the problem, a lot of companies don't come to professionals when they need something more complex or robust. They usually start off hiring a bunch of amateurs who have no firm grasp of professional software design because they are cheap to employ and let them loose without proper supervision. These people cobble together some system that works, it doesn't work very stably, but by and large it works if you constantly monitor it and as long as it the system is still relatively small. This system gets maintained for a while and added to. These additions are usually badly designed or even worse, quick fixes intended to patch up problems that could have been avoided if the system had been properly designed in the first place. As I said before, while the system is still relatively small the bad design does not matter so much but as the system's complexity, the load the system is subjected to and it's importance to the company grow the instability and constant hiccups due to bad design begin to become a liability. This is usually the point the company finally decides to call in the professionals who are then confronted with a system that badly needs a complete rewrite and an employer who expects the necessary rewrite to be done in a couple of weeks and on a shoestring budget. My experience is that a lot of the time (not to be read as: **always**, there are companies out there who proper design work) the professionals are called in to clean up messes created by people who learned to write code with only a few months training. Way to many of the jobs I get involve cleaning up problems created by people who committed basic errors such as duplicating code all over the place instead of building it into class libraries and who didn't seem to be aware of the existence of nifty utilities like 'javadoc'/'doxygen' and 'subversion' or even revolutionary concepts like 'multi-line code comments'. Not that I am complaining mind you; the clumsiness of these badly trained developers and the frugality of the managers who hire them keeps me, a professional university educated software developer, employed but it's still a frustrating way to make a living because a lot of the crap I have to deal with could have been so easily avoided.

Re:This line explains a thing or two (1)

MBCook (132727) | more than 7 years ago | (#17179640)

No kidding. Doesn't that call to mind half the programs you've seen written in VB and such? They may work for prototyping, or a little app for a small business, but you start scaling them up and those kind of things become disasters. I agree COMPLETELY with he statement that we have too many "programmers" who can't program right now. A large chunk of my job (as a programmer) is integration with other people's systems. And while I can tell you our system is hardly perfect, it looks like a panacea of brilliance compared to some of the things I've run across.

Re:This line explains a thing or two (1)

oldhack (1037484) | more than 7 years ago | (#17179744)

That's a very self-serving argument - I'm assuming you're a programmer. There is a programming and there is a programming. Consider programming life-support system vs. programming your powered car seat. Why should my wife have to get an MS in CS to program her car seat? Or why should a financial analyst, to do their what-if analysis? It make sense that my wife only need to know the sequence of the buttons, and the finanacial analysts their Excel macros, do their jobs.

Re:This line explains a thing or two (2, Insightful)

Timesprout (579035) | more than 7 years ago | (#17179356)

Java and C# dont really augment c++. I think what Bjarne meant was they have augmented the programming paradigm in the sense that developers are able to focus more on adressing the problem space rather than the nitty gritty implementation of the the solution.

You are confused (0)

Anonymous Coward | more than 7 years ago | (#17180910)

He is talking about object orientation not being a paradigm shift, not a specific language. Object orientation as implemented in Java did not throw out all of the previous programming language concepts from C++, Simula, Smalltalk, Algol, etc. It built on them and picked and chose features from previous systems. Hence, no paradigm shift.

First web browser not written in C++ (5, Informative)

Anonymous Coward | more than 7 years ago | (#17179348)

WorldWideWeb, being on a NeXT box, was written in Objective-C, not C++.

Aspect Oriented Programming is a Hack. (5, Interesting)

suv4x4 (956391) | more than 7 years ago | (#17179414)

FTFA: I hope you didn't put too much money on it! I don't see aspect-oriented programming escaping the "academic ghetto" any day soon, and if it does, it will be less pervasive than OO. When it works, aspect-oriented programming is elegant, but it's not clear how many applications significantly benefit from its use.

Totally agreed. AOP is a strange form of "dynamic" insertion of code at special "cut points" of execution within the code and represent a very very lazy way to avoid good OOP structure of your applications.

In a bigger framework AOP can be totally unpredictable and wreck otherwise locked and working code.

When AOP started to pick some speed in the beginning I was naturally both interested and slightly annoyed that so short after OOP here's yet another concept for programming I have to learn and implement in my software.

Not so fast though, since as much as OOP provides useful abstractions that makes your code more readable and predictable, AOP does exactly the opposite except in few very limited cases.

The cons outweigh the pros.

The World Before Google (0)

Anonymous Coward | more than 7 years ago | (#17179416)

Why yes, I remember the world before Google. We had AltaVista. Their ads? Teh suck. Their search? If we're talking before they left DIGITAL Corp, as good as Google's. Google's an *ad* company, people, not a geek company.

Google (5, Interesting)

Anonymous Coward | more than 7 years ago | (#17179504)

Claiming Google as a cool C++ program is about 1/3 true. Most Google code is written in C++, Java, and Python: C++ for performance-critical stuff, Python for scripting, and Java for everything in between. The trend is definitely toward Java at the expense of the other two.

Also, for what it's worth, Google's use of Aspect-oriented programming is ramping up pretty fast.

Re:Google (1)

Midnight Thunder (17205) | more than 7 years ago | (#17180736)

The trend is definitely toward Java at the expense of the other two.

I prefer programming in Java, but have been doing a lot of programming in C++ recently. From my experience, while Java produce larger code and slightly less performant code than C/C++ there are many advantages: shorter development cycle (assisted by a large and complete API and you avoid many issue with pointers vs references), works without recompilation no matter the OS/architecture you are using.

Bug in C++ (0, Flamebait)

Anonymous Coward | more than 7 years ago | (#17179512)

Can you find the bug in this C++ program?

---- begin bugdemo.h ----
template<class T> void doprint(T obj) { printf("The numbers are: %d %d\n",obj.num1,obj.num2);}
void foo(void);
void bar(void);
---- end bugdemo.h ----
---- begin bugdemo.cc ----
#include "bugdemo.h"

int main(int argc, char *argv[])
{
  foo();
  bar();
  return 0;
}
---- end bugdemo.cc ----
---- begin foo.cc ----
#include <stdio.h>
#include "bugdemo.h"

struct A {
  int num1,num2;
};
void foo(void)
{
  A myobj;

  myobj.num1=-5;
  myobj.num2=6;

  doprint(myobj);
}
---- end foo.cc ----
---- begin bar.cc----
#include <stdio.h>
#include "bugdemo.h"

struct A {
  short num1,num2;
};
void bar(void)
{
  A myobj;

  myobj.num1=-5;
  myobj.num2=6;

  doprint(myobj);
}
---- end bar.cc ----
This program seems to be intended to generate:
The numbers are: -5 6
The numbers are: -5 6

But instead generates:
The numbers are: -5 -1
The numbers are: -5 6
or perhaps something different altogether.

The problem is portable across platforms and compilers (although the exact incorrect answers sometimes vary).

Re:Bug in C++ (1)

EvanED (569694) | more than 7 years ago | (#17179604)

Re:Bug in C++ (0)

Anonymous Coward | more than 7 years ago | (#17179670)

Agreed. Nevertheless, no compiler diagnoses this. And it has the potential to cause bizarre memory corruption. That makes it a land mine waiting to be stepped on.

The real problem is that the linker crosslinks lightweight symbols without checking if those symbols really are equivalent. But the linker folks don't seem to care ("not our bug").

The "official" response I've seen to this is "you're supposed to use namespaces".

Re:Bug in C++ (1, Informative)

Anonymous Coward | more than 7 years ago | (#17180660)

The real problem is that the linker crosslinks lightweight symbols without checking if those symbols really are equivalent. But the linker folks don't seem to care ("not our bug").


By the way, ld (the link editor) has has an option called --allow-multiple-definition whose documentation says:
Normally when a symbol is defined multiple times, the linker will report a fatal error. These options allow multiple definitions and the first definition will be used.
This tells me that it is a bug in the linker (or at least the linker's documentation).

Note that ld also has an option called --warn-common whose documentation says:
Warn when a common symbol is combined with another common symbol or with a symbol definition. Unix linkers allow this somewhat sloppy practise, but linkers on some other operating systems do not. This option allows you to find potential problems from combining global symbols. Unfortunately, some C libraries use this practise, so you may get some warnings about symbols in the libraries as well as in your programs.
This option does not warn about the issue in question, so I consider that a linker bug as well.

p.s. The best policy is to disallow header files to define nonstatic symbols. This is fairly difficult to enforce programmatically, but you can at least catch multiple definitions and reject them before linking if you do something along the lines of: nm -ogC --defined-only *.o | cut -d: -f2 | sort | uniq -dc. In this case, you'll get 2 00000000 W void doprint<A>(A const&), which indicates that there are two weak symbols with the name void doprint<A>(A const&), so your custom build process can halt with an error.

p.p.s. The fix for the case in question is to change its definition to be template<class T> static void doprint(T obj) { printf("The numbers are: %d %d\n",obj.num1,obj.num2);}

Re: (minor correction to parent) (0)

Anonymous Coward | more than 7 years ago | (#17180710)

Ooops. To avoid confusion for people trying to follow along with what I did, I should mention that I had changed my copy of the header to
template<class T> void doprint(const T& obj) { printf("The numbers are: %d %d\n",obj.num1,obj.num2);};
that's why I got void doprint<A>(A const&) instead of void doprint<A>(A).

Re:Bug in C++ (0)

Anonymous Coward | more than 7 years ago | (#17181152)

The linker documentation (i.e. --allow-multiple-definition) is referring to regular symbols, not lightweight symbols. The reason for lightweight symbols is to allow the linker to eliminate redundancy in code compiled from header files. However, as EvanED pointed out, the compiler and linker are following the spec.

The trouble is that the spec doesn't say what to do in this circumstance. My opinion is that
    1. The linker should issue a warning that it's combining two symbols that refer to code that is not bit-for-bit identical. (this would cause problems if different modules are compiled with different compiler flags), and/or
    2. The linker should keep both versions separate and distinct. One way to achieve this would be to have the compiler add a hash of the generated code to the symbol name

In addition
    3. The language should allow the static keyword in the class/struct definition. That would make all templates of the class or struct also static (i.e. local to the module).

Who knows. Maybe Bjarne will read this and come up with an even better solution.

Re:Bug in C++ (1)

BonoLeBonobo (798671) | more than 7 years ago | (#17179646)

Can you explain where the problem is ?

Re:Bug in C++ (3, Informative)

EvanED (569694) | more than 7 years ago | (#17179732)

The problem is that two different translation units define two different versions of struct A.

Relevant parts from Section 3.2 of the cpp standard:
"There can be more than one definition of a class type ... in a program provided that each definition appears in a different translation unit, and ... each definition of [the name defined more than once] shall consist of the same sequence of tokens ..."

In the example provided, two translation units have definitions for struct A. However, they are not identical; in particular, one has members that are ints, the other, shorts.

However:
"If the definitions of the [name defined more than once] do not satisfy these requirements, then the behavior is undefined."

In other words, the compiler is not required to diagnose violations of the ODR (One Definition Rule).

In this particular example, the compiler compiled bar as if doprint had a four-byte argument* (two shorts) but then threw out one of the definitions of doprint, leaving the other to treat shorts as if they were ints.

*or maybe an eight-byte argument with misc padding that wasn't cleared

Re:Bug in C++ (1, Interesting)

Anonymous Coward | more than 7 years ago | (#17179764)

The compiler generates different but identically names instances of doprint() in each of the two modules (notice the difference in the definition of struct A). The linker then arbitrarily picks an instance and throws out the other.

The net result is that one of the calls to doprint() ends up using a template instantiation for an incompatible datatype and prints out the wrong things.

With GNU ld, the linker's selection of the instance is determined by the order of parameters on the command line, so you can get different behaviors by switching the parameters around.

I spent a week tracking this down during my dissertation work. It was buried in a 4000 line (not including libraries) numerical analysis code. The offending template definition was buried in a macro expansion defined in an external library.

Needless to say, I've avoided C++ since then. Too many gotchas and subtle behaviors, weirdnesses with virtual methods, etc. Not to mention the const/non-const combinatorial explosion and the other hassles resulting from strong typing.

These days I usually end up using C, Matlab/Octave, or Python depending on the problem. The new Numpy is very very good for numeric computation.

Re:Bug in C++ (0)

Anonymous Coward | more than 7 years ago | (#17179718)

doprint<A>(myobj);

Re:Bug in C++ (1)

EvanED (569694) | more than 7 years ago | (#17179954)

You don't need to write doprint<A> because the type can be deduced from the argument to doprint.

(This can be further demonstrated by the fact that making your change doesn't fix the problem.)

Next big programming paradigm: VM on Steroid (0)

Anonymous Coward | more than 7 years ago | (#17179520)

TR brought up aspected orientation, and BS brought concurrency (in line with current CPU design pattern) and generic programming. Concurrency will definitely be a biggie - it applies not only to multi-core CPUs, it already applies to distributed computing (cluster and all those related). Generic would need a lot more work. It has been in C++ (template, STL) for many years, but only the ninjas would cook up their own templates - most of use simply use library-supplied templates and don't f*ck it up. Same story with Java generics, the way it was added. C#'s generics seem easier to use.

AO appears more of an extension to OO - helps to organize and manage the design workload. Much buzz, but no real uptake so far. Maybe a takeup by one of the big platforms (C++, Java, .net) is the push AO needs to take root in practice/industry.

My guess is growing importance of VM/runtime support. Both Java and .net are based on runtime VM, and it has the advantage of access to the runtime profile information that static languages lack. I'm thinking addition to language that better expresses how the VM should optimize in execution of the program (maybe in conjunction with dynamic typing - i.e., runtime morphing of the code) can provide the next leap in programming productivity by pushing up the abstraction level. MDA promised the same result, but so far it seems to have failed to hit the sweetspot on the tradeoff between abstraction and control. And the super VM is not mutually exclusive with any of the ideas noted.

Ok, just an idea out ma ass. I know next to nothing on the topic of VM design. :-)

"Severe resource constraints" (2, Insightful)

melted (227442) | more than 7 years ago | (#17179618)

"Severe resource constraints"? Since when a datacenter with half a million servers in it is called "resource constraints"?

Re:"Severe resource constraints" (4, Insightful)

halftrack (454203) | more than 7 years ago | (#17179946)

Since always ... Getting a 10% performance gain in a 500,000 servers data center could mean a cost saving of 50,000 servers. On 5 servers you wouldn't bother because you wouldn't save anything. The resources we are talking about here are in essence entirely economical and pragmatical. Adding 50,000 servers is not easily done nor particularly cheap.

errrr check your timeline please (1)

biafra (4283) | more than 7 years ago | (#17179772)

From the article: "Technology Review: Name the coolest and lamest programs ever written in C++, and say what worked and didn't work. Bjarne Stroustrup: Google! Can you even remember the world before Google? (It was only five years ago, after all.)

OK, I really try not to be elitist/whatever but this one kind of bugs me. Google has been around, and part of (mostly) popular culture for more than 5 years. And I would imagine that a decent amount of people actually do remember the days before Google. Writing like that is just lazy.

Const (1)

kryten_nl (863119) | more than 7 years ago | (#17179878)

Yes, yes, all fine and well that he's influenced by Kierkegaard and dislikes AOP, but ... COULD SOMEONE PLEASE ASK HIM TO EXPLAIN THE "CONST" keyword .... please ....


(A very good explination is given here [duramecho.com] for those of you who didn't know I was kidding)

Re:Const (1)

EvanED (569694) | more than 7 years ago | (#17180240)

I don't see why you need to say so much.

* If a variable or reference to a variable of primitive type is const, you can't assign to (and must initialize) it
* If an object or reference to an object is const, you can't change non-mutable data members or call non-const functions
* For pointers to primitive types, there are two notions of constness: whether the address stored in the pointer ("where the pointer points") can be changed, and whether the value at the pointed-to location can change. In the type of a pointer, __1__ <type> __2__ * __3__, a const in slot 1 or 2 refers to the second kind of constness, while a const in slot 3 refers to the first kind.
* For pointers to objects, the same rules apply as the last point, except that the second notion of constness changes to preventing modification of non-mutible members or calling non-const member functions
* A const on a member function means that you can't modify non-const data-members or call non-const functions of this
* Implicit conversions will add but never remove const qualifiers

There, that's most of C++ const rules.

Now, I'm being a little facetious here, because the article does go into a lot more detail about how const is actually used in practice (for instance, passing objects by const reference for efficency), but I think the article is making more of it than needs be.

For instance, there's no difference between the treatment of const for normal variables, parameters, and return values. In all cases, const means you can't modify it or call non-const functions, yet he devotes a section to each.

"Also, the first Web browsers." (4, Informative)

SEE (7681) | more than 7 years ago | (#17179998)

Re:"Also, the first Web browsers." (0)

Anonymous Coward | more than 7 years ago | (#17180430)

Yeah and Mosaic was totally written in Objective-C, too.

Re:"Also, the first Web browsers." (1)

SEE (7681) | more than 7 years ago | (#17181046)

Well, let's see. The claim was the "first web browsers".

WorldWideWeb was in Objective-C.
WWW. the line-mode CERN browser, was in plain C.
Erwise was in plain C.
ViolaWWW was written in the Viola toolkit/language system.

Mosaic was early, and Mosaic was important, but to say the "first web browsers" to have been written in C++, one has to ignore the actual first web browsers.

Re:"Also, the first Web browsers." (4, Informative)

iabervon (1971) | more than 7 years ago | (#17181172)

Even Mosaic wasn't written in C++. I'm looking at the 2.7b4 source now, and it's definitely C.

Interview with Stroustrup (1)

ghenne (537543) | more than 7 years ago | (#17180038)

How can any not read this interview with Stroustrup? http://www.nsbasic.com/ce/info/interview.shtml [nsbasic.com]

Re:Intw with Stroustrup - http://www.google.com (0)

Anonymous Coward | more than 7 years ago | (#17180456)

I dont think he likes it though
http://www.research.att.com/~bs/bs_faq.html#impost or [att.com]

Best part of interview (2, Interesting)

rjdegraaf (712353) | more than 7 years ago | (#17180080)

.Net is a huge integrated system backed by Microsoft. That's its major advantage and disadvantage. Personally, I'm a great fan of portability. I want my software to run everywhere it makes sense to run it. I also want to be able to change suppliers of parts of my system if the suppliers are not the best. Obviously, suppliers of huge integrated systems, such as .Net and Java, see things differently. Their claim is that what they provide is worth more to users than independence. Sometimes they are right, and of course some degree of integration is necessary: you cannot write a complete application of any realistic size without introducing some system dependencies. The question is how deeply integrated into the application those system dependencies are. I prefer the application to be designed conceptually in isolation from the underlying system, with an explicitly defined interface to "the outer world," and then integrated through a thin layer of interface code.

Re:Best part of interview (3, Interesting)

oldhack (1037484) | more than 7 years ago | (#17180260)

Large part of the many (most?) business applications is glue to the system ("integration"), especially nowadays where much of the basic algorithms (supplied lib), data access (SQL), and UI are handled by underlying systems.

spongE (-1, Troll)

Anonymous Coward | more than 7 years ago | (#17180150)

aarogance was another cunting unpleasant

the world before google? (0)

Anonymous Coward | more than 7 years ago | (#17180646)

Yes, I remember clearly, I used some other search engine instead.

People need to stop acting like google invented the search engine.

It's a decent one, but only marginally better than the competition and if google search disappeared tomorrow it just wouldn't be a big deal.

first Post (-1, Troll)

Anonymous Coward | more than 7 years ago | (#17180670)

GNAA (GAY NIGGER people's faces at the party in strret Baby take my

use ObjC and your problem will go away (0, Troll)

Anonymous Coward | more than 7 years ago | (#17180888)

C++ is an inherently and unnecessary complex language, if you want to use some C inheritor for OO programming resort to Objective-C: it is a much simpler and cleaner "enhancement" of C instead of C++ which tries to kill many flies with one stroke (multiparadigm language). ObjC is essentially C + Smalltalk, you can learn it within one day if you already know C, just compare the number of pages of http://www.amazon.com/C++-Programming-Language-Spe cial-3rd/dp/0201700735 [amazon.com] vs http://www.amazon.com/Object-Oriented-Programming- Evolutionary-Brad-Cox/dp/0201548348 [amazon.com] . it's like in real live: the worse approach wins (Windows vs. Linux and so on). Good tutorial here: http://objc.toodarkpark.net/ [toodarkpark.net] . And by the way: the OpenStep Libs are to die for!

Moo (1)

Chacham (981) | more than 7 years ago | (#17181096)

Can you imagine the world without the Web? (It was only about 10 years ago.)

The web was created by Al Gore in 1996?

My word ignorance has passed on even to our elders. /me cries.

Just a quick look at AltaVista [altavista.com] 's about [altavista.com] pages shows they *indexed* the web in 95. Of course, the Internet wasn't there before Google, so it must be bogus.

RFC 1580/FYI23 [rfc-editor.org] which was published in March 1994, contains a definition of the web.

In actuality, the World Wide Web came about in 1992 about 15 years ago.

Now, had Bjorn meant that slashdotters wouldn't remember before ten years ago because that's about how old most moderators are, i could understand, but he should have been more clear on the matter.
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?

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>