Sunday, October 18, 2009

The Three Functions of Comments in Programming

If you don't program computers, you probably won't find this post interesting, so just enjoy the raccoon picture, and I'll see you next week.


In computer programming, a "comment" is a series of characters that is meant for the programmer, and not the computer, to read.

When you program, you often do it in an "editor," and most editors help you out by color-coding the comments (among other things) so that you can readily see what's a comment and what's actual code.

However, there are three distinct functions of comments, and I think they deserve different colors.


  1. Comments as explanation and documentation. Some comments are there to explain the code someone trying to read the code. Computer programs are full of jargon, and comments like this help the programmer understand what the code is doing. This is what most people think comments are for.
  2. "Commenting out" code so that it doesn't run.  This is often done during debugging, when, for example, a bit of code isn't working, or taking too long while you find some error elsewhere, or when you no longer want that functionality but might in the future (if you never wanted that functionality again you'd just delete the code). 
  3. Commenting out code that is there for debugging. Sometimes I will put in a print statement, usually, so that when I run the program I can tell what it's doing. When the program is working, I don't need that output, so I can get rid of these lines. However, since I might have to go back and debug again, I like to leave in the debugging code for later use. So I comment it out. 


They're different enough functions that I think they deserve their own color coding-- particularly 1 and 2. 3 can get grouped in with 2 in a pinch.

But I think code would be easier to read if the explanation, for example, were distinctly colored.

In the meantime I have my own workarounds. I program in python. To comment in python you put a # mark, and everything after that on the line is a comment.

For explanation comments (type 1), I use a double hash: ##
For non-working code comments (type 2), I use a single hash:  # (this is because it should be short and easy to remove and retype)
For the commenting of debugging code, I use "# FDO " which stands for "For Debugging Only."

Works for me. There should be three ways to comment, and each should get their own color. But until then, that's my little hack to make them different.

Bookmark and Share

Saturday, October 17, 2009

How to Use Google Wave Outside America

Google Wave is a new, free product from Google that combines email and chat. I love it.
This video is 80 minutes long, but it describes all the features I know about.



Unfortunately, if you're not in America, you can't sign up for it.

However, I found a workaround.

Get someone to invite you, and go to America and accept it. That's what I did when I was in Atlantic City last week for VisWeek 09.

I guess once you log into it in America, it just figures you're an American travelling abroad when you come back to Canada, or what have you. I'm in Ottawa, and wave is working great!

Bookmark and Share

Friday, October 09, 2009

My Talk Online: Don't Waste Student Work



I gave a talk recently that I'm very proud of, introducing my innovative teaching philosophy. I presented it on September 30, 2009, and it was well attended and well-received. The talk is half an hour long, followed by half an hour of my answering audience questions.

I hope you find it inspiring. 

http://vimeo.com/6986853

There is a paper associated with this talk too:
Davies, J. (2009). Don't waste student work: Using classroom assignments to contribute to online resources. Carleton University Cognitive Science Technical Report 2009-01, http://www.carleton.ca/ics/TechReports

You can download the paper at http://jimdavies.org/research/publications/technical-reports/Davies2009.html

 Enjoy!


Bookmark and Share

Monday, October 05, 2009

Why Hypocrisy Doesn't Bother Me




It's always struck me how much people can't stand hypocrites. They never bothered me very much. I think it's because I think the charge of hypocrisy is an ad hominem attack.
Which is, basically, attacking someone's character to weaken others' confidence in their claims.

Hypocrites say you should do one thing but fail to practice what they preach. They way I see it, there are two aspects of a person going on here: their moral sophistication on the one hand and their impulse control and will power on the other. 

Imagine that someone suggests that a person should do x. Whether or not it is true that a person can do x is determined by thinking carefully about implications in morality, practicality, etc. Someone's moral sophistication will influence how good they are at this kind of reasoning. 

Impulse control, on the other hand, is only how well you manage to resist temptation, such as not cheating on a test. Will power allows you to do something that you don't want to, like dieting. I know of no reason to think that moral sophistication correlates with these qualities. So what's the big deal with being a hypocrite? Someone can very well know that something is wrong and fail to live up to their own standards. Don't most of us? It doesn't follow that the moral standards are suspect.

Perhaps the hypocrite should shut up. If they don't express their beliefs, then they can't be hypocrites. They just behave badly. I don't like this recommendation, because I think people with moral sophistication SHOULD speak up, regardless of how well they manage to do what they know to be right. It seems senseless to me to restrict who can speak on moral matters only to those with incredible will power and impulse control. These people are rare. 

There is one form of hypocrisy that one should watch out for, and that is people who are particularly vehement about things people shouldn't do  because they are particularly tempted to do it. It turns out, for example, that homophobic men are more sexually aroused by homosexual content than non-homophobes.
I think what can happen is that people have desires they believe are bad, and the frequency and difficulty of resisting these impulses causes them to believe that the matter is very important, encouraging them to spread the belief about how wrong it is. Someone who has trouble resisting gambling, and has lost a lot of money doing it, for example, but be particularly vocal about discouraging it. As someone who is pretty much never tempted to gamble, I don't feel the same urgency. In my life it's just not a problem.

Such findings as the homophobe study make me wonder when I hear someone getting very emotional about some moral stance-- it doesn't mean that they are wrong (as that would be ad hominem), but if we're not careful we can believe something more if it is delivered with conviction, and if the conviction is coming from a place of guilt and fear rather than reason, we need to pay more attention. 

A "wanton," as defined by philosopher Harry Frankfurt (1982) and discussed extensively in Stanovich (2004, p227), is someone who has no opinion about his or her desires. For example, you might want to eat another piece of chocolate cake, but not want to want to eat another piece. Such desires are called "second-order" desires, because they are desires about desires. A wanton has no second-order desires. They just go through life accepting their every desire. 

Stanovich makes the point that most reflective people with second-order desires actually are hypocrites, at least in their own mind. People not living up to their own standards says more about their standards than their will power. Wantons are perfectly satisfied with whatever they want. To Stanovich, not acting in perfect accordance with your second-order desires is a sign of a reflective person. 


REFERENCES

Harry Frankfurt, 1982, The Importance of What We Care About, Synthese 53 (2).
Stanovich, K. (2004). The Robot’s Rebellion: Finding Meaning in the Age of Darwin. University of Chicago Press. 



Bookmark and Share

Friday, October 02, 2009

Calligraphy: Graffiti: "Jim"






I think graffiti is often very beautiful, and I've been trying, without putting very much time into it, to get better at it for the past few years. I got a new book, which is very good, on how to do it (Martinez, 2009). With the piece pictured, which says "Jim," I think I finally got it. The colors are not good, but I like the composition.

Graffiti has been an influence on my calligraphy in general, which I try to keep in my personal style, but I'm interested in getting good at traditional graffiti as well.

Some wonder why taggers (graffiti artists) make lettering that is not readable. I like one response I read, that compared it to a bird song. You can appreciate the beauty without being able to understand what the song means. Likewise, you can learn to appreciate the formal aesthetic properties of the piece without knowing what it says. In my calligraphy in general, I try to use the letters as a jumping off point, an inspiration, for a composition. The point is not, particularly, to make something for someone to read. In fact, I find that if people have no trouble reading something in a work of art, they often stop looking. I think it's because they feel like after they've read what it says, they've understood the work as much as they need to. Obfuscating the letters encourages one to look longer, to try to work it out.

This reminds me of a recent article I read that shows that viewing strange, surreal art encourages learning.

References:

Martinez, S. (2009) Graff: The Art and Technique of Graffiti. Impact, Cincinatti, OH.
Bookmark and Share