Parts in this series

Part 5: Beginner programming, dynamically typed

This is part 5 in my series on the order to study topics related to programming. This series aims to provide a gentle path to follow as you explore this fascinating field.

In the first four parts, I covered Markdown, HTML, and SQL and a short interlude on bits and bytes. These are good stepping stones to become familiar with how different syntaxes have specific effects. Now you’re ready to start with a “real” programming language.

By “real”, I actually mean “Turing complete”. A Turing complete programming language is one that is powerful enough to simulate any other other programming language. That definition is almost completely false, but it’s sufficient for now. “Turing complete” is actually a mathematical term with a formal definition that we don’t need to get into here.

There are literally thousands of programming languages, but only a handful of them are popular. New ones are invented every day, and older ones go out of style as they age. This can seem daunting at first because learning just one programming language is hard enough! How do you know you’re picking the right one?

The good news is that the syntax of a language is not as hard to learn as the underlying concepts that are programming. Once you’ve become proficient in the core concepts in one language, they will translate to another. If you learn the basic idioms of several languages, you’ll find that you can interact with other languages more easily.

You should try multiple languages, as each of them appeals to a different audience. If you don’t like the first one you try, don’t think, “I’m not cut out for programming”. It is healthier to say, “I don’t like this language”. It’s fine to not like a language. We all have our favourites, and many people make entire careers out of just one of them.

There are many different types of programming languages, but they tend to fall into overlapping categories. Some languages are “dynamically typed”, while others are “statically typed”. Some are called “functional”, while others are called “object-oriented” or “structured”. Most of them fall into more than one of these categories.

I recommend you start with one of the “dynamically typed” languages. There are several popular languages in this category, and I think you should study the basics of at least two of them.

Why a dynamic language

From the last post, you understood that everything in a computer, from numbers to colours to video, is somehow represented in binary numbers. You also learned that binary is grouped into bytes for easier reasoning.

There are a variety of “levels” of programming languages. The lowest levels are understood only by the computer and hardware itself; people aren’t meant to understand them. The lowest languages that programmers know require they think about exactly where all the bits and bytes live on the CPU and in memory.

The next level, statically typed languages, are easier for humans to reason about. However, they require you to think explicitly about the “types” in the language. Types, in programming, define the way bits and bytes are mapped to comprehensible constructs such as various sizes integer and decimal numbers, some form for textual data and yes/no (Boolean) values. Statically typed languages demand that you choose the right types for your values up front and that you always know what they are.

Dynamically typed languages are much more relaxed about these conditions. Often they can translate between types automatically and behave more closely to the way humans think about them.

There are even higher level languages, usually for more specific applications. SQL, which you’ve already studied, might be considered one such language.

There are a few tasks that can only reasonably be done at the lower levels, usually related to directly manipulating hardware, managing an operating system, or the speed of execution. However, most work can be done in the easier to use and learn dynamic languages.

Which language should I learn first?

This is a very subjective question, and you’ll get different advice from different people. It can be especially confusing and even demotivating if you have multiple mentors loudly insisting you focus on their preference.

Instead, I recommend that you spread your learning through multiple languages. Concepts people get stuck on in one language are simpler in another language. Too many people give up when they hit these frustrations. Instead, I suggest starting over in a new language, then switch between them.

Even though this is approach is not commonly recommended, there are a couple reasons I believe in this strategy:

  • It encourages you to go back over stuff you’ve already learned and look at it in a new way. For example, the concept of “variables” in two different languages is usually similar, but they might subtly emphasize different ways of thinking about them.
  • It gives you earlier exposure to aspects of a language that are due to limitations of the computer vs limitations of the language design.
  • You get a new direction to pursue when things get frustrating. This provides extra motivation and reduces thoughts of blaming yourself.

I recommend Python and JavaScript for your first two languages, although not necessarily in that order. There are a few reasons to choose one over the other. I’ll go into the differences below; hopefully you’ll feel yourself gravitating towards one. If it seems like neither of them are working, I list a couple other options at the end of this section.

Python is an easier language to learn. It looks more like English, with less punctuation in odd places. It usually has more useful error messages. Python is very popular for professional development (it’s my own favourite), but it was originally designed for educational use.

JavaScript can be easier to set up. You can work with JavaScript right from the browser and many JavaScript education sites allow you to test your code without leaving the browser. In contrast, Python require that you download and install the Python software on your computer if it isn’t already there.

