Use A Modern Language Already

As I write this, it is July 2021.

Why are people still writing code like it’s 1970???

Why is it that people make a virtue out of writing code in obsolete languages?

People are writing code in C++ dialects that are older than they are. C++20 support is mature and stable-enough for production right now, and even if it weren’t, you can go back a few to C++11, which is rock-solid on every compiler I can even name. But no—people are writing new code in C++98!


I count C, all versions of C, in this. C wasn’t designed. C was heroically developed in pieces in either PDP assembly or an extinct predecessor language—it’s so old, no one really knows anymore. C is strictly inferior to C++ in every way, and in fact almost any C program is a C++ program, just using fewer features.

I get that C is supposed to be simple, but there is a difference between the kind of “simple” that is elegant, versus the kind of “simple” that is pointlessly restrictive. Here’s a clear example. Which code is clearer? Which one is less error-prone?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
float sum_singles(float const xs[],size_t len) {
	size_t i;
	float sum;
	sum = 0.0f;
	for (i=0;i<len;++i) {
		sum += xs[i];
	}
	return sum;
}
double sum_doubles(double const xs[],size_t len) {
	size_t i;
	double sum;
	sum = 0.0;
	for (i=0;i<len;++i) {
		sum += xs[i];
	}
	return sum;
}
int sum_ints(int const xs[],size_t len) {
	size_t i;
	int sum;
	sum = 0;
	for (i=0;i<len;++i) {
		sum += xs[i];
	}
	return sum;
}
//...

C++

1
2
3
4
5
6
7
8
template<class T>
T sum_anything(T const xs[],size_t len) {
	T sum = T(0);
	for (size_t i=0;i<len;++i) {
		sum += xs[i];
	}
	return sum;
}

Where C has to spend performance and clarity to return error conditions by error code or reference-to-flag, which must be checked meticulously by the caller and be interspersed throughout the normal control flow of the program, C++ has exceptions, which are both faster, describe the failures, and handled by the compiler so it is impossible for failures to be ignored accidentally.


This isn’t just pointless and degrading for everyone involved—it’s actually hazardous, as new revisions of language standards fix confusing language features that could lead to bugs in new code, or even the language itself. People are deliberately using language standards with ambiguous grammar flaws. Or all those people ranting about how their code runs in old versions of Python 3? I sure hope no one does use an older version, because the 3.0 interpreter, for example, hasn’t had any security patches for more than a decade!

No bruh. Your code isn’t “portable” or “robust” or “high-quality”. Your code is a tangled nightmare of workarounds and cruft that could have been three times faster, a dozen times clearer, and thousand times more secure if it had been coded in a version of the language that wasn’t written before you were born.

You have the gall to fight clarity—the single most important goal in all of software engineering—and the stupidity to believe you’re doing the world a favor.

If you like the last millennium so much, then go the hell back. Leave the rest of us to writing quality code.


Return to the list of blog posts.