Daniel Pitts’ Tech Blog

Archive for the ‘Uncategorized’ Category

OpenID

Saturday, April 5th, 2008

I went to post a comment on an old acquaintance’s blog, and it asked me for either a Blogger account, or an OpenID. I didn’t have the former, and hadn’t heard of the latter. I checked it out, downloaded and installed phpMyID, and now my OpenID will be http://virtualinfinity.net/openid/daniel_pitts/ Pretty awesome if you ask me :-)

Life’s been hectic.

Monday, January 28th, 2008

Work’s been crazy, we just moved, and we have a baby on the way (Due date 2008-07-04).  I promise I’ll come up with something to write about soon.

Site back up.

Tuesday, December 18th, 2007

As you can see, the site is back up on schedule. Yippy.

One of these days, when I can afford it, I’ll get a dedicated server somewhere. :-)

Moving Server: Site downtime 12-11-2007 through ~12-18-2007.

Monday, December 10th, 2007

We’re moving tomorrow (12-11).  Since I host this site from my apartment, that means the site will experience some downtime.  I hope to “colo” the machine at a friends house during the interim, but there will be some down-time either way. I’ll try to minimize the downtime.

HTML and ShortTags: Its valid but doesn’t work, or its invalid but it works

Thursday, October 25th, 2007

I discovered something interesting the other day. There are some HTML syntaxes that are surprising, but most browsers don’t support them anyway…

Specifically, <p<a href="/">Some Text</> some other text is technically the same as <p><a href="/">Some Text</a> some other text. Unfortunately, most browsers don’t properly support SGML short-tags, so the outcome is likely different than the spec says it should be.

Read more about this at w3c html blog.

Writing as an artform.

Tuesday, October 2nd, 2007

When we write, we seek an elegance in our expression. We intend the writing to be read either by ourselves or others. Stylistic devices help us convey our intent. Rewriting and moving parts around comes naturally, if we think it’s better.

There are also different levels of writing. I feel we label them backwards, when we say “reading level”. Some writings are much more difficult to read, due to the structure used or the difficulty encountered while trying to express your intent with the written language. The product of some authors is easier to read because it is better organized in both its structure and expressions.

It can be difficult to express certain things unless we assume a reading level of our audience, and by all rights we should assume the audience is capable of understanding, provided the structure is as elegant as possible.

Usually, the same meaning can be expressed in many different ways. Sometimes we strive to find a concise expression, even if that conciseness of expression increases the reading level.

You might feel like asking me “So, what’s with the essay on writing? Isn’t this a Tech Blog? It says so right in the title!” I never said I was talking about writing in English. All of those statements apply to writing a program as much as (if not more than) writing an essay. Why is it that we spend so much time teaching programmers-to-be about syntax and making the compiler understand, and so little time on teaching them how to make an understandable and expressive source file for humans?

We all look back on our early projects and thing WTF was I thinking? Even our comments were unhelpful. /* this statement tells the readers that the comments didn’t help */

For people who are passionate about developing software, the realization comes eventually that code can be expressive without the need for comments. Comments become useful only to explain justification for choosing an approach over another, instead of reiterating what the code says it does. Breaking a procedure down into its component parts and naming them appropriately not only allows a person to read the code in a more natural manor, it helps the original author not repeat themselves.

It could be that part of the problem is that text books use comments to explain syntax to the students.

/* The following line assigns the value “foo” to the variable bar. */

This may be useful as a teaching tool, but when you’re writing software in a professional environment, you’re (usually) not trying to teach your colleagues the syntax of that particular programming language. Computer Science teachers often compound the problem be setting a comment quota. The only time I felt that was at all justified was my assembly language teacher, who required more than one comment per line of actual code.

The moral of the story? Separate the teaching of syntax and the teaching of how to write a program. Teach people that using a meaning name can be more powerful than two comments (one at the call, and the other at the definition). Help people understand that your writing isn’t meant only for the compiler, but as much (if not more) for the human.

Make the world a better place. If you feel the need to comment on what a piece of code does, turn it into a function/method/procedure call whose name implies your would-be comment. Do this even for conditions. “if (cans * pricePerCan < goal)” can be rewritten as “if (belowPriceGoalForCans())”.