Thereâ€™s a very interesting discussion on stack overflow right now about learning how to program:Â http://stackoverflow.com/questions/2823571/im-graduating-with-a-computer-science-degree-but-i-dont-feel-like-i-know-how-to
Yesterday, my pair-programming partner mentioned that he thinks code should be art.Â A few weeks ago, another programmer said she wanted to write beautiful code.Â These are awesome goals, and I it made me happy that they even realized these are laudable goals; code, application design, and a running program can (and usually should) be beautiful and elegant.
So, Iâ€™m going to start a series of posts all about beautiful coding, elegant designs, and creating wonderful applications.
The advice on the above stack overflow discussion is very good, and I recommend reading it.Â Â A related post is Joel’ Spolskyâ€™s excellent â€œThe Perils of Java Schoolsâ€.
Certainly thereâ€™s nothing better for learning about how a computer works internally than programming 2D or 3D graphics routines in assembler and linking that to your hybrid C/C++ program managing the rest of your game.Â If youâ€™re using a C++ object oriented approach for the elements of your game (weapons, characters, land tiles, whatever) then you can start to get a sense of good object oriented design.
However, my understanding is that very few game programmers are doing things in assembler these days â€“ DirectX with C/C++ is blazingly fast, and DirectX with .NET is usually fast enough and is much nicer to program in with its automatic memory management and the extensive functionality of the .NET framework.
At the heart of becoming a great programmer is â€“ not surprisingly – a desire to become a great programmer!Â You have to want to write beautiful code using elegant designs to produce wonderful applications.Â You have to want to write code that you can be proud of, even years later.
Itâ€™s going to take at least 10 years.Â Thatâ€™s not 10 years working in a big corporation where 50% of your time is writing TPS Reports, 20% is in meetings, 10% is office gossip, and 10% 😉 is maybe spent fixing somebody elseâ€™s mess with the cacophony of 5 simultaneous conversations about TPS Reports rage in the cubicles around you.
To really learn to program you need to work on things youâ€™re passionate about – a small personal project, or better yet a large personal project.Â Thereâ€™s nothing better than fixing bugs in your own code 2 years later while cursing the idiot that wrote the code for not using a better design and writing some useful documentation.
My own project was a 75,000 line artificial intelligence natural language application written in C++ (and later migrated to C#) that I started shortly after graduating university.Â It was really hard and I made a lot of mistakes.Â I fixed them.Â I made more mistakes, and cursed myself for repeating some mistakes, and then I fixed them.Â Over 3 years I worked on this project a lot; I learned a lot.
Similarly, back in high school and university I programmed games.Â I made a lot of mistakes there too, and I learned a lot.Â A few years ago somebody said to me, â€œI wish I had your knowledge of computersâ€.Â I replied, â€œItâ€™s easy, just devote years of your life to programming something youâ€™re passionate about.â€Â He didnâ€™t seem interested, and fair enough, but thatâ€™s why I can charge a lot for my consulting time.
Of course I still make mistakes, although itâ€™s a lot less now than I used to, and usually I make new mistakes.
I studied math at university, and the amazing thing about studying math is that youâ€™re usually being taught things first discovered hundreds or even thousand of years ago; Newton published Principia Mathematica over 300 years ago!Â Â Computer science and object oriented programming are really only about 50 years old (and yes, Iâ€™m not talking about the difference engine), so itâ€™s only natural that as a discipline weâ€™re all still learning.Â Which, really, is great because itâ€™s a lot of fun.