« Thrice-annual Brain Dump. | Main | naive, possibly ignorant world politics questions open thread »

January 29, 2005

Comments

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!

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?

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++

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

My advice: RUN! Run for your life!

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.

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++ !

C? C++?

What the hell is wrong with Fortran?

Object oriented programming is a tool of the devil.
RUN! Run for your life!
What the hell is wrong with Fortran?

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:

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?

Done. Am I accommodating, or what?

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.

write down a list of what you need done, show it to your guru guy

Don't underestimate the value of pleasantly surprising the guru on the following Monday.

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.

Sorry, took of my shoes to do the math properly, and I've been OOPing for nineteen years, not twenty-two.

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

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.

Chuchundra,

OOP rocks :P
I am a Java developer, by the way.

Slarti,

I like Deitel books, personally.

Doh, never mind Deitel. More of a beginner type books.

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:

I argue that clear use of function pointers is the heart of object­oriented programming. Given a set of operations you want to perform on data, and a set of data types you want to respond to those operations, the easiest way to put the program together is with a group of function pointers for each type. This, in a nutshell, defines class and method. The O­O languages give you more of course - prettier syntax, derived types and so on - but conceptually they provide little extra.

Combining data­driven programs with function pointers leads to an astonishingly expressive way of working, a way that, in my experience, has often led to pleasant surprises. Even without a special O­O language, you can get 90% of the benefit for no extra work and be more in control of the result. I cannot recommend an implementation style more highly.

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.

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

While I like C++, it is the subject of the greatest putdown evah:

"C++: An octopus made by nailing extra legs onto a dog."

Or you could just skip C++ and learn a decent language like Java or C#.

Feh. Everyone knows that great hackers prefer Python.

Stan, you're a Java programmer? Well, I might have known.

Oooh! programming language flamewars. This place gets more like Usenet every day.

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.

I love perl, though I use python at work. SQL, yuck.

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.

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.

Java. Ignore the haters.
If you want to avoid compilation, php is more readable than perl.
Scheme, for good times.

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.

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.

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.

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.

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.

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.

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.

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!

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.

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.

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.

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.)

Was that the same TradeWars that started as a FidoNet-based game in the late eighties?

double,

Ever play Telegard/PC Board based games? Ie, The Pit, Global Wars, etc?


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.

No, 'fraid not.

Were you active on any l33t boards? ;)

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.

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.

It was!
The BBS game was TradeWars 2000.
TradeWars 2002 is the spiritual successor.

I still play it.
And angband.
I'm a geek.

JerryN,

Algol?? Wow. I'm impressed. What next? APL?

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.)

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.

Visual Studio is complete shite.

Agreed, although I'm probably coming from archaism: I prever to code under *nix using nedit.

And let me say that I am surprised and horrified at the number of ObWiers that are programmers.

I sincerely hope that you're not referring to me; if so, I must take exception. I, sirrah, am an algorithmist.

Dutchmarbel: As a marketeer I thought that was my prerogative ;-)

I thought marketeers translated normal speech into bullsh*t... ;-)

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.

++ungood;

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.

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.

Dutchmarbel: As a marketeer I thought that was my prerogative ;-)

Jesurgislac: I thought marketeers translated normal speech into bullsh*t... ;-)

Nah, that's Sales ;-)

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.

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

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.]

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.

The comments to this entry are closed.

Blog powered by Typepad