What is a program?

Reading time5 min

In brief

Article summary

In this article, we explain what a program is, and introduce the notion of programming languages and their specificities.

Main takeaways

  • A program is a series of instructions in a given syntax that realize an algorithm.

  • The programming language constrains the syntax of the program.

  • Choosing a programming language for a project depends on many factor, as each language has its specificities.

  • Some programming languages are interpreted, and some are compiled, to be able to be executed by the machine.

Article contents

1 — Programs and programming languages

A program is a translation of an algorithm in a particular language, that enforces some strict syntactic rules. A program that has a valid syntax according to the rules should be understandable by a computer. Therefore, the computer will be able to realize the computations described by the program (which describes the algorithm).

The syntax is defined by the programming language. There are hundreds of programming languages in the wild, each with its own specificities. During your scholarship, you will learn a few of them, which are pertinent for the associated tasks. In particular, you will learn:

  • Python – This is a great language for quickly writing a program. It has a very simple syntax, which makes it easy to learn. In addition, it has a large community, and a lot of libraries to realize standard operations. In particular, it has become the main language for everything related to artificial intelligence. This language will be the language of choice for this semester.

  • Java – Java is a convenient language for writing complex applications, due to its strict typing and object-oriented nature. It is very present in industry, and often required to be known by many companies when hiring. You will study it during the next semester.

  • HTML/PHP/CSS – These are essential languages for writing Web-based applications. You will learn about them later in your scholarship.

  • SQL – This language allows you to address a database, to add entries or perform request on it. Again, you will study it later when you learn about databases.

Depending on your cursus, you will also learn about other languages, that are adapted to the specificities of your formation.

To choose a programming language for a project, there are many criteria. Here are some of the main ones:

  • Adaptedness – Is the language adapted to your project?

  • Performance – Is the language performant for your project?

  • Libraries – Does the language offer some libraries adapted to your project?

  • Easiness – Is the language easy to learn?

  • Community – Is there an active community on the language?

  • Long-term – Will that language only be useful for this project, or will you acquire long-term skills?

  • Context – Are you working in a company that already has some codes in a particular language?

  • Demand – Does knowing that language increase the quality of my resumee?

There are obviously many other criteria.

Also, you can find a lot of pages online that rank languages. Here is an example, another one, and again another one. Obviously, depending on who writes the article and their criteria, the ranking will change. However, checking these kinds of rankings is interesting to evaluate the market demand for a language.

Information

The choice of a language has always be a dividing question among computer scientists. However, with the recent rise of artificial intelligence-based tools such as GitHub Copilot or ChatGPT, it has become pretty easy to translate a program from a language to the other.

Therefore, what is important is to master a programming language, and to understand its strengths and limitations. Transitioning to a new language will then be a lot easier, when needed.

2 — From source code to programs

Machines speak their own (abstruse) language, which is difficult to manipulate as a developer. As humans, we speak natural languages that are too complex for machines, at least for now. Programming languages are located in-between natural and machine languages. With special training, they can be easily managed by humans and, being strict and formal enough, they can be automatically translated into machine languages.

Programming languages may be discriminated based on the way they are in fine translated into machine executable statements. They can be interpreted or compiled. In both cases a tool is needed to perform the translation. As illustrated in the figure below, the first case relies on a so-called interpreter that on-the-fly translates statements written in the concerned programming language into machine code. Code written in such languages, which is the case of Python, cannot be executed without a specific interpreter. Oppositely, compiled languages rely on a compiler to translate your code in a program that can be then directly executed by your host operating system. So, wheras code written in an interpreted language can be executed on any type of machine, thanks to the interpreter, the result of the compilation of your code is directly executable but on the host machine only.

When you submit source code for execution, the Python interpreter goes through several sequential steps to check the validity of your code and translate it into machine language. These steps are as follows:

  1. Lexing – To split each line of code into tokens, which are abstract elementary units of code.

  2. Parsing – To structure sequences of tokens into a tree structure (Abstract Syntactic Tree) that indicates how to group tokens and in which order they have to be executed. At this step, the parser detects syntactic errors corresponding to unexpected sequences of tokens.

  3. Compiling – To translate your readable source code into byte code that is faster to execute and that is adapted to the execution platform (i.e., your operating system). The result of this translation is stored in (hidden) file having the .pyc extension.

  4. Executing – To execute machine specific statements to run byte code instructions. It is performed by a central element of the Python interpreter, the “Python Virtual Machine (PVM)”. As an intermediate between the machine and your code, the PVM executes your compiled source code that has been completed with its dependencies, code coming from other available libraries.

To go further

Important

The content of this section is optional. It contains additional material for you to consolidate your understanding of the current topic.

Looks like this section is empty!

Anything you would have liked to see here? Let us know on the Discord server! Maybe we can add it quickly. Otherwise, it will help us improve the course for next year!

To go beyond

Important

The content of this section is very optional. We suggest you directions to explore if you wish to go deeper in the current topic.