W1082 Programming Language Survey

From Coder Merlin
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

There are hundreds of programming languages, each with their own set of pros and cons. There are endless ways to categorize or otherwise group languages together, and one such way is by differentiating between compiled and interpreted languages.

Compiled Languages[edit]

A compiled language is a language which must be run through a compiler in order to generate machine code that the computer can then execute. The compiler takes the source code of the program then runs it through various stages and ultimately converts the program from the source language, such as C or Swift, into a format the computer can directly understand, i.e. machine code.

The biggest advantages of a compiled programming language are performance and the ability to run the program with less requirements. Because all of the translation work from the source code to machine code is done up front, the computer can directly execute the resulting program with very few intermediary steps. Once a program is compiled, it can also be run on any architecture for which the code was compiled without requiring the system to have a compiler handy. However, it is worth mentioning that compiled programs still often have other requirements, such as shared libraries, that must be present on the system in order to run. Programs can also be statically compiled, in which case everything the program needs to run is bundled into a single file along with the machine code.

The biggest disadvantages of a compiled language is longer development time and less portability. Although programs built with compiled languages can generally run faster than their interpreted counterparts, it often takes more time to develop the code itself. This basically boils down to the fact that the program must be compiled before it can be tested, which can take several hours for large programs. Debugging a compiled program can also be more difficult, although tools such as lldb exist to make this process easier. Lastly, a compiled executable can only run on the architecture for which it was designed. A program compiled for x86 Linux will only work on x86 Linux, attempting to run that executable on a Windows computer will fail (unless a compatibility/translation layer exists to translate instructions from another system to the current one).

Interpreted Languages[edit]

An interpreted language, as its name suggests, is a language that must be interpreted before it can be run. Interpreted languages generally require there to be an interpreter available on the system in order to be run, and are interpreted each time the program is run. Interpreted languages are also usually higher-level languages such as Python, JavaScript, and PHP.

The biggest advantages of an interpreted language is portability and speed of development. An interpreted program can run on any system with a compatible interpreter, which means that a Python script written on Linux will run properly on Windows, assuming that a Python interpreter is installed on both. Development can also be faster with interpreted languages because they don't need to be compiled in their entirety in order to test them. Additionally, interpreted languages require the developers to put less thought into memory management, and the language can do more of the work during execution (some higher-level compiled languages such as Swift and Rust can also handle most of the memory management, but do so in a different way).

The biggest disadvantage is slower performance when the program is being run. An interpreted language must be interpreted each time its run, unlike a compiled language which only needs to be compiled once. This can result in a longer wait for the program to start after executing it as well as lower performance throughout the duration of the program. This is one of the reasons that C and other low-level languages continue to be popular for video games and other situations in which high-performance is important.

Bytecode[edit]

There is a third option that's less heard of but equally viable; bytecode. A bytecode language requires compilation similar to a compiled language, but retains the portability of an interpreted language. The program needs to be compiled once, but instead of being translated to machine code, the program is compiled to bytecode. This bytecode can then be run on any system with the correct runtime available (e.g. the JVM in the case of Java). These languages can also offer the memory management features from an interpreted language, which can help speed up development.

References[edit]