Why are there so many programming languages?

Updated: 12/31/2022 by Computer Hope
Computer programming

Over 250 programming languages exist. Some are widely-used in the business world, like C++, Java, JavaScript, Ruby, and Python. Others are primarily academic, such as Lisp. Still, others are obscure and esoteric. You might be asking "why are there so many programming languages?"

That's a lot like asking "Why are there so many fields of mathematics? We have algebra. Why do we need geometry, calculus, and fluid mechanics?" Every programming language aims to solve a particular problem. More than one language might be able to solve the same problem, but each will approach it differently.

Here are some major differences in programming languages.

Legibility and maintainability

Some languages are easier for a human being to read, which makes it easier for one programmer to collaborate on another programmer's code. Python, for example, has a reputation for being easy to read. It enforces strict indentation of lines to define its code blocks, which makes it easy to glance at a program and figure out its structure. Other languages allow indentation as well, but as a stylistic choice, not as a requirement.

In contrast, Perl is a language that allows the programmer to write the same program in many different ways. Still, the program's purpose might not be immediately clear to another reader. Such a program may be convenient to write, but difficult for someone else to understand and edit.

Performance

Some languages are interpreted, and some are compiled. A compiled program must be processed by a preprocessor, compiler, and linker before it can be executed by the computer. This specialized intermediate software performs lexical analysis, translating the program into machine language. It may also optimize the resulting instructions, looking for clever ways to make the program run faster.

Compiled programs usually perform better than interpreted programs. For instance, C, C++, and Objective-C are languages that compile to very fast machine code. Video games and system software are often written in these languages, to squeeze every bit of performance out of the CPU (central processing unit).

On the other hand, interpreted-language programs are run by software called an interpreter, which executes the program's instructions without first compiling them to machine code. Although the interpreter sometimes parses the program to an intermediate language, resulting in some optimization, the performance is never as fast as compiled machine code.

One major benefit of interpreted languages is their potential for interactive development. Because the entire program does not need to be compiled before it can be executed, the code can run interactively. You are familiar with this if you've ever used your operating system's command line: you enter a command and see the results. Such an interface is called a REPL (read-eval-print loop). A REPL permits you to execute commands (or blocks of commands) individually, and view the results. Lisp, Perl, Python, NodeJS, Ruby, and JavaScript are examples of interpreted languages that can run in a REPL.

Interactive command interfaces, such as the Windows Command Prompt and bash, also qualify as interpreted languages. Programs in these "languages" are called batch files, or shell scripts.

Specific use cases

Often, languages are especially good at writing specific types of programs. For instance, NodeJS is designed to write single-threaded applications for the web. Its non-blocking file I/O permits programs to continue operating ("not be blocked") while they wait for required data to transmit.

Another example is the R programming language, which specializes in statistical analysis. Programs written in R benefit from built-in analytical tests and models, and tools to efficiently manipulate massive quantities of data.

Ease of prototyping

Some languages allow for rapid prototyping: the programmer can "start writing," and build component upon component until the program is fully formed.

For example, the website Reddit was originally written in Lisp. After Reddit launched, the entire site was rewritten in Python for many reasons, both technical, and logistical. Although refactoring all the code was a major undertaking, the site's owners expressed no regrets.

Available libraries

Usually, when you start a new programming project, you don't want to re-invent the wheel. That is, you don't want to write functions for common tasks like calculating a square root, or finding the first occurrence of a character in a string. For this reason, nearly every programming language provides a set of standard libraries of common functions. Programmers may prefer a language because of the libraries it provides.

For instance, the C standard libraries provide highly performant functions for many low-level system operations. Perl provides many robust libraries, and also the CPAN (Comprehensive Perl Archive Network) repository of modules to be downloaded and used in your program. Python provides a wide array of built-in functions and modules for almost everything under the sun. Clojure, a Lisp-like language that runs on the JVM (Java virtual machine), benefits from its ability to run code from the extensive existing libraries of Java objects and methods.

Security

Not all languages lend themselves to writing safe code. The C programming language, for example, is notorious for having features (or lack thereof) that lead to devastating vulnerabilities such as null pointer dereferencing. Other languages try to address these concerns with stricter rules.

For instance, some languages place restrictions on what operations can be performed on various types of data. The strictest of these languages are sometimes called "strongly typed," and they can offer peace of mind to programmers who prioritize security and stability in software development. Examples of strongly-typed languages include Rust, Nim, Ocaml, and Haskell.

Languages may also place limits on "mutability," the ability of a data object to change state. Instead of objects whose values are overwritten, these languages favor "immutable" objects: values in memory that cannot be changed without explicit exception. Immutable objects have attracted interest as multi-core CPUs have become widespread, because of their tendency to promote "thread safety." In a thread-safe program, more than one processor may operate on one set of data with a greatly-reduced risk of error. Languages that prioritize immutable objects include Rust and Clojure.

Community support

When programming in a new language, it helps to access an active, passionate community of developers who actively use and contribute to each other's work. Before choosing a programming language, find more about that language's community. Some languages have an exciting, dynamic, vibrant user base you might want to be part of and other languages may have little or no community.

Expressiveness

When writing a program, the programmer's thoughts and problem-solving abilities are "speaking" through that language. As a result, programmers tend to prefer languages where they are comfortable expressing themselves. What makes a language and programmer work well together is hard to define, however. Ultimately, the only way to know which language you are comfortable with is to use different languages for different projects and compare them for yourself.