Programming is a very useful and rewarding hobby. There are few better feelings than when someone sees you using a program you lashed together to make your life easier and says that it looks really useful. Most people have, at some point in their lives, really wanted to be able to do something on their computer or phone and been unable to. If you know a programming language, then there is often a fair chance that you can write a program to accomplish that task yourself. While there are a huge number of programming languages, many of them have a lot of similarities; this means that once you learn one language quite well, in most cases you will be able to pick up a new one far quicker.
One thing that all new programmers must come to term with is the amount of time learning a programming language takes. Although when you have become an expert you will be able to write many programs quickly, you must remember that many programs have taken whole teams of expert developers years to create. So it is important to understand that knowing a programming language or even several is not enough to write some of the more complex programs you have seen. Don’t look upon this new hobby as a way to save yourself a lot of money, as writing your own version of most of the programs that you need to pay for now will be out of your reach.
The most important thing that a new programmer needs to know is that the “Learn Programming in 24 hours” sort of books are simply not true. A more accurate title would be “Learn Programming in 10,000 hours”. If you put 24 hours or a week into learning a language you will not be creating the next Windows or a new, state of the art game. It is possible to learn to write a program in 10 minutes, and really all you need to learn a new language is your favourite search engine, but you will not be an expert. The only way to become an expert is much like learning the violin; the answer is practice, practice and practice some more.
Selecting Your First Language
Now that we have examined the limitations and handled some of the more unrealistic expectations, those of you still wanting to learn to code will be happy to know that programming is not a hard thing to start learning and will not require you to pay out huge sums of money. If you are reading this article on-line, you already have the resources to start with some languages, so let us consider what your first language ought to be.
Traditionally the first language a programming newcomer learns is either Visual Basic or Python. The first thing to understand is that these two languages are very different. The simplest difference is one of price. Python is totally free; you can start writing python now with just a text editor on your computer, though if you are on Windows, you will probably need to install it first. However Visual Basic, often abbreviated to VB, is both free and not free. On the upside, VB can be simpler for newcomers to learn because it allows you to build the interfaces (the part of the program the user will see) by dragging and dropping the different parts much like designing it in some basic art application. The version of VB newcomers learn is usually Visual Basic 6, but this is rather outdated and has been discontinued. So these days the version learned is often VB.NET which can be considerably less simple for newcomers.
VB.NET must be developed inside what we call an IDE (Integrated Development Environment); this is basically a special program you use to write other programs. They also exist for Python, but their use is totally optional. The free VB.NET IDE is called Visual Studio Express. At the time of writing, the latest version is Visual Studio Express 2010. Unfortunately, by using the free version of the IDE you are restricted with what you can do, and any programs you create cannot be commercially sold on. Regretfully, the full paid version of the IDE is not cheap, and probably not appropriate for a hobbyist, but fortunately to learn VB the free version is enough. In practice, very few commercial programs are developed in VB these days, but the Visual Studio IDE allows you to use many other languages. The familiarity you will develop by using it will also allow you to use the power of the IDE for development in many other languages. Some will argue that almost every language can be developed in a text editor and that they are by far the most flexible way in which to code. While this is technically true (and I do suggest trying development in a text editor to compare once you get a little better), I would strongly advise learning your first language with a proper IDE.
While traditionally, people learn Python or VB first and these are generally what is taught at schools, I would not suggest either of these. I am of the opinion that your first language should continue to be useful to you one it has served the purpose of helping you learn the fundamentals of programming. If I had to recommend one of these for newcomers, it would be VB.NET as often the most complex part of programming is the graphical side of things and in VB.NET this is very simple due to the drag and drop interface. These two languages are often used as introductions as they are very tolerant of mistakes, and allow you to become confident in programming principles without worrying about a lot of the more complex matters.
For those brave souls among you, I would actually suggest Java as your first language, even though it can be complex, and is therefore not a common choice for a first language. Java programs are different to most others in that they do not run on your computer. The user downloads Java, then your code runs on what is called a VM (Virtual Machine). This means that your code runs in a special place Java sets up for it – a fake copy of your computer – and handles the translation of this to the real machine for you. This means that Java programs are “cross-platform”, meaning that they will for the most part run on Windows, Mac, Linux and most other operating systems.
Java is a good language to learn, as it is very widespread and useful. Furthermore, it is very powerful, and is available for free for both hobbyists and commercial uses. However, in contrast to VB and Python, it does not tolerate mistakes and requires you to be very specific about everything. It is also an object-oriented programming language, which is a very complex issue which I will briefly try to summarise. Languages like Python and VB are what is known as procedural languages, meaning that the lines of code are run one after another, whereas Java is an object-oriented language. object-oriented development is a term thrown around a lot these days in the programming world, and while not always appropriate it is generally considered a good idea. At the most basic level, an object-oriented program is all about objects. An object is an “instantiation” of a “class”. A class is a blueprint used to describe something like a cat. The class contains both the data about the cat such as its name, age and owner as well as “methods” which are essentially actions the cat can perform, such as miaow. An instance of the class “cat” would give you a particular cat. However, this is not a Java tutorial, so if you are brave enough to experiment with Java you will come across this yourself in more detail. It is worth noting that VB.NET and Python both have support for object-oriented development, and Java has the potential to be used procedurally, but these are not the languages’ primary intended uses and are not often used. If you did not understand that comparison, don’t worry about it too much. Object orientation is hard to get your head around, but any basic Java or other object-oriented language tutorial will have you understanding everything in that paragraph.
As for the actual language you pick, it is entirely up to you. Some may choose the traditional beginner languages or be brave and experiment with Java. Some of you may already have your eye on a language or fancy one of the more specialist languages like Scheme or Prolog. Whatever your choice, the way you will learn how to program is the same.
IDEs, Yes or No?
Many of the purists say that IDEs are a bad idea, and are packed with unnecessary tools and menus that take up disk space and time to learn. While this is true, I feel that an IDE is definitely worthwhile. Many people offer free IDEs, such as Eclipse and Netbeans, for the more popular languages. There is also Visual Studio, which I mentioned previously; it is very intuitive, very powerful and it supports many languages (much as Netbeans and Eclipse do). If you chose to use Java I would suggest Netbeans, as there is a packaged version of Netbeans with the JDK (Java Development Kit). Most languages need an SDK (Software Development Kit) to work with them, and getting it installed properly and linked to the IDE is often the hardest part of the procedure. Visual Studio already comes with the development kits set up, which makes life easier, but other languages like Java and Python can be quite hard to set up properly. This is why I suggested the Netbeans + JDK bundle for those experimenting with Java, as it handles the complex set up for you, which will save you hours of suffering.
There are, in my opinion, three major advantages to using a fully featured IDE. Firstly, they are usually extensible, meaning that there are many free plug-ins that could make your life a lot easier when you get a little more advanced. Secondly, and most importantly, is the ease with which an IDE allows you to debug your code. Most IDEs let you set breakpoints in the code, which will make the program stop when it gets to that point and let you step through it line by line, so you can examine the contents of all the variables at any time. (For those of you who do not know what a variable is, I will briefly explain. A variable is a bit like a train station locker. You ask for one big enough to hold what you want to store, and if what you want to store is the right shape, it can be stored there. When you write a program, any data you want to store temporarily will be held in one of these until you are done with it.) As the old programming saying goes, if you have not found any bugs, you are not looking hard enough. Almost no non-trivial program will work first time, and trying to work out where the problem lies without the use of a debugger is a pain I would not wish on anyone. Finally, an IDE will often give you advice on how to fix issues in the code. This can be very useful for fixing bugs, and saves you having to resort to Google every other minute.
Learning the Language
Now that you have a language and an IDE, it is finally time to learn the language. This, as you may or may not be surprised to learn, is not complex at all – it is simply time consuming. To learn programming for the first time, there is no better way than exploration. Buying a book that walks you through steps will not teach you anything, as you will not understand the reasoning behind what they are doing, and people often get disheartened by the tedium.
The key to learning programming is to have a goal. Think of a task, such as a system to keep track of where you are in all the various TV shows you watch, or a system to let you look at all the books you own in a particular category, or, if you feel brave, try to replicate part of something that you use on a regular basis. My advice would be to start small, perhaps by making a sequence of message boxes that insults the user or a really simple calculator. It is important when you first start that your goals are interesting, challenging and entertaining. If you try to make really boring programs you will quickly get disheartened, so try to inject some comedy into your program. The calculator is a very good introductory program, but after you get the general idea it is important to set quite ambitious goals, as if you keep doing simple things you will never learn anything new. It is important to try to incorporate some of the knowledge you have gained from previous work. One of the reasons most books fail to teach programming well is that they use small examples for each thing they introduce, whereas what you really need to do is plan the task without considering what you will need to accomplish it. This means you will be able to code some of it using what you already know, but most importantly, you will not know how to code some of it. The best way to learn is to learn by doing. Go for a full program that does a task you wanted to do on a computer in the past, work on it, and when you are finished you will have learned a lot and you will have a useful (or at least entertaining) program which is far better than some toy program demonstrating lists.
I have said that you learn by choosing to do projects where you are unable to do certain sections, thus requiring you to learn, but how do you go about finding out how to do them? It’s simple, and most likely the way you found this article. Go to your favourite search engine (like Google) and search for what you want to do – for example, search “drop down list Java” to find some examples of using drop down lists in Java. Because you will need it for another task, and not just to re-do the same thing the examples did, you will have to play with the examples you find and try to get them to do what you want. Just search each bit you need, and before long you will find that most of the basics are as natural as waking up in the morning, and you did it all without spending a small fortune on books, without getting bored and hopefully while being entertained. To this day, if I am bored, I sometimes break out one of my very first programs which is just a list of boxes and a random number generator. It is your task to try to fill all the boxes such that the numbers the random number generator gives you are in ascending order – if you don’t leave space and can’t fit a number in a hole then you lose and must start again. It’s a simple program, but it took a lot of work when I first made it and I learned a lot from the experience.
Once you have a few decent sized programs under your belt, you will find that you know the language well. You will also find that it is rare, no matter how well you know a language, to be able to write a program without resorting to Google at least once just to check something. So with that in mind, it could be argued that you learned the language without ever actually trying to learn it. Clearly there are standards and good practices that you may not pick up on your own, but as you see more examples and read the comments you will find you adopt your own standards rather rapidly.
Learning Another Language
Once you have learned one language, whatever it may be, the most valuable thing you will have learned is all the key words for searches. When you want to do something in a new language, you need only search what you want to do and the language name. However, by now you will know the names used to refer to what you want to do, allowing your searches to be more effective and yield examples and answers much more quickly. As the fundamentals of programming are mostly the same, regardless of the language you use, you will hopefully be able to guess at the meaning of most of the code much more effectively once you locate an example, allowing you to pick up most of the language very quickly indeed.
If you take nothing else away from this article, remember that the best way to learn a skill is practice, practice and practice some more, so don’t expect to become an expert overnight. Remember that programming is not something that can be learned overnight, and that to become a passable expert you probably need to spend at least 10,000 hours programming, so you will need to find ways to remain motivated. Don’t think of it as learning to program – rather, just start programming, and before you know it you will be an expert. Programming is a skill, and while it is quite simple once you have the feel of it, it can be quite daunting to see your little calculator that took you a week and then to consider a modern game like “Batman: Arkham City” and realise how far you have to go.
Programming is easy when you know how, but is not a trivial thing to learn, so it is important that you set yourself tasks. These tasks should preferably be interesting and, better yet, entertaining, as these will be what keeps you programming and learning more and more until, one day, you wake up and realise that you know quite a lot. You are your own best tutor and the key is simply to jump in and get started.