Let's imagine chemistry without the Periodic Table of Mendeleev (1869). How many elements had to be kept in mind, and in arbitrary order... (At that time - 60.)
For this, it is enough to think of one or several programming languages at once. The same feelings, the same creative chaos.
Now we can experience the feelings of 19th-century chemists when they were presented with all their knowledge, plus a little more, in one Periodic Table.

The book "Matrёshka C. Layered System of the Programming Language" presents all units of the C language at a glance. This allows for their organization, correction of outdated information, and even refinement of the very concept of a program.
Today, programming information needs systematization even more than chemical elements did 150 years ago.
The first necessity is teaching. Mendeleev began creating his system when faced with the question of which element to start teaching with: O, H, N, He, Au… It was easier for him — he taught chemistry to the best students of St. Petersburg University. Programming is already taught in schools and will soon start in kindergarten.
The second necessity is a scientific approach. The Periodic Table led to the discovery of new elements and corrections of old data. It helped in creating the model of the atom (1911). And so on.
The third necessity is the clarification of the concept of a program.
Modern programming has one foot stuck in the 1950s. Back then, programs were simple, and machines and machine languages were complex, so everything revolved around machines and languages.
Now everything is the opposite: programs are complex and primary, languages are simple and secondary. This is called the applied approach, which seems familiar to everyone. But students and developers continue to be convinced that everything remains the same.
This brings us back to the first lecture of Privat-Docent Mendeleev. What to tell the freshmen? Where is the truth? That is the question.
The book "Matrёshka C. Layered System of the Programming Language" offers its own answer to this. Moreover, it is addressed not only to students but also to prepared programmers, as the search for truth and the transformation of worldview should be their task, that is, our task.
Next is a brief summary of the book.
1. Introduction
In 1969, the C language was created, which became a foundational programming language and has remained so for 50 years. Why is that? Primarily because C is a practical language that gives programs a human-like appearance instead of a machine-like one.This achievement has been cemented by languages from the C family: C++, JavaScript, PHP, Java, C#, and others. Secondly, it is a concise and elegant language.
However, the C language is often confused with machine assembly, complicating and distorting its perception. Another extreme is the imposition of a certain 'philosophy' onto the language: procedural, object-oriented, functional, compiled, interpreted, typed, and so on. This adds emotion but does not help to better describe the language.
The truth lies in the middle, and for the C language, it is strictly between philosophical and machine perceptions.
The C language is not independent; it adheres to ordinary written speech, while simultaneously managing the assembly language itself. This position describes the Speech Model of a Program, according to which a program is divided into three subordinate types: speech, code, and command. The C language is responsible for the second type, code.
By defining the place of the language in a program, one can organize information about it, which creates the Layered Language System of a Program, presenting the C language in the spirit of a periodic table—on one page.
The system is built with consideration of the commonality of practical languages, stemming from their speech subordination. One set of Matryoshka units of C allows for the description and comparison of different languages, creating a series of Matryoshkas: C++, PHP, JavaScript, C#, MySQL, Python, and so on. It is fitting and proper that different languages are described using the units of the foundational language.
2. CHAPTER 1. The Speech Model of a Program. Understanding C
The first chapter presents the Speech Model of a Program, reflecting the practical approach. According to this, a program has three obvious successive types:
- speech—direct speech of the programmer solving the task,
- code—encoding the solution in a mathematical form using C (or any other) language
- and command—immediate machine commands.
The Speech Model explains why C is a simple and understandable language. C is built in the image and likeness of our familiar human speech.
The first type of program is the direct speech of the programmer. The speech aligns with human thinking. Beginner programmers write programs using speech—first in Russian, then gradually translating actions into code. It was based on this model that the C language was created.
The programmer's inferences, expressed in speech, are transformed into a numerical code form. This transformation should be referred to as reflection, since both speech and code share the same nature (reflection — birth — origin). This is quite evident when comparing the speech form (on the left) and the code form (on the right) of the program.

