肯勇敢面對自己的感覺,已是一種幸福。

Tuesday, December 14, 2004

Programming is an art

Buildings that serve a purpose and enhance the beauty of the environment around them are created by artists disguised as architects. Buildings that are hideous and need to be torn down are created by architects. The difference is that the artist takes pride in what he is doing. He understands that his work will be viewed by many people and therefore stakes his pride in the building. The architect knows that he got paid to finish something within a timeframe and therefore could care less how people see his building. In fact he does not even think the building is his anyways.

Hackers act the same way as architects. They gather bricks and cement and throw something together called a house that although it works will more than likely not stand the test of time. As a programmer you should not see your code as a means to an end. It should provide a source for others to look at and revel in its beauty. I do not mean that you should write a ton of crappy code, but use appropriate whitespace and indents (although whitespace and indents should be used appropriately for legibility). What I mean by beautiful code is more than the look of it. I want to get lost in the beauty of its design. I want to see how simple you make complicated sequences appear. A quick example is the Towers of Hanoi done using recursive functions. There are plenty of ways to go about this problem, but the recursive approach shows you how code can be an art. Although very rarely you see recursiveness used in large designs you must marvel at the simplicity of the design to such a complicated problem. To me simplicity of design is beauty.

A lot of programmers are given code that is not their's and they are told to refactor it or make it work better. This is the greatest time for showing that programming can be an art. It is like someone giving you a marble statue of something that appears to be a man and when you are done with it looks like David.

If you tackle your code as an artist then you are putting an investment into it. You are putting yourself behind the code so that the code represents you. A lot of open source projects need to take heed and listen. Just because you start a great idea for a project and start an account on SourceForge.net it does not mean you will draw in the legions of the open source army. No doubt you will draw interest, but if your code is a catastrophe and the design is horrific then that interest will die quickly, very quickly. Beautiful code and design lasts like great pieces of art.

Programming is an art because you are creating your own masterpiece. You are creating your own exhibit for the world to see. Artists don't paint just so they can keep their works to themselves. They paint because they want the world to enjoy what they enjoy. Why should coding be any different? Of course if you are writing a small program for yourself, write it however you want. I write small little programs that serve my purposes, but I also design them as if I were letting the whole world see them. For some reason I can't let bad design and ugly code get in my way. I take pride in what I do because I take it seriously and I wish others to take me seriously also. Nothing is more fulfilling to me than someone telling me they respect me. If they only know me through my code, then I wish for them to respect my code. For this to happen I have to become the artist that respects his own work.

As programmers you are more than likely under a tight deadline so your main priority is to create working code. However, if the design is not thought out then that working code might be incompatible with the other components that it has to interact with. If there is an art to the design of the code, then even though the code is incompatible, maybe it can be fixed more readily. If something is hacked together quickly, that is understandable, but go back and fix it up. 99% of the time there is a more elegant solution to the problem.

See yourself as a master craftsman who has apprentices and journeymen coming from all over to view your code so that they may learn the art of programming. Take pride in your work not for others' enjoyment, but for your own sense of self. We are artists and that is why we love our art.


This piece originally was published at Whitespace.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home