What Is a Programming Language?
Programming languages make it easier to not only write software but write software that can run anywhere. This article explains how programming languages work and why their benefits far outweigh their drawbacks.
A programming language is a set of instructions that developers use to create software, which users can in turn deploy to interact with computers. Programming languages come in many forms. Some are more difficult to use than others. Some offer deeper control over how computers operate than others. Some result in applications that perform better than others. At their core, however, all programming languages share the common trait of making it easy to create software.
Programming languages haven’t fundamentally changed for decades, and they tend not to receive as much attention as flashier tools and resources used by developers — like microservices architectures or cloud computing, to name just a couple of trendy topics that impact software development.
Nonetheless, programming languages remain one of the foundational tools for developers. For that reason, it’s critical for developers and software engineers to understand how programming languages work, the main differences between programming languages, and what programming languages can’t and can’t do well.
Programming-lang
How Does a Programming Language Work?
Programming languages work by allowing developers to write human-readable code, which is then translated into a form that computers can execute. The translation process is usually performed by what’s known as a compiler. Most programming languages require their code to be compiled before an application written in the code can run, but some languages, which are known as interpreted languages, automatically compile and execute code on-the-fly, meaning programmers do not have to compile the code explicitly.
Programming languages also include syntax or grammar, which defines how developers must structure their code. For example, a programming language might use brackets or line breaks to identify specific functions or routines within a larger code file. Programming languages also usually include so-called reserved words, which are special terms — such as “if,” “for,” or “import” — that developers can use to tell the computer to perform predefined actions.
What Are the Benefits of a Programming Language?
Technically speaking, programming languages are not the only way to interact with a computer. It’s possible to write what’s known as machine code (also sometimes called binary code), which can be executed directly by a computer processor.
The main problem with machine code, however, is that it’s very hard for humans to read, and even harder for them to write. Programming languages solve this problem by allowing developers to write instructions for a computer using code that is easy to both read and modify.
To explain what this means in practice, consider the following code, which is written in the C programming language:
#include
int main() {
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
If you are a programmer who understands the C language, you can read this code (which happens to be for a simple program that prints the string “Hello, World!” on the command line). You can also easily modify the code if you want to change the way the program operates. For instance, if you want your program to print the string “Hi, World!!” instead of “Hello, World!” you would modify your program to look like this:
#include
int main() {
// printf() displays the string inside quotation
printf("Hi, World!");
return 0;
}
If you were a computer, however, you wouldn’t be able to read this code. Computers only understand machine code. To turn the program above into machine code, you would pass it through a compiler that is designed to compile, or “build,” C code. You’d end up with a file that looks something like this if you try to open it in a text editor:
programming-code-example
The actual file is much longer, but it consists of data like this — data no human can easily read, and that would be very difficult to write from scratch. While seasoned developers may know how to write binary code like this, it’s much easier, even for them, to generate the code with the help of a programming language such as C.
A second important benefit of programming languages is that they make it easy to write software that can run on multiple platforms, with few if any platform-specific modifications. This is important because machine code can usually only be executed by whichever specific computer processor architecture it is designed to run on. However, when you write software using a programming language, you can tell the compiler which type of computer or computers you need it to run on, and the compiler will translate it into machine code for each one. Thus, programming languages allow developers to write code once, then generate applications that can run anywhere.
What Are the Drawbacks of Programming Languages?
While each programming language has its own advantages and disadvantages, there are only two real drawbacks to using programming languages in general:
Performance: The machine code generated using programming languages and compilers is not always optimized to execute as quickly as possible. In general, the performance benefits to be gained by writing machine code by hand are far outweighed by the difficulty of that approach; nonetheless, in situations that require ultra-high performance and high efficiency, programming languages may not be the best way to write software.
Control: Programming languages usually place restrictions on the level of control that developers possess over how a computer works. Writing raw binary code provides more control over how CPU resources and memory are managed. But here again, the small advantages gained through manual machine code generation are greatly outweighed by the complexity of writing machine code by hand.
These drawbacks notwithstanding, the vast majority of software produced today is written with programming languages.
Most Popular Programming Languages
Depending on how you define “programming language,” there are anywhere between 700 and 9,000 different programming languages in existence today. However, a relatively small number of languages predominate among professional developers. Here’s a look at the 10 most popular programming languages. (For a more complete listing, check out the TIOBE Index, which tracks languages by popularity.)
1. Python
Although Python originated in the 1980s as a scripting language to help with system administration tasks, it has become popular as a general-purpose language for building applications of all types and across all major platforms. One of Python’s most compelling features is that it’s an interpreted language, so developers don’t have to compile code in a separate step. You can simply write Python code and execute it directly.
2. C
Introduced in 1972, C is one of the oldest programming languages that remains in widespread use today. When compiled, C code produces applications that offer relatively high performance. However, C lacks features, such as built-in garbage collection and exception handling, that make programming a bit more convenient.
3. Java
Java code is relatively verbose, which means that implementing an application in Java will usually require more lines of code than it would using other languages. However, Java has long been one of the most popular languages due largely to its simplicity and the ease with which programs written in Java can be run on multiple operating systems with minimal changes to the code.
4. C++
Created in 1985 as an extension of C, C++ prioritizes efficiency and performance even more than its parent language.
5. C#
C# is more or less an easier-to-use alternative to C. C# provides features such as native garbage collection, and — unlike C — it’s object-oriented, which makes it easier to structure code. The main drawbacks of C# include less portability and poorer overall performance than C, but that hasn’t stopped C# from long being one of the most popular languages.
6. Visual Basic
Designed to be extremely easy to learn, Visual Basic has long been derided as a language for non-serious programmers — or even “wimps,” to quote from one decades-old forum post on the language. Nonetheless — and despite the fact that Visual Basic code is not very efficient and offers little control over the computer — Visual Basic remains widely used, probably because it is so easy.
7. JavaScript
Developed originally to help build dynamic websites, JavaScript remains a core programming language for the web. It’s also now used as a server-side language, through frameworks like Node.js.
8. Assembly language
Assembly language isn’t a programming language per se, but rather a category of language. Code written in assembly is hard for humans to decipher, but because it represents machine-readable code, it can be executed very quickly.
9. SQL
SQL is the go-to language for querying database systems, like MySQL and Microsoft SQL.
10. Swift
If you write applications for iOS, macOS, or other Apple platforms, you’ll want to know Swift, a general-purpose language developed primarily by Apple for use across its ecosystem.
Conclusion
There are a variety of types of programming languages out there, each with various pros and cons. But no matter which type of application you want to create, or what your preferences are as a programmer, you’ll almost certainly want to create the application by selecting a programming language that is well-suited to the use case at hand.
About the Author
You May Also Like