Home > Learning To Code > Learn To Program 2: Ground Rules

Learn To Program 2: Ground Rules

So you’ve decided you want to learn computer programming. That’s great! Now what?

I’m not going to start teaching you to write programs in this article; instead I’m going to give pointers and topics for thought that apply equally to all beginning coders.

Self-taught or go on a course?

Until relatively recently there weren’t any official courses for software development, so most or all of the old-timers were self-taught.

Self-teaching has risks and benefits. You can work at your own pace, on topics that match your interests, in the comfort of your home, and create the applications you want to create. However, without the benefit of peer review, it is easy to develop bad programming habits, write programs that are inefficient and improperly written, and generally head in the wrong direction without knowing it. A lot of self-teaching material both on the internet and in books is dross, but as a beginner it is hard to tell the difference between a good tutorial and a bad one.

On the other hand, I have a masters degree in Computer Science and I can say that it was a complete waste of time and money. They taught nothing that wasn’t readily available and better explained in much cheaper books, much of the teaching was irrelevant to real-world programming, much of the material was out of date by modern programming standards, and worst of all, the course was presented in such a way that if I hadn’t known programming could be exciting before I started, I would have certainly lost my interest long before the end. On top of that, no employer has ever asked to see my degree – they just look at the portfolio on my web site to see that I know how to write modern code.

If you have the discipline required, I would recommend a combination of self-teaching and constantly asking questions and seeking peer review online. Sites like stackoverflow.com are great for beginning programmers; there are many experts there who are happy to take sensible questions from newbies and answer them constructively, along with an enormous library of existing questions and answers.

Why algorithms matter

An example will illustrate: suppose we have a bunch of numbers like 1, 3, 8, 23, 104, 500, 750, 1020, 1021, 1022, 3456. If asked to search through this data to find where 1022 is, a typical beginning programmer might write a program to examine each number in turn from the start, until 1022 is found. This works, but it’s a bad solution. Because the numbers are sorted in order, we can instead use something called a binary search. A binary search starts in the middle of the data and cuts it in half on each turn. For example, here the search will start with the “middle” number – 750. The number we are looking for is higher than this, and because we know all the numbers before 750 in the list are smaller, we can immediately ignore all of them. This leaves 1020, 1021, 1022 and 3456. We then pick the middle number again – there actually isn’t one here so either 1021 or 1022 will be chosen. In just 2 (or at most 3) attempts, we have found the number we want – checking each number in turn from the beginning would require 10 attempts.

To successfully teach yourself, you must practice rigorously. No amount of reading books and theory will help if you don’t sit down and code! Take any examples and tutorials you find, and alter them to see how they behave when you change the code. Satisfy your curiosity. Set yourself exercises or look for simple exercises on the web. Some programming books also contain exercises – sadly they are few and far between and mostly aimed at advanced programmers.

One very important thing when self-teaching is to check out algorithms – this means things like sorting, searching and generally re-arranging and crunching through data. An easy mistake to make as a beginning programmer is to try and work out how to do these things yourself and then come up with a slow or inefficient solution. Virtually every type of operation you may want to do already has well-established and tested algorithms (ways to do it), and usually more than one, so that you can pick the one that is most efficient for the kind of work you are doing. Many books teach the “how” of writing code but they do not teach algorithms.

Buy some books

data structures and algorithms binary-search p...

Data structures and algorithms: Binary search problem example. (Photo credit: Wikipedia)

There is a plethora of great resource material out there in both tutorial and reference format; there is also a lot of badly written hard-to-understand dross. The publisher of a book is often a good indicator as to its quality: books from O’Reilly, Wrox Press (now defunct but the books are still available) and Apress are generally of a high quality. Be wary of anything from Sams Publishing and don’t buy a For Dummies or a Learn In 21 Days-type book as they are usually thin on content and not very well-written (there will, of course, be exceptions both ways).

Be wary when choosing your book not to pick one that is too old. Languages evolve quite quickly and a book that was relevant 10 years ago may contain examples that don’t even work in today’s programming environments.

It is hard for me to recommend current beginners books, simply because the ones I read are very old and I haven’t needed to buy any beginners books for some years! However Google will help here, simply search for “best xxx beginner book” where xxx is the language you want to learn, and you will find a mountain of forum posts from experts with good recommendations. For example, Google reports that the best beginners programming book for C++ is probably Accelerated C++. Be sure to check several sources and pick whichever book gets the most recommendations from people who seem to know what they are talking about – some intuition is required here!

Amazon is a great place to pick up hard-to-find programming books, but don’t pay too much attention to the reader reviews as many of them will be beginners themselves who aren’t really qualified to say whether a particular book is good or bad.

Incidentally, if you are planning to learn Python, Ruby, JavaScript or HTML/CSS, CodeAcademy is a new and somewhat revolutionary way to learn as it provides live tutorials and exercises which can be completed directly in the web browser.


Pages: 1 2 3 4

  1. cheeseater
    March 15, 2015 at 20:20

    Thank you for this post, it is very useful.

  2. April 18, 2015 at 01:34

    To put in 0.02 cents from an old programming fart…

    I would add, be sure to have fun…try to find some small thing to start with, and ‘play’. Start with the old ‘Hello World’ in the language of your choice.
    DONT treat learning to code as ‘important’, its a hobby, enjoy it…its hard, but rewarding.

    Learning programming is just like learning anything else, its always ‘Hard’ at the start, then, IF you don’t give up, it gets easier, and when it gets easier, it gets funner, fun makes you want to do it more (called practice), doing it more makes you better, which makes it funner, recurse and before you know it your a programmer.

    Find a friend who also wants to learn and bounce little programs back and forth, always
    better to suffer with friends….and eventuallyl you’ll get good and its nice to not suffer with friends too.

    OH, and after your done and find it a little fun, look up Data Structures right away, they matter, and you really need to get those to do big stuff…and they are fun in their own right.

    All programmers look at existing code to learn stuff, I’ve been programming professionally for 35 years and I still look at others code (thats what drew me to this site btw good job Katy!) We all stand on each others shoulders, NO one is born knowing anything except how to eat poop and cry, we ALL have to learn everything we know, don’t get discouraged when you see someone who’s a ‘great’ coder, remember, they suffered too, and you’ll get there if you persist in your efforts.

    But most of all do it for fun, don’t waste your life trying to chase doing things for $$$…money will come if you just do what you enjoy.

    OH, remember, artists, good ones, make art for ‘fun’ its what they ARE artists. Programmers program for fun, because, well, its what we ARE, we do it for work, but we do it for fun, at least the good ones do.

  1. No trackbacks yet.

Share your thoughts! Note: to post source code, enclose it in [code lang=...] [/code] tags. Valid values for 'lang' are cpp, csharp, xml, javascript, php etc. To post compiler errors or other text that is best read monospaced, use 'text' as the value for lang.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: