Archive for November, 2008

Writing and Programming

November 12th, 2008

This post is inspired by Jeff Atwoods post “Coding: It’s just writing“  Jeff argues that like writing, to code effectively is to write clear concise code.

When you’re writing on a personal blog. Very little thought goes into what you write. Much of the time, it’s almost a stream of consciousness, it’s whatever comes to your mind at the time of writing. Unless you’re a natural and experience writer with an expertise on the subject on which you’re writing, your readership will never reach an audience beyond your social circle. When you write professionally, or at least outside the personal blogging bubble, you expect to have a bigger audience, or at least an audience with higher expectations of the quality of your writing. You take more time with the choice of words, the choice of topics, the sentence structure, you have to think about what you want your audience to get out of it, you think about what your audience would like to read and whether they would like to read more of your writing afterwards. When we are reading someone elses writing, whether it’s a book, a review of a movie, or an article in the news paper, we expect certain standards or properties from each piece of writing. We unconsciously expect that the authors have considered their audiences when writing, and hope that we’re part of the audience that will find it interesting, relevant and useful.

Similarly, when you write code in the real world, you are writing it for others to read. You have an audience, those who will be maintaining your code. When we inherit someone else’s code, we hope that the authors have considered their audience and wrote code clear enough for you to understand and maintain. You hope that they have built a framework based on best practice design patterns, and that you can add to it or change it without too much effort.

When you work on a pet project, most of the time, you’re the only person who is going to read the source code, and it’s okay to take shortcuts, write ‘hacky’ code, and provide little to no internal documentation. For any non-programmers sad enough to be reading this blog(get a life!), imaging building a house and realize only after you are nearly finished that you forgot to build a bathroom. When a programming faces a analogous situation, he/she would have to write ‘hacky’ code to get around the problem by perhaps using the kitchen as a bathroom because it has similar pluming.

When you work on bigger projects, you have to think about the overall design of the system you’re building, otherwise it gets too complex to manage and you’ll be forced to use hacky programming tricks to fix and change things that will confuse those who will be reading your code later. (Imaging living in and maintaining a house with a kitchen that doubles up as a bathroom, how awkward!) When you write a book or a major essay, you have to do some top down design. It has to have some structure and planning, otherwise you’ll confuse your audience and the ideas you’re trying to present constantly changing as your mental state changes while writing.

I started blogging because I wanted practice in writing. As much as I hated English class in high school, I miss the creative writing essays — essays which I very much enjoyed writing. I chose to study computer science because I thoroughly enjoyed my first programming class in high school. Yet I’ve always thought they were very different activities. One requiring creativity, the other requiring strict logic and analysis. Only after reading Jeff’s post did I notice the similarity between the two. I’m not a natural writer, and I wouldn’t call myself a natural programmer, but I certainly find the latter much easier. Perhaps with this new realization, I can learn to write and code better at the same time.

The elements of style (a book on effective writing that inspired Jeff’s post that inspired mine) has been added to my to-read list. I’ve probably violated many advices that this book will recommend about writing, but this is still a personal blog with almost no audience base and I can still write things without much thought if I wanted to :)

Silly thoughts that keep me awake at night

November 1st, 2008

Before you go to sleep every night, what do you think about? Do you reflect on the events that happened during the day? Do you think about how you’re going to talk to that girl/boy whom you have a crush on? What about that embarrassing thing you said when the wrong person was in the room? …Do you think about number theory?

I’ve thought about all of the above and much more at one point or another. Some of those things make me sleep better at night, others keep me up till dawn. I sometimes ask myself, “is this the direction I want to be heading in life?” The answer is never quite clear. What are my long term goals, do my short term goals complement the long term ones, and are my decisions and actions helping me reach them? To which I answer, “what goals? I don’t have long/short term goals!” I don’t have very specific goals, but I wish did, and I wish I could answer those questions. I’m not certain about what I want out of life. Is anybody certain, really? What I do know is this: I want to achieve balance. A balance between work and play. I want to experience excitement, but I also value my quiet time. I have ambitions, but if I had to, I wouldn’t don’t want to sacrifice everything else in my life to pursue them. Having balance is a very generic want, but I don’t think it’s very common to see it fulfilled. Without more specific goals, I feel that anything that fulfills my wants comes only as a stroke of luck.

I love my degree, I enjoy the theory that makes todays technologies possible, and putting it in practice and actually seeing a piece of technology being created, even if it’s something small or a recreation of something that already exists. I enjoy programming because I like creating things, and I enjoy solving problems. I’m lazy but I like efficiency, that’s a common characteristic I see among my peers. We hate doing manual work, especially repetitive work. Who doesn’t? Programmers can do something about that. We can write programs to do the work for us, sometimes writing those programs can take longer than the work itself, but it’s all worth it, because we turned something boring into something challenging and exciting. Nevertheless, sometimes I wonder, do I want to have software development as a career? Sure I enjoy computer science in academia, but there are a lot of things that come with real work that is very boring to me. Having to learn a programming language that I don’t like, having to read other people’s badly written code–badly written because they were under a deadline and couldn’t design it properly, which unfortunately is the state of most code I’m expecting to see in the real world. There is a tendency for us to rewrite code from scratch because code written by someone is always less legible and elegant to the someone else reading it, but that’s one of the things that I need to learn not to do.

I’ve gotten myself into things that prevents me from focusing on and enjoying my degree to the fullest, sometimes they prevent me from enjoying my degree at all. In exchange, I’m a part of something different like producing a theatre show and being on stage in front of hundreds of people to watch them laugh and cheer for something that we’ve created. Is it all worth it? I think so. There will rarely be any more opportunities to do this kind of thing after going into the workforce. Many people have told me that it’s too much stress and time commitment and that it’s totally irrational to do it with a full load of uni work. They might be right, and I also think that it’s irrational. Those observing from a distance can see a clearer picture, but they tend to miss finer details that make doing this worth it.

I need to stop thinking. I need a peace of mind.