Thursday, July 29, 2004

C++ is Not a Scripting Language

Ok, listen up you fuckers: one of the problems with programming and programmers is that a lot of the developers who are really good at coding are not so good at explaining their ideas to others. Being the egoists that programmers are, instead of realising that we don't grasp inter-human communication so well, we tend to think instead that our audience is just too slow to grasp our brilliant ideas. But I digress. What I am trying to say is that when you hack on code in a procedural, scriptish way, it's hard to avoid developing certain conventions that you have to enforce yourself. And probably others whom you work with will have different preferences in the kinds of conventions that they would choose to follow, and it results in big arguments with lots of hand-waving and raised voices. Don't pretend like you don't know exactly what I'm talking about.

C++ is not a well designed programming language, and it does not have an even remotely elegant approach to the whole object-oriented bag, but it does allow for encapsulation, and straight-forward class inheritance is possible. Just because many features of C++ are totally archaic doesn't mean that you have to write archaic C++ code--it is possible to write reasonable object-oriented C++ code just as it is possible to write Objective C. Now here's a trick that all programmers know about, and most programmers are constantly forgetting: if you write your code in a well encapsulated manner, you can make it self-enforcing to the point where your co-workers don't need to argue with you about it. That really is the whole point of encapsulation, and even object-oriented code at all. Otherwise there'd never have been a need to progress beyond the world of C.

So the next time you get in a big argument with another programmer over whether or not such-and-such a way of coding is reasonable, consider whether or not you could have avoided that nasty confrontation if you'd spent more time encapsulating your code and generalizing it to the point where others can use it without worrying about how it works under the hood. It's not a cure-all solution, but you may be surprised at how effective it can be.

4 Comments:

At July 30, 2004 at 2:02 PM, Blogger fritz said...

Better than bein' a fish gutter, parappa. :)

 
At August 2, 2004 at 11:10 PM, Blogger Parappa said...

Hey, I didn't say that I was unhappy with my job. :) I'm just frustrated with programmers who implement things in arbitrary, obscure ways, and are later grouchy and defensive about it when they can't justify their decisions. Actually, what I'm more frustrated about is people who write C++ code as if they were allergic to the idea of trying to organize it. It's one thing to write a shell script as one gigantic, procedural mess--but C++ is supposed to be above that kind of hackish abuse. I've seen some code that looked like the author originally had "#!/bin/csh" at the top of the file and later replaced it with "void main(void) {" as an after-thought.

 
At August 2, 2004 at 11:16 PM, Blogger Parappa said...

To phrase my arguement in a more meaningful way (who knows--some real programming geeks might nitpick it someday), what I'm really saying is that if you're just hacking together some kind of sloppy program to get the job done quickly, C++ is probably the wrong tool to be using. Try JavaScript or something.

 
At August 4, 2004 at 9:29 AM, Blogger Parappa said...

I was gonna write "int main(int argc, char** argv)", but then I thought to myself that most lazy programmers just write "void main(void)" because they can get away with that in C++.

"bkac"? wtf? Even Google wasn't able to help me out with that one.

 

Post a Comment

<< Home