Untrained Programmers

Yesterday I discovered why so many scientists write their own code for things despite there being other code already out there. The code already out there stinks. It is filled with bad practices, spaghetti code, idiosyncrasies and poor design choices.

In my last non diet post I spoke of helping a friend debug a data analysis program. It was horrible. Every function and variable name started with the letter z. The variable names did not make their usage clear. At least 95% of the variables were declared in a global fashion. There were gotos everywhere, all with nonobvious names. There were while statements and if statements that would always evaluate to true. Not once did the programmer free any memory that they had allocated with malloc. No array boundaries were ever checked. Chunks of memory that were not large enough for the array desired were allocated and the programmer just read past the end of the arrays (and got away with it in an ancient solaris machine). It was unpleasant.

Oh did I mention the whole thing was written in c? c is an evil evil programming language. Lacking any object oriented paradigms it lets bad programmers to some truly horrible things, with all the functions coming out of nowhere and no real indication of what they are operating on or why, trying to read code like that is a nightmare. Of course my personal language c++ lets bad programmers construct some REAL atrocities so I shouldn’t say to much there.

I think there should be some sort of scientist programming license, you have to take a couple courses on programming and good programming practices. Then you have to pass a test on those practices and certain system headers that many seem to reinvent bits of. Then and only then can you get your scientific programming license.