Programming – the stuff you can’t learn from books

Posted by on Jul 03 2009, in Programming - the stuff you can’t learn from books, zegarkus

This is old post that was originally found here:


Programming is something you learn by doing. And doing over it again. And over yet again. It is not something you can master in 21 days. Which brings me to my point – its can be very difficult to learn even if you have good books to teach you. Now this is not to say learning from examples is bad. I’ve pretty much self taught everything I know about programming through examples. The problem is that examples are the end result – you do not see the process it took to get there.

When I started to teach myself python programming, I saw immediately why learning programming via example is somewhat flawed. The example shown in the book is usually a perfect working model – but its quite deceptive; it doesn’t show the numerious revisions and blood sweat and tears the programmer has put into the code. Large chunks of code may have beend added, substracted, tweak, abused and optimised during for the final result.

When learning python, I decided to write a little game for battle ship with a command line script. A very simple script got more and more complex as I continued to build it. This is the stuff they seldom show you computer books. Whenever I made a revision I saved the script with a number after it. Here is an example of this process with the total lines of code* after each effort:

  • lines of code: 88
  • lines of code: 175
  • lines of code: 137
  • lines of code: 149
  • lines of code: 184
  • lines of code: 177
  • lines of code: 219
  • lines of code: 187
  • lines of code: 242
  • lines of code: 237
  • lines of code: 235
  • lines of code: 250
  • lines of code: 249
  • lines of code: 266
  • lines of code: 277
  • lines of code: 286
  • lines of code: 276
  • lines of code: 289
  • lines of code: 295
  • lines of code: 308
  • lines of code: 334
  • lines of code: 363
  • lines of code: 353
  • lines of code: 362
  • lines of code: 354

*I include all comments as lines of code here – though the lines might not do any actual work they keep me sane 🙂

As you can see the code grows, shrinks and grow again several times. You can examine the code by clicking on the hyperlinked filename. Don’t expect this to be world class code – hey I was learning python during this process! If a book (god forbid!) were to use my final script as an example, probably would not show evolutionary process of how I got there. This is just as important as the final product, you learn most of the real life stuff through this learning curve!