The summer of ‘99: Junior-Style / Newbie Programming
Steve Yegge discusses junior-style programming in his post: Portrait of a n00b. After reading Steve’ post I decided to dig up some of my own newbie code - this code is from the summer of ‘99.
I got my first real C++ book
Bought it at the local book store
read it ’til my eyes turned red
it was the summer of ‘99
I found this code amusing… To keep things short, I included one method, but the entire class implementation is similar - my comments describe almost every facet of what I now regard as relatively simple logic and I’ve completely removed all whitespace.
As Steve puts it:
[I was] making up a temporal narrative in an attempt to carve out a mental picture of the computation for myself. These stories I told myself were a critical part of my mental development as a programmer. I was a child trying to make sense of a big, scary new world. - Steve Yegge: Portrait of a n00b
The code:
//***************************_Command.cpp_********************************* //__Creator:_____________Adam Kahtava //__Date:________________June 14, 1999 //************************************************************************* //-----Implements the init method defined in the command.h header file //-----Keywords and Modifiers are initialized into keyword[], and modifier[1-5]. //-----(Keywords and modifiers are all separated by semi-colons). void command::init(char data[]){ int j=0; int len=strlen(data); for(int i=0;i<6;i++){ //this for loop is run 6 times, 1st for the keyword, // and 5 times for the modifiers, and increments i. int k=0; char temp[20]={""}; //sets temp to "" (the default) //goes through "data" copying string into "temp", // until delimiter ";", '\0' is encountered or until len >= j while((data[j]!=';'&&data[j]!='\0')&&len>=j){ temp[k]=data[j]; //copies useful data from "data" to "temp" i++; //increments i k++; //increments k } if(i==0){ //is initiated on first "for loop". strcpy(keyword,temp); //copies temp to keyword/ } else if(i>0){ //else if "for loop" has been run more than once. strcpy(modifier[i-1],temp); //copies temp to modifier[1-5]. } j++; //increments j } }
Notable difference from then and now:
Back in ‘99 I thought everything I wrote was awesome, I thought I was a Code Poet, or a Programming Ninja (with Real Ultimate Power). I thought my descriptive comments were awesome, and probably thought that by removing all whitespace I would be increasing the program’s efficiency. I thought I could learn more by just programming than reading about programming - I recall discarding books and often hacking my way to comprehension. I was clearly disillusioned.
Today I agree with Jeff Atwood that everything I write sucks, I have an obsession with white space, and prefer to thoroughly understand a programming language before verbalizing my proficiency in it. Now I occasionally get complaints that I’m not including enough comments, and I’m still improving and learning. :)