I really hate to do this sort of thing, but I'm at a point in my job where I really, really need a decent manual on C++. I hate to go out and buy the first thing I see, and I've got no idea what's good. I don't need to learn the C subset of C++, just everything else. The problem I'm faced with is integrating with someone else's utilities that use template classes and suchlike; I need something that tells me in detail about different kinds of classes and how they're used.
Oh, and consider this an open thread on geeky stuff. It doesn't have to be all politics, all the time. Have at it.
Slarti,
Object oriented programming is a tool of the devil. If procedural code was good enough for me and good enough for Knuth then dagnabbit it should be good enough for everyone.
And oh yeah, I want my freakin' GOTOs back!
Posted by: Chuchundra | January 29, 2005 at 10:00 AM
But...but...I was waiting for an open thread so I could ask a naive, possibly ignorant world politics question. When can we have a naive, possibly ignorant world politics questions open thread?
Posted by: Opus | January 29, 2005 at 10:34 AM
If by "manual" you mean sonething like a man page...um...this would be the closest thing:
The C++ Programming Language
These are generally recommended introductory books. Except for a brief chapter on linking C code in C++ Primer, there's no C in either.
C++ Primer
Accelerated C++
Posted by: DeadTrees | January 29, 2005 at 11:28 AM
My favorite introductory book to C++ is "Thinking in C++" by Bruce Eckel. I read it back when it was just one volume, but I assume it's still good. He gave a relaxed discussion of C++ that gave a sense of the principles behind it. Also, it's detailed, and I believe it goes into all of the features of the language. C++ is far from my favorite language, but this is the book I'd recommend for learning about it.
--Rick Taylor
Posted by: Rick Taylor | January 29, 2005 at 11:29 AM
My advice: RUN! Run for your life!
Posted by: Josh Yelon | January 29, 2005 at 12:01 PM
no suggestions for actual books, but i always keep a like to the C++ FAQ Lite handy. lots of good stuff in there.
and, if you have specific questions, i always recommend The Code Project.
Posted by: cleek | January 29, 2005 at 12:30 PM
and, just let me share...
yesterday i found myself converting some old-school C to C++. the C made heavy use of function pointers and global (and static local) variables. very bad. boo . hiss. not thread-safe, not modularized, not what the baby likes.
so, i made a class. i made all of the C functions members of that class, threw all the globals and static locals into the class - encapsulation problem solved. i wasn't about to rewrite all the C as true OO C++ - no time for that. but then i realized i had to find a way to duplicate the function pointer functionality... a head scratcher.
i'd never tried calling a member function via a function pointer, and for all i knew, it couldn't even be done. the job function pointers do in C is usually handled by some inheritance/virtual function scheme in C++ (but i didn't have time to rewrite all 5000 lines of C to make a nice C++ class heirarchy out of it). i was worried i'd coded myself into a corner.
but, thanks to the C++ FAQ Lite, i discovered that it's not only possible, but trivially easy (if a bit arcane). so, hooray for the FAQ!
hooray for C++ !
Posted by: cleek | January 29, 2005 at 12:42 PM
C? C++?
What the hell is wrong with Fortran?
Posted by: Bernard Yomtov | January 29, 2005 at 12:51 PM
To quote the oft-maligned Glenn Reynolds: Indeed. Given my druthers, I'd have used Fortran, or Matlab, or, in a pinch, C. I taught myself the latter two, and so I'm very comfortable with them, although (it goes without saying, I know) likely extraordinarily inept.
But, here's the problem: the software lead on this is a guy who's stunningly competent at every programming language he touches. His code is better than what they give in textbooks as best practice, and he's already written these wonderfully useful, safe, practical utilities in C++ that, unfortunately for me, require some higher level of understanding of the language than I currently possess. The last program I was on, I wrote the algorithms in C and they Saran-wrappered them with C++ and pronounced them worthy of being included in the OFP (Operational Flight Program, for the uninitiated). This program will be different, and Stan is so goddamned competent that he sort of induces people around him to, well, rise.
Oh, nearly forgot this:
Done. Am I accommodating, or what?
Posted by: Slartibartfast | January 29, 2005 at 02:00 PM
Slart - my advice as someone who learned programming on punch cards and wrote bad C++ for several years - write down a list of what you need done, show it to your guru guy, have him show you exactly what needs to be done for each sort of thing on the list, type it in, and have him debug/tweak it. It will take less of his time than fielding your inevitable questions. Otherwise you can of course set aside a good chunk of time/day for the next n months to learn C++ from the ground up.
Posted by: rilkefan | January 29, 2005 at 02:14 PM
Don't underestimate the value of pleasantly surprising the guru on the following Monday.
Posted by: Slartibartfast | January 29, 2005 at 02:18 PM
OMG Slarti, if your starting point on C++ is templates, it'll kill you. I've been programming in C++ for, let's see, um, fourteen years now (and OOP for 22 years), and even I think templates are the darkest work to scrabble its way out of Lucifer's lair.
Are you looking into some standard template library (STL) stuff? If so, then there are a number of deeply confusing books out there that might help somewhat. In terms of C++, I too highly recommend the C++ FAQ, but it's not likely to get you up to speed very fast, but is a good resource to use while going there.
My suggestion for anyone who wants to pick up on C++ is to take a course for it. There are so many evil pitfalls in the language that it's best to have a good instructor show them to you. ESPECIALLY when it comes to templates.
Or you could just skip C++ and learn a decent language like Java or C#. And here come the language wars.
Posted by: double-plus-ungood | January 29, 2005 at 02:29 PM
Sorry, took of my shoes to do the math properly, and I've been OOPing for nineteen years, not twenty-two.
Posted by: double-plus-ungood | January 29, 2005 at 02:31 PM
Never bothered with OOP, ++!good, because I never write anything that can be used twice. Well, I never plan it that way.
No, I'm doomed. I have no choice. But many thanks for your many suggestions, and probably my date tonight with my lovely redheaded wife (celebrating our dozenth wedding anniversary) will wind up, typically (for us) at the bookstore, where I'll nab whichever of the contributions seem to be handy at the local Borders store.
And if it seems as if I'm more boisterous than usual, it's because I've had a bottle of Nostradamus Belgian Brown Ale (surely it's got to be a liter), followed by a Spaten Optimator. The girls are painting in watercolor (protected by modern smock technology) in the lanai, so I'm free to throw sod any whichway I want.
Reminder to self: post something asking about clinical validation for things related to rerouting neural pathways, a la balametrics.com
Posted by: Slartibartfast | January 29, 2005 at 03:34 PM
Strostrup's "The C++ Programming Language" is Required Reading. He invented the language.
Also, get a copy of ISO/IEC 14882, the standard for C++.
Neither is exactly an elementary tutorial, but they're great argument settlers as to what the language "really" is.
Posted by: lightning | January 29, 2005 at 03:35 PM
Chuchundra,
OOP rocks :P
I am a Java developer, by the way.
Posted by: Stan LS | January 29, 2005 at 04:25 PM
Slarti,
I like Deitel books, personally.
Posted by: Stan LS | January 29, 2005 at 04:28 PM
Doh, never mind Deitel. More of a beginner type books.
Posted by: Stan LS | January 29, 2005 at 04:30 PM
Ah, OO, data structures, function pointers, all that good stuff. I tend to side with what Rob Pike wrote over 15 years ago in his Notes on Programming in C:
Of course, I consider Java a pox worse than Pascal ever was, so YMMV. Oh, and do read that article for great, simple ways to improve the readability, robustness and maintainability of your code.Posted by: JerryN | January 29, 2005 at 04:47 PM
Worst C++ book advice thread ever ;).
Slarti, get a trial subscription to Safari. It gives you online access to all of the books in O'Reilly's (and a number of other publishers') catalog. I think you can get a week free. Personally, I'd recommend you keep it indefinitely. I think it's invaluable.
Once there, I would start with:
C++ in a Nutshell
Inside the C++ Object Model
C++ FAQs
Posted by: sidereal | January 29, 2005 at 05:20 PM
While I like C++, it is the subject of the greatest putdown evah:
"C++: An octopus made by nailing extra legs onto a dog."
Posted by: Anarch | January 29, 2005 at 05:21 PM
Or you could just skip C++ and learn a decent language like Java or C#.
Feh. Everyone knows that great hackers prefer Python.
Posted by: Josh | January 29, 2005 at 05:45 PM
Stan, you're a Java programmer? Well, I might have known.
Oooh! programming language flamewars. This place gets more like Usenet every day.
Posted by: Chuchundra | January 29, 2005 at 06:21 PM
I interviewed at one of the bigger financial firms a few days ago. Got teched out by 5 people (close to 3 hours). Anyway, here's something that shocked me. I was asked a rather easy question (construct a SQL query) and upon answering it correctly the interviewer informed that 80% of the people she posed that question to either were not aware of GROUP BY or how to use it properly. This is for an intermediate development position (4-5 year exp.)
Pretty shocking.
Posted by: Stan LS | January 29, 2005 at 06:38 PM
I love perl, though I use python at work. SQL, yuck.
Posted by: rilkefan | January 29, 2005 at 06:49 PM
That's disturbing.
I have an ORDER BY (CASE WHEN... question that rarely gets answered correctly, and the outer join question gets maybe a 20% success rate. Somewhat forgivable for Java programmers, but my standards continually drop.
The dirty secret of the dot com bust is that a significant part of the failure is due to the fact that the incredible influx of engineers meant that maybe 30% of the developers with jobs were actually qualified to do them.
Posted by: sidereal | January 29, 2005 at 06:52 PM
I love perl, though I use python at work.
Down the Perl love here. I keep promising myself that I'll learn some of the more hardcore languages -- python, in particular -- but there's never been any need for anything I do (glorified shell scripts, frankly). Any suggestions for a language that's easy enough to pick up on the side that might actually have practical use* around the home or office?
* A loaded term in this context.
Posted by: Anarch | January 29, 2005 at 06:56 PM
Java. Ignore the haters.
If you want to avoid compilation, php is more readable than perl.
Scheme, for good times.
Posted by: sidereal | January 29, 2005 at 07:00 PM
sidereal - my answer to any outer join question is to rewrite the query. Any construct that guarantees ambiguous results when used correctly should be thrown in the trash.
Posted by: JerryN | January 29, 2005 at 07:02 PM
Any suggestions for a language that's easy enough to pick up on the side that might actually have practical use* around the home or office?
Python fits that bill pretty well, actually. If you already know perl, you should find python a snap. And it *forces* you to write readable code.
Posted by: Josh | January 29, 2005 at 07:03 PM
rilke,
I just began looking at Perl. Pretty interesting...
side,
I actually wasn't aware of CASE till you just mentioned it.. So, I looked it up. Thanks! :)
I agree with you regarding the 30%.. I got laid off in 2001, and was forced to go into whatever paid the rent (now making my move out of there, though), anyway, you should see the "developers" at this place. No degrees, took maybe 2 C classes. Then they decided the company needs a web presence, so they needed Java developers... What did they do? Bought Java books for their sucky C programmers. Forget OOP, these guys don't know what functions are. This one girl at work, wrote a clss which had functions, ie getFirstToken(), getSecondToken(), getThirdToken()... all the way up to getNinthToken()..
Another person was too lazy to write functions, but not lazy enough to cut and paste teh same block of code in a dozen places...
Pretty bad.
Posted by: Stan LS | January 29, 2005 at 07:07 PM
See, and these are the people I have to interview every week.
On CASE, it's T-SQL only. Pretend you don't know it if you're interviewing for an Oracle job.
Posted by: sidereal | January 29, 2005 at 07:13 PM
The last time I did any dev work for a living was about 13 years ago, so let's just say I'm a bit out of the loop. Nevertheless, every now and then I try to pick up VC++ for yuks and to churn out simple apps to make my life easier, but I just can't get past the development environment: Visual Studio is complete shite.
Posted by: Catsy | January 29, 2005 at 07:22 PM
Already know Java; I'd like to learn php but they won't let me install php apps on the office server so its utility is somewhat limited IMO. Python and scheme are both on my list, we'll see what comes of it.
Now a question to all the programmers in the hizzouse: how many of you think in a specific language when deciding how to program? After much investigation, I've discovered that I program at a much more abstract level than do most of my friends: I write most of the program as pseudocode in my head, then just implement the details.* This means that I'll never write as good C code (f'rex) as they do, but it has the perk that I can pretty much pick up a language over the weekend if I'm so inclined and program with it at an indifferent level.** Is this unusual or do I just need to broaden the scope of my acquaintances?
* My greatest accomplishment was when I wrote a modular, extensible 1000-line C++ program in Notepad because the department screwed up and failed to provide me with a compiler, then debugged that puppy by hand. [Due to University regulations the code could only be generated/tested/compiled on officially sanctioned software, hence my desperation.] Except for a stupid semantic mistake -- I think I put colons for linebreaks instead of semicolons or something moronic like that -- it compiled on the first time, too. I never get tired of telling that one :)
** The one stunning exception to this is LISP; I've never got the hang of functional closures.
sidereal: The dirty secret of the dot com bust is that a significant part of the failure is due to the fact that the incredible influx of engineers meant that maybe 30% of the developers with jobs were actually qualified to do them.
Speaking of people who shouldn't have been programming, I got a job working at an internet startup one summer that was supposed to morph into a real job, but unfortunately didn't. One of my jobs -- really, my only job -- was to go into the lead (and, prior to my arrival, only) programmer's code and rewrite it. I'll never forget the half hour I spent trying to puzzle out a block of code that was supposed to generate a table in HTML. He'd used variables a, b, c, ... , i; I couldn't figure out for the life of me why. Then it hit me: he was generating a 3x3 table by explicitly taking values out of a previously-generated array, shoving them into the nine individual variables, then explicitly creating the HTML table one variable at a time.
I literally couldn't stop laughing for the ten minutes it took to shrink the ~fifteen lines of code into two lines and a pair of FOR loops that let me generate an m x n table on the fly, as God intended.
I guess the joke was on me, though: I eviscerated his code so efficiently that I worked myself right out of a job. The company's doing quite well, last I checked; I just hope to hell they got someone else to actually write the code.
Posted by: Anarch | January 29, 2005 at 07:22 PM
Python blows dead goats. Easy to quickly write stuff in, impossible to maintain. Bleah.
Love that description of C++, Anarch. And let me say that I am surprised and horrified at the number of ObWiers that are programmers.
Posted by: double-plus-ungood | January 29, 2005 at 07:23 PM
Love that description of C++, Anarch. And let me say that I am surprised and horrified at the number of ObWiers that are programmers.
OK, it's time: the steel cage, no-holds-barred deathmatch between the ObWi programmers and the ObWi lawyers. Let the tedium commence!
Posted by: Anarch | January 29, 2005 at 07:24 PM
Seeing as how I was coding in three different languages at one early point in my working life (ALGOL, FORTRAN and BASIC) I tend to design at a generic structured / procedural level. I kind of have to translate into an object paradigm, with all of the resultant ugliness that implies.
Posted by: JerryN | January 29, 2005 at 07:35 PM
Even I was once a programmer, back in 1981 -- and I had to test stuff on a little computer with a one-line (!) display that made this horrible honking sound when it encountered an error. And since I was testing, throwing errors a it was pretty much all I was doing. It was awful.
Posted by: hilzoy | January 29, 2005 at 07:39 PM
I don't really count Javascript or ASP, since I wasn't doing any of that professionally--the last time I ever worked with coding and made money off it, I was writing third-party plugins and apps for TradeWars 2002--mostly in QuickBasic.
Posted by: Catsy | January 29, 2005 at 07:42 PM
I was a technical writer, not a programmer. I translated geekspeak into normal language. ;-)
(Yes, okay, I have written programs. But that doesn't make me a programmer.)
Posted by: Jesurgislac | January 29, 2005 at 07:51 PM
Was that the same TradeWars that started as a FidoNet-based game in the late eighties?
Posted by: double-plus-ungood | January 29, 2005 at 07:52 PM
double,
Ever play Telegard/PC Board based games? Ie, The Pit, Global Wars, etc?
Posted by: Stan LS | January 29, 2005 at 07:59 PM
Anarch,
Now a question to all the programmers in the hizzouse: how many of you think in a specific language when deciding how to program?
Well, if your thinking process is object oriented, your desing should work with any language that supports OOP.
Posted by: Stan LS | January 29, 2005 at 08:05 PM
No, 'fraid not.
Posted by: double-plus-ungood | January 29, 2005 at 08:05 PM
Were you active on any l33t boards? ;)
Posted by: Stan LS | January 29, 2005 at 08:09 PM
I was a technical writer, not a programmer. I translated geekspeak into normal language. ;-)
As a marketeer I thought that was my prerogative ;-)
My programmings never got further than the basis. Punchcards at highschool, to have the mainframe print my name 2000 times... a bit of basic during the study as a basis for using statistical programs.... and as a SAHM I took up online courses. I can now make nifty memory games for the kids in Flash ;-) and just started basics in PHP, to make maintenance of our ever increasing family website easier.
Posted by: dutchmarbel | January 29, 2005 at 08:10 PM
Was that the same TradeWars that started as a FidoNet-based game in the late eighties?
It was originally Tradewars, or TW2, but a version of the source code was picked up by Gary Martin of Lawrence, KS and turned into TradeWars 2002, arguably a much better and more complex game. It was a door game for BBSes, initially WWIV (through chain.txt) but capable of reading the user files of a number of other BBS software packages. Around 1990, I started writing third-party addons/utils for it, such as ShipEdit, Genesis, Missions, etc, and made a few hundred bucks a month off shareware registrations for the next several years.
You can still find TW2002 telnet games here and there, and the game underwent something of a predictable revival when the year 2002 actually showed up.
Every now and then I entertain the notion of picking up writing plugins for it again, but nearly everything my programs used to do were eventually implemented by the author as features of the game, and I simply don't have the kung fu necessary to do it anymore.
Posted by: Catsy | January 29, 2005 at 08:10 PM
It was!
The BBS game was TradeWars 2000.
TradeWars 2002 is the spiritual successor.
I still play it.
And angband.
I'm a geek.
Posted by: sidereal | January 29, 2005 at 08:11 PM
JerryN,
Algol?? Wow. I'm impressed. What next? APL?
Posted by: Bernard Yomtov | January 29, 2005 at 09:51 PM
Python blows dead goats. Easy to quickly write stuff in, impossible to maintain.
What's so difficult about it? (I've heard the "impossible to maintain" complaint about perl more times than I can count, but never about python, so I'm curious.)
Posted by: Josh | January 29, 2005 at 09:57 PM
Bernard - yeah, I'm an old fart - I can probably still read the Hollerith code off of a punch card. It was a necessary skill at school, because nobody ever changed the ribbons on the keypunches.
Posted by: JerryN | January 30, 2005 at 01:30 AM
Agreed, although I'm probably coming from archaism: I prever to code under *nix using nedit.
I sincerely hope that you're not referring to me; if so, I must take exception. I, sirrah, am an algorithmist.
Posted by: Slartibartfast | January 30, 2005 at 02:37 PM
Dutchmarbel: As a marketeer I thought that was my prerogative ;-)
I thought marketeers translated normal speech into bullsh*t... ;-)
Posted by: Jesurgislac | January 30, 2005 at 02:41 PM
JerryN,
Me too. No Algol though. Ah for the days of object decks and the like. I probably wrote some of the code the Y2K people were desperately digging through a few years ago. In my defense, given the resource constraints in those days using only two digits for the year was eminently sensible.
It's been a long time since I've programmed. Probably couldn't write something to add two numbers today.
Posted by: Bernard Yomtov | January 30, 2005 at 03:50 PM
++ungood;
Posted by: Slartibartfast | January 30, 2005 at 04:21 PM
Bernard - not only were there resource constraints, but who in their right mind thought that the code they were writing would still be in production a decade or more later?
I worked on one project in the late '80s that was put in place as a quick and dirty stopgap until the real system was in place. Somehow, even after the real system came on line (before 1990), the temporary system never went away. By the early '90s it had been ported 4 times to fresher hardware and gone through a few RDBMS ports as database vendors fell by the wayside. Ultimately, it had to be made Y2K compliant.
Posted by: JerryN | January 30, 2005 at 04:41 PM
Sidereal:
On CASE, it's T-SQL only. Pretend you don't know it if you're interviewing for an Oracle job.
Bzzzt. Been there since Oracle 8i. Though personally DECODE is such an ingrained habit for me, I often forget about CASE entirely.
Posted by: kenB | January 30, 2005 at 04:45 PM
Dutchmarbel: As a marketeer I thought that was my prerogative ;-)
Jesurgislac: I thought marketeers translated normal speech into bullsh*t... ;-)
Nah, that's Sales ;-)
Posted by: dutchmarbel | January 30, 2005 at 05:13 PM
I'm a big fan of "The C++ Standard Template Library" by Plauger, Stepanov, Lee and Musser but I am not sure it's broad enough for what you seek. I basically learned to do templates by studying how the STL is built, and that worked pretty well for me.
Posted by: Jeremy Osner | January 31, 2005 at 12:58 PM
well, since we're washing our dirty laundry in public --
1986: B.A. Dartmouth College in Math / Computer Science. (BASIC, PL-1, C, macintosh architecture, a couple others).
A weird little company called microsoft was interviewing on campus (iirc; maybe they just posted notices they were looking for programmers). and i passed. went to law school instead. (i could be retired by now . . . argh.)
so, Anarch, i guess in your no-holds-barred steelcage deathmatch i get to play with myself.
hmm, don't think that came out right.
Francis
Posted by: fdl | January 31, 2005 at 08:08 PM
so, Anarch, i guess in your no-holds-barred steelcage deathmatch i get to play with myself.
Carton of bleach, cage 3! Yep, Francis has been at it again...
[This seems an opportune moment to mention that I was once recruited for the glamorous and exciting world of jizz-mopping. Paid better -- significantly better -- than my bartending gig at the time, but it turns out that there are some things that not even I can stomach. So to speak.]
Posted by: Anarch | January 31, 2005 at 09:50 PM
Well, I got here late (via "humor", no less! -- the link from "naive, possibly ignorant world politics questions open thread"), but...
Slart, if you're still looking, take a peek at C++ Annotations by Frank B. Brokken, Computing Center, University of Groningen.
I haven't read the template section yet but it's a very good resource for someone who is already a C programmer. It's definitely better for my purposes than Accelerated C++.
As to languages, ... SNOBOL4 (SPITBOL) forever! OK, I'm a nut.
Posted by: ral | March 06, 2005 at 08:38 PM