Interestingly, the reflection occurs very simply—with just two types of expressions.
However, the modern description of the C language (from 1978) does not contain a sufficient list of terms either for describing the language in general or for the task of reflection in particular. Therefore, we are compelled to engage in creativity and introduce these terms.
The choice of words must be precise and clear. This requires a specific approach, briefly expressed as—strict use of the native language. For the English, this would be English, but we are not Englishmen. So we will use what we have and strive to speak Russian.
Reflection is performed by two types of expressions:
- calculation (Ca) — reflects changes in the properties of an object. The property's expression is represented by a number, thus an action on the property is an action on the number—an operation.
- subordination (Su) — reflects the order of actions. The prototype of Su is the complex sentence in speech, so most forms of Su begin with subordinating conjunctions like 'if,' 'otherwise,' 'while,' 'for.' Other forms of Su complement these.
By the way, can you believe that there is no term for calculation expressions in the description of C—they are simply called 'expressions'? After this, it won’t be surprising to find the absence of a name and unification for the type subordination, and indeed the general scarcity of terms, definitions, and generalizations. This is because the famous K/R ('The C Programming Language,' Kernighan/Ritchie, 1978) is not a description but a manual for using the language.
However, it would still be desirable to have a description of the language. Therefore, it is proposed by the Layered Language System of a Program.
3. CHAPTER 2. Layered System. Brief C
Any description must be precise and extremely concise. In the case of programming languages, a straightforward description is challenging.
Here we have a program. It consists of modules. Modules consist of subprograms and collections (structure). Subprograms consist of individual expressions: declarations, computations, and subordina. There are a total of ten types of subordinates. Subordina connect sublevels and subprograms. There are also several declarations. However, declarations are included not only in subprograms and sublevels but also in modules and collections. Most expressions consist of words that are so complex to describe that they are usually presented in two lists — source and derived words, which one will encounter throughout the study and application of the language. Additionally, we include punctuation marks and a number of other expressions.
In such a presentation, it is not easy to understand who stood on whom.
A direct hierarchical approach to describing the language would be excessively complicated. Finding indirect paths leads to a description of the language based on its speech nature and command side. Thus, the Layered system was born, which partially coincides with the Periodic table of Mendeleev, which is also layered. It was discovered 42 years after its publication (1869) that the periodicity of the system is related to electronic layers (1911, Bohr-Rutherford atomic model). The Layered and Periodic systems are also united by the tabular placement of all units on one page.
The description of language units turns out to be brief — only 10 types of expressions and 8 types of other units, as well as being substantial and visual. Although it may be unfamiliar for the first acquaintance.
Language units are divided into 6 levels:
- orders — rows of the table
- departments — special groups of kinds (parts of the first row)
- kinds — cells (the main level of division)
- superkinds — separators of types (a rare level)
- types — formulas of units at the bottom of the cell or separately
- samples — the units themselves (only for words)
Word samples are described by the dictionary — a separate subsystem made up of the same six levels.
The speech component of the C language is quite obvious, although it still deserves description. However, the command part of the language is directly related to managing the compilation, during which a third type of program is created — command. Here we approach the most fascinating side of the C language — beauty.
4. SUBSEQUENT CHAPTERS. Beautiful C
The C language is the foundation of modern programming. Why? Firstly, due to its closest correspondence to speech. Secondly, because it beautifully circumvents the limitations of machine number processing.
What exactly did C offer? Type and layer.
The word 'type' is a translation of the English word 'type', which comes from the Greek 'prototype' — 'pre-image'. In Russian, the word 'тип' does not convey the cornerstone of the expressed concept, and it also gets mixed up with the auxiliary meaning of 'kind'.
Originally, a type solved a purely machine problem of computation, and later became a launchpad for the birth of object-oriented languages.
The layer immediately addressed several tasks — both machine and applied. Therefore, the discussion will start with the single-task type and transition to the multi-task layer.
One unpleasant trait of historical programming is that most concepts, including the fundamentals, are presented without definitions. 'Programming language (name of rivers) has integer and floating-point types...' — and they moved on. What is a 'type' (image) — no need to define, because the authors themselves do not fully understand it and will mumble 'for clarity'. If pressed hard, they will provide vague and useless definitions. It really helps to hide behind foreign words: for Russian authors — behind English (type), for English authors — behind French (subroutine), Greek (polymorphism), Latin (encapsulation), or their combinations (polymorphism ad-hoc).
But that is not our fate. Our choice is definitions with the visor up, in pure Russian.
Type
Type is a prototype name of a quantity, defining 1) the own properties of the quantity and 2) the selection of operations for the quantity.
The word 'type' (kind) corresponds to the first part of the definition: 'own properties of the quantity'. But the main essence of the type lies in the second part: 'the selection of operations for the quantities'.
The starting point for introducing a type in the C language is a regular computation, for example, the addition operation.
Paper mathematics, whether handwritten or typed, does not make a significant distinction between types of numbers, usually considering them as real. Therefore, their processing operations are unequivocal.
Machine Mathematics clearly divides numbers into integers and fractions. Different types of numbers are stored in memory differently and processed by different CPU commands. For example, the commands for adding integers and fractions are two distinct commands associated with two different CPU nodes. However, the command for adding an integer and a fractional argument is nonexistent.
Applied mathematics, which is the C language, differentiates types of numbers but combines operations: addition for integers and/or fractions is written with a single operator.
A clear definition of the concept of a quantity allows for definite discussion of two other concepts: quantity and operation.
Quantity and operation
Quantity — the number being processed.
The operation — the processing of the values of the original quantities (arguments) to obtain the final number (result).
Quantity and operation are interrelated. Each operation is a quantity, as it has a numerical result. Each quantity is the result of transferring a value to/from a processor register, i.e., the result of an operation. Despite this interrelationship, it is still essential to have the possibility of separate descriptions, even if it involves repeating a single word in different sections of the vocabulary, which occurs in ma3.
The machine approach divided all numbers used by the programmer into commands and data. Previously, both were indeed numbers; for instance, commands were written with numerical codes. However, in applied languages, commands ceased to be numbers and became words and operators. Only "data" remained numbers, but continuing to refer to them as such is absurd, as from the machine perspective to the mathematical view, numbers represent quantities that can be categorized into original (data) and final (desired). Referring to an "unknown data" would sound silly.
Commands have also divided into two types of actions: mathematical and auxiliary. Mathematical actions are operations. We will address the auxiliary ones later.
In C languages, familiar paper-based and machine-based unambiguous or singular mathematical operations are nearly universally becoming multiple.
Multiple operations involve several named operations with different forms of arguments and various, closely related actions.
Whole arguments correspond to whole operations, while fractional ones correspond to fractional. This difference is especially evident in the division operation, where the expression 1/2 yields a result of 0, not 0.5. Such notation does not conform to traditional arithmetic rules, but the C language does not strive to adhere to them (unlike Fortran) — it operates by its own applicable rules.
In the case of mixing whole and fractional numbers, the only correct option is value argument conversion — a selective transformation of the value from one form to another. Indeed, when adding a whole and a fractional number, the result is fractional, so the form of the operation selects the operation to convert the whole argument into a fractional value.
Some operations remain multiple, and single. Such operations are defined only for one type of argument: the remainder of division — whole arguments, packing (bitwise operations) — natural integers. M3 indicates the multiplicity of operations with signs (#^) specifying the forms for which the operation is defined. This is an important, yet often overlooked property of each operation.
All functions are arbitrary single operations. The exception is operators — non-parenthetical functions, built into the language (original operations).
Assistance
Assistance — an accompanying action to the operation.
If we consider the operation as the main action, we can identify two accompanying actions that support the operation and differ from it. They are 1) variable control and 2) subordination. This action is called assistance..
Here we need to digress and separately address the Russian translations of programming textbooks. In the K/R text, a new word was introduced for recording actions statement which attempted to distinguish the concept of a machine instruction into different actions: 1) operation, 2) declaration, and 3) subordination (termed 'controlling constructs'). This attempt was buried by Russian translators, who replaced 'statement' with the word 'operator', which:
- became synonymous with the machine word 'command',
- turned out to be synonymous with the phrase 'action sign',
- and also acquired an unlimited number of additional meanings. In other words, it became akin to the English article 'uh...'.
Let’s consider accompanying actions, or assistance..
Variable management
Variable management (UP) — creating/deleting variable cells.
UP occurs implicitly when declaring a variable, which is already written for another purpose — to indicate the magnitude. Only one type is explicitly managed. additional variables using the malloc() and free() functions.
It should be noted that implicit actions are more convenient for writing, as they do not require any additional code but are more difficult to understand — they are harder to account for and interpret.
Subordination
Subordination — connecting/disconnecting layered sections.
The C language proposed a method of control different from assembler, a practical way to manage the order of actions — subordination. It reflects and develops a complex sentence with a clear separation between the main part (subordination clause) and the subordinate part (sub-level/ subroutine sections).
Both declaration and subordination are fully based on the concept of layer.
A layer
A layer — is a limited one-level selective set of expressions.
A layer has taken upon itself several tasks explicitly and implicitly:
- program ordering,
- limiting the visibility of names (implicitly),
- managing variables (memory cells) (implicitly),
- defining subordinate sections for subordination,
- defining functions and collections, and others.
In machine languages, there was no concept of a layer, so it did not appear in K/R either, and if something did not exist there — introducing it in subsequent books would be heretical and free-thinking. Therefore, the concept of a layer never appeared at all, even though it is extremely useful and quite obvious.
Without a layer, it is impossible to explain many actions and rules of a program concisely and clearly. For example, why something as simple as `goto` is bad, while something complex like `while` is good. One can only impotently curse, as Dijkstra did (‘the qualification of programmers is a function inversely related to the frequency of `goto` statements in their programs’. In short, only goats use `goto`. The level of justification — God.) However, this is not so terrible if your books do not have to explain anything at all, but as we have already said, that is not our fate.
Interestingly, it can be assumed that Den Ritchie left goto specifically as a key to find some unnamed concept, because there was no necessity or beauty in the expression goto. Instead, there was a need for a simple and clear explanation of the new language principles, which Ritchie himself did not want to provide, and which are based on the concept. layer.
Deviation
Deviation — a change in the usual properties of a new name.
The most important deviation is related to the layered properties of the program and is described by the word 'static', which has different meanings in each type of layer.
5. LAST CHAPTER. The Commonality of Application Languages
Application languages are figurative languages (having an image, 'typed'). They are based on the explicit or implicit use of an image. Here again, a contradiction arises: the explicit image is more understandable, but less convenient, and vice versa.

