In a continuation of the idea behind my “What Programming Language Should I Learn” post, people always ask how to learn a language. These are people who have not learned a programming language yet, so we have to start at the beginning. The following is some simple advice on how to get started. The idea is that if you learn these basics, you can then translate the general idea to the next programming language that you need to learn.
Duh. This is so obvious to most programmers that it should not be mentioned. However, new programmers may want to get to the “meat” of the language before learning the basics. So, learn what the datatypes are (if there are any), how to declare variables and if-else statements. There may be more syntactic sugar like case or choose statements, but they can wait until you really need them.
Iteration And Looping
Loops are important in various situations beyond a simple “Hello World” program. Most languages have a few different types of loops. For loops are typically “indexed” and while loops are generally “conditional”. By “indexed”, I mean that you are going to loop based on an index or number, i.e. for 10 iterations. By “conditional”, I mean that while some condition is try, i.e. while working == true. You can use for and while loops in various ways, so do not take this as some cardinal rule. There are likely other ways to loop as well, but again they are normally just syntactic sugar.
Back in the day we called these data structures, but now they have the grander term collections. Some basic collections are arrays, lists, sets and maps. These concepts can be a little confusing for new programmers, but learning the difference between these four collections is highly important. Also, once you get past really simple programs, barely anything useful can be created without collections.
Files And I/O Handling
In many cases, you will need to handle files or even basic input and output. For example, in most languages, there is a simple way to read and write from the command line. That is simple I/O, but those same concepts can be used to learn about more interesting I/O techniques. A good (and bad) example of the various I/O techniques can be found in Java’s IO package. It is a good example as it shows there are many ways to handle I/O. It is a bad example because they include various abstractions for each method that it all seems a bit chaotic.
If you want data storage, you are typically going to use a database. In many cases, you can get by using file based storage, but if you want simple querying databases are immensely useful. Because of this, most languages have some way of getting access to the database. Some examples are ODBC on Windows, JDBC in Java and DBI for Perl. Typically, database access is a fairly small piece of the language so it should not take long to understand the basics.
Threads And Concurrency
This may be a rougher subject for some as it gets into a difficult topic. The main reason for learning about threads or concurrency is to be able to understand how much of the computing world works. On your PC, multiple threads are running in the background. Your web browser is running multiple threads in order to allow the user to view multiple sites or even just to increase the speed of downloads. Threads are everywhere, so hopefully your chosen language has good support for them.
Other than the basic concepts that I have described so far, there are a few other things that are important. First, you should likely target object-oriented languages or principles in your code. Many languages that were not object oriented in the beginning are getting or already have new object oriented features. Perl is a good example of this. Whenever you need to learn a good language, reference material is critical. You can go to your favorite bookstore to find a good book, or you can find very good reference material on the internet. Many reference books are being converted to free pdf downloads.
There are other programming topics that you will run into fairly quickly (or I will be vilified for not mentioning them). Networking, sockets or basic http and url connections will probably be used at some point. Again, this topic could be something you learn in order to understand more about how things work. GUI or client application development is something I have tried to avoid as it is generally specific to one operating system. However, most languages can be run from the command line to start. Most languages have a way to hook into a web server or an application server as well, so your GUI could just be a web page. GUIs will not be going away for quite some time, so it is not a bad thing to learn. Lastly and more likely not to be seen for quite some time is bit manipulation. Some people never see this in there career, but “bit twiddling” does have its uses. If you are in graphics or game programming, you will probably have to play with bits. Device drivers are another bit heavy arena. I would highly recommend avoiding bit manipulation until you have really learned everything else in this post. It is the last thing you will need, unless you are training for a job in graphics.
One last piece of advice. When you are learning a new language, start with a standard project that is not overly aggressive but allows you to hit many of the topics covered here. Many people use a simple address book as their first project. The reasoning is simple, you have a list of people and addresses and you need to store data. You could easily cover all 6 of the major topics mentioned. You could also build a client GUI or a web GUI or both if you are feeling adventurous.
The main thing to remember is to have fun. Programming can be immensely frustrating when it does not work, but it is also very rewarding when things do work.