Arbtirary thoughts on nearly everything from a modernist poet, structural mathematician and functional programmer.

Saturday, December 22, 2007

Ideals, Scheme, and useful kludges: 3 unrelated topics

So... Today I met with a friend I've seen once (maybe) since highschool. We were never really that close, but 2 years age difference will do that... I've often complained about women, drama, etc, but I do find myself often preferring the company of women. I've long struggled to find an answer, and I think I've begun to understand.

It hinges around my idealistic hopes for the world; I have an almost kitschy ideal of human relationships, and there are certain types of interaction I find stimulating. I'm still having trouble pinning these down, but, I digress.

The longing after my ideal place in the world is something I've comet o call nostalgia, however (in)correct that term might be. It is certainly related to the concept of sensucht, angst, despair, nostalgia, discussed by many philosophers of the 19th and 20th centuries. Anyway, when I feel some sort of fulfillment of this ideal, I experience the emotion nostalgia, in all of its painful beauty.

Now, how does this relate to my preference for the company of women? Nostalgia, faith, romance, platonic love, and empathy all fall under a class of emotions; all of these ideals trigger the emotion nostalgia (as well as the emotion they are associated with.) I find myself able to sit down and converse with female friends much more often than male friends. I'm not sure why this is, but a personal connection is easier for me to establish with a woman. Something tells me that I find this connection easier to make because of a desire for romance with these women, but I find this very difficult to accept. Tiffany, Rachel, Katie, Kate, Haley, Tessa, Melissa, Sasha, Adriana, Adie. Of these, I've only felt a "crush" on Tiffany, Katie, Melissa and Adie. Of those, only Katie has developed into something I'd classify as romance. Tiffany was an emotional security blanket, Melissa was the last person I had an engaging conversation with before leaving the springs, and Adie was the first person I truly felt close to in Chicago, so it follows that I'd have had a short-lived crush on each of them.

What really makes sense, is that all of these girls represent an approximation of my ideals. They evoke nostalgia, which allows my to feel a solidarity with them. I haven't met nearly as many guys who do this, perhaps because men make friends in a fundamentally different way than women; the push for alpha status has to be set aside before this sort of friendship can develop, or it has to be clear that we think in a similar way for me to be able to relax around another guy; I guess I'm afraid of the guys "kicking me out".

Katie, then, seems to represent the closes approximation of this ideal. Perhaps it's her passion and faith; perhaps it's the warmth she radiates, but I can't seem to interact with her without getting excited...

On another note, I'm having problems with my cell update functions for the Game of Life, so I've decided to sit down and force my way through the tedium of a whole Scheme tutorial, while of course supplementing it with "oo! I think I can do this!"
I'm still struck my how easy it is to do things in functional style. It's truly breathtaking.

And finally, it ahs been explained to me why someone would want to use the kludges taught by koots. Granted, it doesn't excuse their use as a teaching element: good habits should be taught first, useful, yet inelegant kludges should be taught only after the concept they are useful for. So perhaps he's not a terrible coder, just an inelegant one: an engineer, not an artist.

Wednesday, December 12, 2007

Bad Coding, Bad teaching. OR: Why I want to be a professor

Edit: It seems this site hates my whitespace.... Sorry

I've been helping a friend with CS homework the last few weeks. He's taking "Object Oriented Programming I", which is the intro to programming class for CS and related majors, taught in Java.

I've been helping him because his professor is a hack, an absolute hack. Were he a brilliant man, but a bad teacher (e.g. Calinscu), or an idiot who knew how to teach, it would be acceptable, but he cannot code well and he cannot think well.

Firstly, my friend said "I do not know what object programming is. I don't know how object oriented programming languages work." Investigation shows that the problem is not on my friend's end, because he's understood everything I've taught him. It's that the subject has not come up in his lectures. He has mentioned "template classes", which is a bit redundant....

But I digress. Code samples and critique! These are the professor's, not my friend's... (Some variable names have been changed, but the logic is precisely the same.) The numbers in parenthesis mean I'm going to comment on the line after the segment.

First, a BubbleSort (Copied from a handout):

public int [] bubbleSort (int [] array){
(1) boolean done=false;
(2) int [] arraySorted=array;
(1) int p=0;
(1) int temp=0;
(3) while(!done&&p<=arraysorted.length-1){ (4) done="true"; (5) for(int j="0";j<=arraysorted.length-p-2;j++){ if (arraysorted[j]>arraysorted[j+1]){
return arraysorted;

1: booleans initialize to "false" and ints initialize to '0'. explicitly setting these values is unnecessary. Perhaps a good habit, but unnecessary. p is also in no way descriptive. It isn't following the lisp '-p' convention; why can't he use 'i' or 'count'? 2: Also unnecessary. the parameter "array" does not point to the same location as the array that was sent to it, so the line "int [] newArray = bubbleSort(oldArray);" will create a copy of oldArray, and pass that to bubbleSort().
3:This 'done' flag is absolutely unnecessary... It does nothing. To make matters worse, he handles the flag how drunken frat boys handle glassware: throws it around till it hurts something:
4:Every iteration of the outer loop sets "done" to "false". This means the operation is made n times in the outer loop, where n is the number of loops. It is also set to "false" in every inner loop (as long as flipping happens), this adds ~nlog(n) operations to the procedure. The operations that are done to this boolean flag (which I remind the reader, does not need to be there) have a complexity of O(nlogn). He has effectively turned a flag, which, if properly used (assuming it did need to be there) will take exactly n+1 [O(n)] operations into a flag which will take between 2n and (2n)^2 operations.
5:This one is fun. On the first page of the "how to write readable code" handbook (which doesn't-- but should-- exist) is the following statement:
"Do not use magic numbers!" In CS there are 3 numbers: 0,1,n. Any number besides 0,1 number should be specifically labeled because it's being used for something specific. Better, he has "<=/*some number*/-2" rather than "