Tuesday, August 26, 2008

Rudiments? Atavisms?

I've noticed an interesting fact during recent (and not so recent) refactoring sessions: junior programmers are using constructs that they couldn't possibly be taught using. Such as, huge blocks of variable declarations (the record is 152 declared variables: int i1, int i2; ... int i99; and so on), usually uninitialized.

The devastating consequence of this is that the compiler won't be able to detect branches that don't initialize the variables, and will happily use given default values and thus let you produce complete crap.

The closest historical origin of this is C, not even C++. It is highly unlikely that very junior Java programmers ever had any C exposure. The only explanation I have is that they keep stealing the code that was written somewhere in late nineties by some inexperienced C programmer trying to learn Java, and they keep doing that for years and years (actually, rather decades now) without a slightest attempt at comprehension of what it actually does, or where did it come from. Thus reaffirming again the painful experience of cargo cult programming.

Like the saying goes, you can write Fortran in any language...

But I wonder, maybe there's a different, better explanation?

No comments:

Post a Comment