Introduction to Programming Languages
Introduction to programming languages
What is a programming language?
Code has to be created in a way that allows for the computer to understand and process it. This is where programming languages step into the picture.
By now, you have probably seen and heard of a bunch of different programming languages. Some of the names might sound quite familiar, others rather mysterious and cryptic.
But as complicated as they might sound, all programming languages have the same purpose: they are there to make it possible for us to create programs, software and applications.
Since a computer only understands binary code consisting of only zeroes and ones, we need a tool that makes it easier for us to communicate our instructions to the computer.
So, programming languages allow us to write code that is relatively easy to write, read, and understand compared to binary code. Reading and writing instructions for a computer using only 1’s and 0’s would not only be awfully time-consuming, but the entire process would also be extremely prone to errors.
Syntax: programming language rules and structure
When it comes to reading and writing, each programming language is different as for how the code actually looks like and how it is structured.
The basic rules for writing code in a specific programming language is called the syntax. Hence, each language has its own syntax. Depending on these rules, some programming languages are generally viewed as “easier” for beginners to learn, while others might feel more cryptic for a total newbie.
Programming language paradigms
Additionally, the characteristics of each programming language in terms of how it works and how “evolved” it is is called a paradigm. For example, you can differentiate between low-level and high-level programming languages, both terms referring to programming language paradigms.
Low-level languages are closer to the binary code a computer can understand. Remember, binary code is the machine language consisting of only 1’s and 0’s.
High-level programming languages on the other hand bear no resemblance to binary code.
Therefore, high-level languages are easier to understand, especially for beginners, since they can even read a lot like English.
Why do we need programming languages?
So what do we need a programming language for if computers are so smart these days?
You could assume that we could simply tell a computer what to do by giving instructions in plain English, right?
Let’s consider a simple example with an everyday procedure: making an omelette. Yum. If you wanted to give a computer a set of instructions on how to make a delicious omelette, you could write a list of the individual steps:
- Take the eggs out the fridge
- Chop some onions and red peppers
- Whisk the eggs in a bowl, add some salt and pepper
- Turn on the stove, medium heat
- Melt a tablespoon of butter in a frying pan
- Sautee the onions and peppers
- Add the eggs to the pan
- Turn the heat on low
- Let the omelette sit for 3 minutes in the pan
- Turn off the heat and put the omelette on a plate
So these steps are pretty clear and well structured, right? If you were making an omelette for the first time, you could probably follow these steps and end up with something edible on your plate at the end.
However, the steps written in English are very ambiguous and imprecise. Following them correctly requires quite a bit of basic skills and assumptions as of how to cook, for example:
- You would know how to whisk eggs in a bowl. A computer would not know what size the bowl should be.
- You would know how much salt and pepper is enough to make the dish taste good.
- Further steps assume that there is a stove in the kitchen and that it is working in the first place.
Surely, we could keep adding additional points to our instructions to make them more detailed and specific. However, even if you put plenty of effort into it, you would still end up with something ambiguous and difficult for a computer to understand.
So, we need some other way for telling a computer exactly what it should do. The steps of a process have to be told precisely and succinctly to a computer. That is what we use programming languages for.
The bottom line here is that computers are, in fact, extremely stupid. They only do what we want them to do. And we need to give them instructions that are clear, unambiguous, and fool-proof.
We will discuss this topic in more detail in Chapter 2 of this guide when we take a closer look at the basics of Computer Science.
Why are there so many programming languages?
Each programming language is designed to serve a specific purpose. Some are used for creating desktop software, some are useful for web development, while others can be used for data analysis, for instance.
Therefore, each programming language exists to solve a problem for us who use it. Simple as that.
We will take a closer look at the different areas of web development in the next part of this chapter, when we discuss front-end vs back-end development. Each of them uses specific programming languages to achieve the desired outcome for the most diverse web projects.
For front-end development, the most important programming languages are
- CSS and
To be precise, HTML and CSS aren’t actually programming languages, but markup languages instead. We’ll get back to this topic when we discuss programming language paradigms in Chapter 3.
— Read also: HTML and CSS Courses for Beginners
For back-end development, some of the most used programming languages are
— Read also: Python Courses for Beginners
— Read also: PHP Courses for Beginners
- Each programming language is designed to serve a specific purpose
How is a computer program written?
A simple computer program is simply a text file written in a certain programming language.
Each programming language has its own rules as to how the program should be written. These rules and practices constitute the syntax of that specific language.
The actual code, that is the written instructions inside a program file, is called the source code.
To create a program, you simply write the code using a plain text editor like Brackets, Notepad++ or Sublime Text and save it on your computer.
We’ll take a closer look at text editors later this chapter under Useful tools and software for coding.
How is a computer program executed?
Once you have written your program in your text editor, you surely want to see how it works, right?
To do that, you will choose a platform for running your program depending on the programming language you are using.
Other languages can be run directly in the Command Line or in another software.
What happens when you run a program?
So when you run the program you just coded, what is really happening behind the scenes? How does the computer know what to display on your screen?
A computer only has an understanding of either “off” or “on”, either 0 or 1. So to actually run your program, it first has to translate all the code you wrote into a series of commands of ons and offs.
The computer does this in three steps:
- First, the source code is translated into assembly language.
- Then, the assembly language is translated into machine language.
- Finally, the machine language is directly executed as binary code.
To be more precise, assembly language is a very low-level language that uses words and numbers to represent binary patterns. Furthermore, it depends on the programming language whether this source code translation into assembly language is done by an interpreter or by using a compiler. An interpreter translates your computer program line by line, while a compiler translates the entire program as a whole.
After this, the programming language sends the assembly code to the computer’s assembler. It in turn converts it into the machine language that the computer can understand and execute as binary code.
- Code for programs is stored in text files
- Computers only understand binary code consisting of zeroes and ones
- Running a program requires the source code to be translated into assembly language, which is translated into machine language, which in turn is executed by the computer as binary code
When you think about it, it’s pretty awesome how something as complex as your online banking or your favourite social media can run based solely on binary code, ones and zeroes!
Feeling a bit confused? Don’t worry! We will take a closer look at binary code in Chapter 2, where you will learn more about how computers work.
And by the time you reach the end of Chapter 3, you will already have chosen your first programming language to learn.
In the next part of this chapter, you will learn about the different building blocks of websites and other web projects. Reading about the differences between front-end and backend development, you will get a better idea at what all these different programming languages can do.