(The table markup has not been provided yet, so the table is given as an image.)
After C, the development of application languages moved towards increasing their figurativeness. The most important for understanding high figurativeness is the direct descendant of C — the C++ language. It develops the idea of arbitrary selection of operations for values and embodies it based on the C expression selection, which receives a new name — object. However, C++ is not as concise and expressive as C, due to the overload of new types of selection and the associated rules. By the way, let's talk about 'overload.'
Overloading and Polymorphism
The word 'overload' is an outdated term from the machine approach, denoting the creation of multiple operations.
System programmers multiplicity of operations could be quite irritating: 'What does this sign (+) mean: addition of integers, addition of fractions, or even shifting?! In our time, it was not written this way!' Hence the negative connotation of the chosen word ('overload', 'I'm fed up'). For the application programmer, multiple operations are a cornerstone, the main achievement and legacy of the C language, so natural that they are often taken for granted.
In the C++ language multiplicity The development has spread not only to source operations but also to functions—both standalone and grouped into classes—methods. Along with multiple methods came the ability to override them in extended classes, which was vaguely referred to as 'polymorphism'. The combination of polymorphism and overloading created a volatile mixture that split into two types of polymorphism: 'true' and 'ad-hoc'. Understanding this can only be achieved by looking past the assigned names. Foreign names have paved the way to ad.
The declaration type 'overloading' is better expressed with the word over-declaration — adding a declaration of the same function with arguments of a different type.
The declaration type 'polymorphism' is better named as re-declaration — shadowing a declaration in a new extending layer of the same function with arguments of the same type.
Then it will be easy to understand that methods with the same name of different types (arguments) are over-declared, while of the same type are re-declared.
Russian words solve the problem.
Runway
Considering the concepts of high-type languages confirms the importance of clearly defining fundamental concepts. With properly described C, learning high-type languages will be easy and enjoyable.
This is especially important for implicit high-type languages (PHP, JavaScript). For them, the significance of objects (composite types) becomes even greater than in C++, but the very notion of type becomes implicit and elusive. From a usability standpoint, they have become easier, but from a comprehension standpoint, more complex.
Therefore, one should begin learning programming languages with C and progress in the order of the emergence of languages in the C family.
The same applies to the descriptions of languages. Different languages have a matching or smaller set of types of units than C. The number of types and patterns can differ in both directions: C++ has more types than C, while JavaScript has fewer.
Particular mention is warranted for the MySQL language. It seems unrelated, but it is well described by the Matryoshka model, making acquaintance with it quicker and easier. This is important, considering its significance for the web—the central thoroughfare of modern programming. Where there is MySQL, there are other SQL variants. Also, various Fortran-Pascal-Python languages are described by the Matryoshka model once the hands get around to it.
We are poised for great achievements — a practical description of the C language and a unified description of the languages that follow. "Our goals are clear, tasks defined. Let's get to work, comrades! (Thunderous, prolonged applause, leading to an ovation. Everyone stands up.)"
Your opinions will be heard with great attention, and your assistance in creating the Matryoshka website will be received with immense gratitude. More detailed information about the book can be found on the website cleverly hidden inside the C Matryoshka.
Source: habr.com
