Divided by a Common Language

"I have come to view C++ as a federation of several different languages: C, OO C++, STL, [and] TMP," wrote Scott Meyers on the comp.lang.c++.moderated newsgroup. Quite so, and the species of programmer that live in the federation are quite varied, too, claims Verity Stob.


July 01, 2004
URL:http://www.drdobbs.com/windows/divided-by-a-common-language/184405745

Verity is the pseudonym of a programmer based in the UK.


Species: Old Men of the C

Stamping ground: Embedded system shops, Linux generally, and the GNOME desktop project in particular.

Spore:

#include "header.h"

#define DIMENSION 1

struct intstruct{
int i1;
int i2;
} is[DIMENSION];

int fn(int** a1, int*** a2) {
int a3, a4;
double d;
char *m;
int ******p;
int i,j,k,l,m;

for(a3=0;*a1[a3]!=**a2;
a3++,a2+=a3,(*a1)--)
/* nothing */;

Regrets: The removal of static as a keyword applied to functions.

Most enviable vice: Guilt-free (type)casting.

Mating call: You do as you like, but I don't trust the compiler doing stuff behind my back.

What to do if one becomes trapped in the house: Bless their little cotton socks! (Cotton socks worn, of course, with sandals.) This is a harmless and usually amiable species, once very widespread, but now sadly somewhat declined. Treat it gently, and see if you can get it to take a saucer of warm gin.

Species: Microsoft Soviet Era

Stamping ground: Wherever you may find five-year-old Windows projects.

Spore:

BOOL CVeryBigClass::GetResult()
{
BOOL bBoolResult = (
GetScaryApiInfoEx(
m_hHandle,
m_nNumber,
m_lpszString,
NULL,
NULL,
NULL,
NULL,
// Many more lines of NULLs
// omitted for brevity
NULL)) ? TRUE : FALSE;
if (bBoolResult == TRUE)
return TRUE;
else if (bBoolResult != TRUE)
return FALSE;
else
return FALSE;
}

Mating call: MFC always was underrated. It's very, very powerful, once you understand it properly.

Guilty secret: Hopes that Microsoft will give up on 'all this .NET malarkey. I mean, it may be all right for you people, but in our line of business we really need that front-end performance. C#, pah!'

Really daring thing it does for a lark: Edit the AFX_MSG_MAP block generated by the ClassWizard, in open defiance of the official comment prohibiting this.

What to do if one becomes trapped in the house: They can be driven off effectively and humanely using the Stobbo patent SoftieScarer, which gives off the musty odour of MCSD Exam 70-016 (discontinued). A snip at $200.

Species: Confused Putative STL User

Stamping ground: Small independent programming shops, where C++ is not the main language.

Spore:

// Yes! Yes! Yes!
// More Meg Ryan noises!!!
// Got find_if to work!!!!!

Chns::iterator itChan =
find_if(chns.begin(), chns.end(),
bind2nd( cmpWrap() , name));

// ...

// Found this string trim on the Net
// that uses 'find_first_not_of'
// It has a bug - throws if no trimmable
// chars.
//
// But at least it compiles, and it
// *is* very elegant. So am keeping it
// here commented out, in case
// some day I figure out how to
// fix it

Guilty secret: Continues to use the Singleton pattern, despite its fall from grace in more fashionable circles.

Mating call: Did I tell you about my milkshake trait? It brings all the boys to the yard.

Unconvincing attempt to mix it with hard-core C++ techies: What, are there really punters who don't care a fig about the Standard? And are quite content if something just works with their compiler? Well. I'm very shocked, I can tell you. Shocked.

Another way to catch it out: Yes of course I use the Boost Graph Library. I love its 3D pie charts.

Reason for notable familiarity with this species? You wouldn't perhaps belong... Mind your own business.

Species: The League of TMPers

Stamping ground: The specialist newsgroups.

Spore:

// factorial
template <int N>
struct fact {
enum { res = N * fact<N - 1>::res };
};

template <>
struct fact<0> {
enum { res = 0 };
};
// initialise j to 8!
int j = fact<8>::res;

Progenitor: In 1994, Erwin Unruh turned up at a C++ standardisation meeting with a program that didn't compile, but which output a sequence of prime numbers in its compilation error messages.

Evolution: Ten years later, many TMP programs now compile. There again, not that many.

Notable characteristic of Template Meta-Programming programs: Computation is done at compile time not runtime.

Mating call: My compile time is longer than yours.

Where do they come from, these meta-programmers? Those kids, the ones who were given 'My Little C++ Compiler' for their seventh birthday, have grown up.

Wait a moment. Your 8 factorial evaluates to 0 instead of 40320. You want a '1' in the template specialisation. Oh, leave me alone, clever clogs.

You're sore because these TMPers are smarter than you. I admit it. I am envious, to envy level nine. You will recall that the envy scale is logarithmic.

Pathetic challenge: If they are so clever, let's see them write a GUI dialog with this technique. A complex one with lots of tabs and maybe a slider. And make it look nice.

What to do if one becomes trapped in the house: If you can possibly do so without putting yourself at risk, open the front door and see it run friskily out onto the snow—black on white, black on white, black on white, and then gone.

DDJ

Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.