High quality Python instructional material is easier to find. It is very popular in computer science education. In contrast, many JavaScript tutorials assume you already know the basic concepts. That’s not to say there aren’t good new-to-programming tutorials based on JavaScript; you may just have to try a few before you find one that makes sense.

JavaScript was designed for and is still highly oriented towards web programming. If you dream of writing interactive websites or mobile apps, the examples used in JavaScript coding may seem more comfortable to you. You need a solid understanding of HTML to understand such examples, though. Spend some time learning more about HTML before you start with this kind of JavaScript tutorial.

Python might be more interesting if you have an interest in data science or statistical analysis, one of it’s most popular uses. It is also very popular for so-called “systems programming”, although if you are interested in that kind of work, you probably already know about Python!

If you are interested in game development, I’m afraid neither is primarily used for that purpose. However, you can find tutorials for either that use examples from gaming if it interests you. If you ultimately want to make web-based games, choose JavaScript. If you are more interested in console gaming, start with Python as it is an easier stepping stone to languages that are traditionally used for it.

As a language, JavaScript has evolved a lot in the last few years. This is a drawback for new coders, because the educational material hasn’t necessarily kept up. If you use multiple tutorials, you may find they have very different syntaxes depending what version they were written for. You may find confusing references to ECMAScript, the same language with a different name. ECMAScript versions are sometimes named after the name they were standardized, such as “ES2015” and “ES2017”, but can also be named by version numbers like “ES6” and “ES7”. As a result, it can be really hard to figure out which kind of JavaScript you are learning.

To a lesser extent, Python also suffers from this problem. Python 3, when it was released 10 years ago, was a huge change to the language. There are still a few instructional references hanging around on Python 2 that you should avoid. Python 3 is simpler, easier to learn, and more fun. There is plenty of new educational material available.

Don’t obsess over this question. Remember, I encourage you to switch back and forth between the two and others anyway. If you are still uncertain, I recommend trying Python first.

If you’ve tried both languages and don’t like either one, there are other options. In this case, I specifically recommend Ruby, as it’s quite different from both Python and JavaScript. I actually don’t enjoy coding in the language myself, but there are plenty of people who don’t think like me. Many of them love Ruby!

Alternatively, if you have a math or statistics background, try R.

How to find resources

Except JavaScript, all of these languages are hard to search for because they’re common English words (R is particularly bad!) I suggest searching for “learning to program using ”.

Beware: searching for “ tutorial” or “how to learn ” will likely not yield useful results. Most of those results assume you already know how to program in another language before learning this one.

How much should I learn?

As with human languages, becoming fluent in a programming language can take years of effort. But nobody needs to become fluent. At least you don’t also need to learn accents and pronunciation!

For the purposes of this article, you only need to learn the very basics before we move on. Become comfortable in the following concepts in at least one (preferably two) languages before you move on:

  • How to do basic math
  • Working with strings (programming term for textual data)
  • How to set, modify, and read variable values
  • Boolean logic
  • Conditional statements (In almost all languages, these are if statements)
  • Loops

That should be sufficient for now. You may also learn about functions, but if you start learning about classes and objects you can take a break and move on to part 6.

How long is this going to take?

This is, by no means, a trivial project. There are many new ideas to assimilate, and depending on the quality of the learning resources, they may be thrown at you in an unintelligible order.

Switching back and forth between languages will slow you down. I think the slower, deeper approach makes learning easier and more enjoyable for most people. However, if you’d prefer to focus more deeply on a single language, do it. That’s actually how I learned and it worked well for me.

I expect you can read through lessons for the above topics and implement the examples in those lessons in a couple weeks. However, that is not sufficient to truly understand how to code. In order to really internalize the concepts, start thinking about how to adapt your code to your own ideas. This can start really simple; if the program tells you how to display “Hello World” on the screen, try making it say “Hello, my friend” instead. If it tells you to repeat a task ten times, also try 100 times. I expect you’ll spend a month or two to get to know these aspects of the languages.

As you advance, do make your explorations more divergent from the lesson materials. The amazing thing about programming is that experimenting has absolutely no cost. If you mess up, read the error message and try again. There are no resources consumed or wasted, as is the case if you mess up while learning, say, woodworking or painting. There is no way to fail!

I promise you cannot blow up your computer using these programming languages. In fact, I dare you to try. Finding all the ways to do things wrong is super educational, not to mention a lot of fun!