Programming languages to learn

by Dr. Ben Keller

Stretch your programming skills: 4 languages you should learn this year


One of my LinkedIn contacts shares a lot of web posts, and soon after the beginning of the year he shared “10 programming languages you should learn in 2014” from Mashable.com. The list in this post is dominated by languages with C-derived syntax (including C, which is about as C-derived as you can get), and five languages that are some variant of object-oriented. There is a lot of shared knowledge there, and learning both C# and Java is kind of a waste of time.

So as a professional, what should you learn? First, why are you learning a new language (or technology stack)? If it is to get a job, don’t look at lists like this; pick the language that matches the work that you want to do. This is why Code Fellows courses, bootcamps, and accelerators are focused on a technology stack.

But what if you are a professional programmer and want to get better at programming? What can you learn that will improve your programming? I want to suggest some classes of languages that will help you develop your skills in how you approach different problems, even if you are using a different language.

This is not about building knowledge of subtle differences, like memory allocation/deallocation in C versus C++. It's about building up your understanding of programming.

As much as I hate blogs with these "N things you should" topics, here's are my 4 suggestions.


1. An assembly language

Ultimately your code is running on a CPU, and having a basic appreciation of how programs work on the hardware is useful in understanding the high-level magic you get to do with scripting languages.

You don't have to go deep here. Write a simple program with a single function/procedure, play with parameter passing and addressing modes—learn what an activation record actually is so that when your recursive function dies a gruesome death you know what is going on.

Most of us have computers with some variant of an x86 processor, but since you aren't trying to become an assembly language jockey, you might consider an emulator. My suggestion is the PDP 11. For a helpful resource, this course has some materials and has about the right scope.

The PDP 11 was a computer big enough to need a decent sized truck to move, but has all the architecture to teach you what you need to know. Instructions here look like

ADD (R2)+, R0

which requires some details to understand. You should keep in mind that this could be a rabbit hole, so make sure you learn just enough.

Get in, get out—and don't waste your time!


2. A (typed) functional language

A lot of people are already programming in a functional language called JavaScript, but other than being able to assign functions to variables and pass them as parameters, I'm talking a language of a different color. However, one of the reasons to learn them is to be a better JavaScript programmer.

A program in a functional language is basically just an expression that is evaluated to execute the program. So, this

5

is a program. Variables are like in math—we say "let x be 5" in some computation, and x keeps the value 5 throughout the computation. In Standard ML (Meta-Language), we can write

let val x = 5 in x*2 end;

to bind the value 5 to x in the evaluation of x*2 (10, in case you were wondering). Some languages have a way to define references, which can take on different values as variables do in JavaScript, but they are the exception. We can rebind the value, but this won't affect the definition of functions that use the earlier binding.

I would suggest learning a language in the ML family, but any will do. I am partial to Standard ML (and the SML of NJ implementation), but there is also OCaml and Scala, which both have more industry presence (and object-oriented features—more on that later).

One of the key ideas in these languages is that of type inference—you don't always have to specify the types of things, yet the type rules are checked and strongly enforced.

For instance, if I define the function

fun f x y = x*y;

in the command-line interpreter, the system will respond with

val f = fn : int -> int -> int

telling me that f is bound to a function that takes two integers and gives back an integer.

In this case, it used rules about the types in multiplication, but in other cases it will use information about types to infer the type of an expression (when it is not ambigous).

Types can also be polymorphic, but that is something you should learn about on your own.

Unlike with assembly language, you need to dive in to a functional language to gain some advantage. Pick something relatively hefty to build that requires you to think and ensures that you are using the language to its fullest extent. You want to work over complex recursively defined types with pattern matching, and also use modules and signatures. Build something that would push you regardless; perhaps involving a B-tree, suffix tree or trie. Or, if you are feeling really adventurous, try following Appel's Modern Compiler Implementation in ML at least until you feel comfortable traversing abstract syntax trees. You'll want to understand how we move information around as we traverse complex structures.


3. An object-oriented language

You are probably already working with a language that is object-oriented—even JavaScript can lay claim to the label. But, you want to make sure you know how to build a system of interacting objects, and not just a procedural program that moves data around in the form of objects. Pick a language that is different, and try a project that stretches you—maybe the same one you used with the functional language. (The Appel compiler book even comes in a Java edition.)

One suggestion is the language Eiffel (with resources here). It's creator, Bertrand Meyer, has a lot of interesting ideas about software development and the role that a language plays, and Eiffel was carefully designed for these purposes. It is definitely worth a look as an alternative source of good ideas.

Ultimately, you might want to try to roll your functional and OO experience together into what the Scala world calls object-functional programming. Scala is the obvious place to start for this, but OCaml also provides the opportunity (I recommend the Real World OCaml book).


4. A logic programming language

Ok, on second thought, functional programming is not that different from what we do in an imperative language like JavaScript, Ruby, Pyton, or C++. But only because logic programming is truly different.

In a logic program, we have our data, which is stated as facts of the form

eats(ben,grubs).
eats(grubs,salad).

along with rules of the form

eats(X,Z) :- eats(X,Y),eats(Y,Z).

which states transitive closure on the eats relation, and allows the conclusion that "if ben eats grubs, and grubs eat salad, then ben eats salad." Therefore, the response to the query

?eats(ben,salad)

is yes or true. With this program we can also ask things like "what eats salad?" as

?eats(X,salad)

and "what does ben eat?" as

?eats(ben,Y).

The language provides us with a lot of flexibility in exploring the data set.

At its base, the languages are simple, but the implementations allow for more complex computations.

My suggestion?

Start with Prolog using the SWI-Prolog implementation and work through the tutorials. Your goal is to get familiar with the recursion and understand how the structure of your data and rules affect the computation.

There are a lot of parallels with functional programming, but the ability to use bindings in different ways really changes things up.

So give it a go. Learning a new language in each of these classes will not only stretch your abilities as a professional programmer, it will also develop your understanding of computation and hone your understanding of the craft of programming.


Ruby on Rails Development Accelerator

In this 8-week course, you'll learn the platform that powers huge sites like AirBnB and Twitter, build your own web apps, and work in a team environment that prepares you for a full-time job in web development.

Learn More