2013: Advent Computing: Programs without compilation

by on December 8, 2013

Both assembled and compiled languages require some form of translation to convert them from a language a human programmer can (more-or-less) understand to the machine language the computer can understand. But what about if we could skip that step? That’s where interpreted languages come in.

The compiler or assembler is a computer program that is capable of understanding both the machine language and the human readable language, so if there’s a computer program that can convert one to the other, there’s in principle no reason why it can’t do just that on the fly. Rather than taking one list of numbers (the human-readable characters of the program being compiled) and giving a new list of numbers (the computer-readable machine language instructions) so you can feed the new list of numbers back into your computer, it simply feeds the instructions straight into the computer.

The disadvantage of interpreted languages is that they tend to be slower than compiled languages. With a compiled language, the interpretation happens once, then whenever you want to run your program you just run the ready-to-go machine language version. An interpreted language program needs to be interpreted on-the-fly every time.

In principle, there’s no real difference between an interpreted language and a compiled language. There’s nothing stopping something written in a language we call an “interpreted language” from being compiled into machine language ready to run, and there’s nothing that means something we call a “compiled language” from being interpreted on the fly. In reality, however, the languages we use for each were designed for that use; compiling an interpreted language wouldn’t get you much of a speed increase, while interpreting a compiled language program is likely to be exceedingly slow.

Interpreted languages, despite their relative slowness when you run them, are popular because they tend to be faster to use for producing programs. Fundamentally, that has very little to do with the language itself. Being able to run a program as soon as you have written it, without needing to go through a compilation step, means it can be much quicker to put your new program to use. One of the ways this trade-off is explained is that the time of a programmer is expensive, while making a program run quicker is just a case of buying a (relatively cheap) faster computer.

In particular, when you’re first learning to program, an interpreted language means you can experiment a lot more easily. Most interpreted languages come with an interactive mode that works like a glorified calculator. This is sometimes called a “REPL”, which stands for “read–evaluate–print loop”, meaning the interactive mode will read whatever you type in, interpret it as if it were part of a program, print the result, then loop around to start again.

For that reason, amongst several others, if you want to learn to program and have no other reason to pick a specific programming language, I’d rcommend Python. I don’t have any book/course/whatever I can recommend from personal experience, but I’ve heard good things about Learn Python the Hard Way, which you can buy ebook or dead tree versions of, or read for free online.

Leave a Reply