Tuesday, July 26, 2005

Programming advice from John Carmack

I emailed John Carmack (technical director/co-owner of Id software) and asked him for some advice for a beginner programmer (read: me), and he gave a very thorough, thoughtful and helpful response, and I feel that other people should hear what he has to say.

So, without further ado, the email from JC;

When I started, computers couldn't do much more than simple arithmetic and if statements -- my first computer had 4k of memory. How I learned probably isn't very relevant, because there are so much better resources available today.

Don't expect it to be easy, you will have to work at it. Get a few more books from the library that cover beginning programming to go with the ones you have -- sometimes a different author explaining the same thing will help a concept click. Go through all of them at least twice. Try to do every problem and exercise, don't just read them and think you get it. Lots of people that want to program will talk a lot about programming, but not actually write that many programs. You should write hundreds of programs

If you want to get good at something you need to focus on it, which means choosing to exclude some other things from your life. Keep a little journal of what you are working on each day, you may find that you aren't applying yourself all that hard. Learn something new every single day.

Avoid "cookbook programming", where you copy and paste bits of code that you have found to make something work. Make sure you fully understand what everything it actually doing, and that you are comfortable applying the techniques in other situations.

It isn't a bad idea to start in an environment that give you more exciting feedback, like visual basic, flash, or javascript, but you should try and "find the excitement" in even the most simple data processing tasks. There are layers and layers of things going on in just compiling and running the simplest program that are worth investigating.

Pay attention in school to the math classes. It is more important to be able to do basic algebra and trigonometry extremely well than to sort of get by in higher math classes. You should be able to ace all the tests and teach other people if you truly have a complete understanding of the subjects.

John Carmack

4 Comments:

Blogger Gibson Martin said...

His bias towards understanding trig comes from his background in graphics.
For graphics though, trigs value cannot really be overstated.
Know the implications of cross products of matrices. Know angle addition formula.
DO NOT BLINDLY COPY 3D TRANSFORMS CODE LIKE EVERYONE ELSE. It will bite you in the ass. Pretend the answer has never been found and you're the 1500's physicist on the edge of a breakthrough. Try to invent the solution.

If you have calculus under your belt you can derive a lot of the formulas used strictly algebraically within programming, and the intuition goes a long way.
However if you don't, don't worry about it too much.

I am also a beginner, and my addition to his advice is to stay away from libraries. Implement every single algo yourself. Even asinine stuff like parsing an image file into memory, sorting, or vectorized math functions. Libraries are a crutch, and reading documentation is a nightmare for beginners. Over time you will realize you've ended up making your own sets of libraries.

ALSO. an Apple2 emulator is a lot of fun. I highly recommend.

3:17 PM  
Blogger Alan De Smet said...

There is a lot of value to implementing things yourself. It's incredibly educational and it's often a lot of fun. It's hard to overemphasize that. As Carmack says, write hundreds of programs! And attacking fun little problems is an awesome place to start.

Libraries are awesome, and the basis for nearly every large scale software project. Rolling your own is super educational, so totally do that, especially if it sounds fun. But it can occupy all of your time. When you want to do larger projects, using a widely used library with a good history behind it will give you more time to work on the higher level problems and less time figuring out why some dull but incredibly irritating to track down edge case is screwing you over. Also, using existing libraries teaches a lot about API design, both good and bad.

5:18 PM  
Blogger Alan De Smet said...

Oops, just noticed the date on the original post. I'm guessing you don't quite need the advice anymore. :-) Perhaps it will be of use to other people.

5:20 PM  
Blogger Gibson Martin said...

i seem to also have not noticed the date...

1:13 AM  

Post a Comment

<< Home