What Programming Language Should I Learn?  Why Not All of Them?

by RAMGarden

You see this question asked almost daily from those who want to learn for fun, get a job, or just learn more about hacking with software and writing their own tools and scripts.

I taught myself how to code Applesoft BASIC when I was 12.  I just happened to find a guide book in our tiny elementary school library one day.  I asked the teacher during computer lab if I could try some of the examples in the book using one of the Apple IIe machines (that's all we had in our school back then).  Once I made the computer ask me for my name then say "Hello <name>", I was hooked!  I wish the valuable resources and tutorials available on the Internet now were around back then!  Today, you can go to www.w3schools.com and easily learn JavaScript, for example.

But instead of me telling you which language is best for a beginner or which is best for hacking, I'll give you my best advice from my two decades of programming for fun and profit: learn the basics that most languages have in common.

Then, learning a different language is just looking up how those pieces should be typed out (or what that language syntax is for that particular piece).  You'll also need to determine which language works best for the task, such as which ones work for the server side of a web app or which ones can run on mobile phones versus desktops natively, etc.  But that's usually figured out with a quick Internet search.

These basic parts will make up most of your code and should be what you think of when designing your program before writing any real code.  A great way to design is to write down pseudocode - code parts written in plain English that just lay out the basic statements and logic flow without any real, working code.

Then you should be able to pick from a few different languages to write the program following that pseudocode.  There's a ton of stuff I could go into for all the documents and planning and design reviews that go on with professional software engineering, but the most attention always seems to go to the pseudocode section of our documentation.

There's also things that narrow down the list of languages to use, like if you will be extending other software using an API or application programming interface.  Then you have to use whatever language is supported by that API.  The documentation for the API will tell you which language or languages can be used.

The Esri ArcGIS API supports Java, C#, VB.net, and Python, for example.

Once you learn the basic parts and the things most languages have in common, learning a new language to take on a new programming project should be easier than just learning from scratch.  You also don't have to memorize it all since you can just do quick Internet searches for something like "c# for loop syntax" or "VB.net if statement syntax" to get quick examples.

Just a few of the main basic parts are:

Variables

Store and retrieve numbers, words, whole sentences, objects, and more.  You see these in algebra class and you see them a whole lot more in programming.

Examples:

catTax = 6.8
sumTotal = 42
grandTotal = sumTotal * catTax

The Ada 95 language uses this syntax (colon before the equal sign):

catTax := 6.8;

Look up "Assignment (computer science)" to learn more: wikipedia.org/wiki/Assignment_(computer_science).

If Statements

This is also known as "if-then" or "if-then-else" or Boolean logic flow control.

These are the "Choose Your Own Adventure" novels in computer form that will make up a large portion of your code.  They are based around a Boolean expression that just comes down to TRUE or FALSE.

Things like "Is this checkbox checked?"  "Did the user click yes or no?"  "Is the total greater than some maximum number?" will be asked with these "if statements".

Note that every language has someway to mark the lines of code that will be executed if the statement is true.  Sometimes it's curly braces, sometimes it's the words "end if", and for Python it goes by the fact that the lines "inside" the if statement are indented below it.

Examples:

JavaScript, C#, Java, PHP syntax:

if (livesRemaining == 0) {
  alert("game over");
}
else {
 alert("Ok!");
}

Python syntax (I had to Google this with "python if statement"!):

if livesRemaining == 0:
  print "game over"
else:
  print "ok!"

Visual Basic .NET:

If (livesRemaining == 0) Then
  Console.Write("game over")
Else
  Console.Write ("ok!")
End If

Loops

Another feature that makes computers so great is how they can do the same or similar thing over and over again millions of times without getting bored or complaining.

You can use various types of loops to tell the computer to repeat a whole section of code with as little or as much complication as you want.  Watch out for the dreaded "infinite loop" though!  If you tell it to repeat until something is true, but that thing never becomes true, then it will get stuck looping forever until you turn off the computer or kill the program.  Sometimes apps or games can "hang" because they're waiting forever for something and that thing never happens.

There are several kinds of loops like FOR loops, WHILE loops, and FOR EACH loops.

FOR loops are normally used to loop through a known number of items in an array or list of things like numbers.

Example: loop through all the cats in my list and print them out:

FOR (i=0; i < catList.count; i++) {
  print catList[i];
}

WHILE loops are used to loop until some condition becomes false.  This is the one that can repeat forever!

Example: loop until I have 100 in my cat count:

WHILE (catCount < 100) {
  catCount = catCount + 1;
}

FOREACH loops are used to loop through all the items in a list and is only implemented in certain languages.

This is different from the FOR loop in that instead of keeping up with some index then using that inside the loop to get the item from the array or list at that index, the FOREACH statement will assign each item in the list to the given variable for you so you can read or change the item directly and type less code.

Example: print out each cat's name in a list of cat names:

FOREACH (string catName in catNameList) { 
  print catName;
}

Each time the loop goes through, it will change out the value stored in catName to the next one automatically.  Less code to write!

These are just some of the basic parts of software and by no means anywhere near the full list, as that is covered in many programming books and API help documentation.

I would recommend finding your nearest hackerspace/makerspace and asking if they have any code jams or programming classes to learn from.  These are normally free or very low cost - along the lines of a small donation to the space to help cover their costs for rent, etc.  If there aren't any of these near you, then I would say that going through any programming tutorials you can find on the Internet is always another great way to start.

And don't forget to sign up for stackoverflow.com to post and answer questions from fellow programmers who get stuck making computers do great and wonderful things!

I wish you good luck and hope you learn to bend silicon to your will.

Return to $2600 Index