Why you need to know more about programming languages

After all, the operation of a program is just a continuation of reading or changing the value of a memory or auxiliary storage device. However, by putting a little restriction on it, the rules are set and controlled

Even the things we call programs, when eventually executed by the OS, are simply receiving a certain amount of memory space available as a process and manipulating the values of memory within that area
However, it will not be easy to create an assembly using a few registers, which are tools that programmers can use to manipulate memory at the process level, to identify various factors to consider, including all processors, memory size, number and size of registers

Therefore, we leave it to the compiler to handle these assemblies, and we organize programs by addressing the concept of abstracted, more imaginable, and manageable variables rather than dealing with registers, which are direct hands and feet when manipulating memory

In other words, the tool we deal with is technically part of the memory chunk reserved for the process, and by specifying a name identifier, it makes it more convenient for people to think about problems by allowing them to refer to identifiers instead of directly to memory at the programmer level

The publication in which this article is written is about C++, so I will explain it with examples based on C++

Value is a broad concept that deals with a lot of things, and to put it simply, a variable is just a subset of values. And expression refers to a statement that calculates these values as operands and various custom operators, including “Built-In Operator”, as operators

Next, [1.4. Value Category], but to explain the feeling a little bit earlier, if you look closely at the relationship between values, variables, and expressions defined in the C++ standard, the definition of values and expressions itself is a little more complex and difficult to understand compared to the standard of variable parts

For example, when we’re dealing with variables, unless we’re writing a very sensitive code, we’ve only got to care about general technical issues, such as type, identifier, casting, algorithm, architecture, etc. In other words, the concept of what we see as superficial in the code itself is very intuitive, and even the transformation (typically type casting) between those concepts is defined with a little explanation and understandable rules

However, it does not feel intuitive that the transformation between the values responsible for the inner behavior of the apparent code and the detailed concepts and concepts of the expression

Of course, the precise standard definition of these detailed values and expressions tends to be information for compiler makers or producers, but knowing the concept and behavior of these detailed terms can help a lot with debugging and optimization

For example, the following are the cases:

int main()
{
int arr[] = {, 0, 1, 2};

return 0;
}

Let’s say there is a code like this. If you want to compile it, the compiler returns the following error message:

error: expected primary-expression before ',' token
11 | int arr[] = {, 0, 1, 2};
| ^

To solve the problem, of course, you can google it simply, but to quickly solve the problem with your pure knowledge, you need to know the terms in the error message first

In other words, the error message given by the compiler in this situation suggests that there should be a primary-expression before the ‘,’ token, and to understand this sentence, you need to know the term primary-expression among the categories of expressions defined in the C++ standard

There is another example

#include <iostream>

int main()
{
int num = 0;
int&& rf_1 = num++; // Fine
//int&& rf_2 = ++num; // Error : Cannot bind rValue references to lValue

return 0;
}

Let’s say there’s a code like this. It’s a very simple matter of incremental operators. You see a Declarator called ‘&&’, which you’ll see in [2. Memory, Pointers and Reference], but just to put it simply, it’s the Declarator used to create a reference variable that references rValue. To understand these codes properly when faced, and to write them, you’ll need to know about prValue, glValue, rValue, xValue, and lValue among the categories of values defined in the C++ standard, and you’ll also need to know about the transformation rules between the categories of these values

Of course, C++ deals with simple variables, i.e., objects, and there are many things that can be these objects beyond just variables, such as structures, enumeration, classes, and functions. However, since these must eventually include variables, which are the most basic elements, you will be able to gain a deeper understanding of C++ by first knowing the values of variables and the behavior of expressions, and then moving on to the values and expressions related to each concept in future rounds

And this fact is not limited to C++; it is also true of C#, Python, Java, and Rust. Therefore, in many ways, it will be good to examine and study deeply when learning any programming language

--

--

HyunsuYu
More Deeper C++ Programming Language & Game Dev

As a game developer with Unity and C# as the main players, I've been working on a number of game development projects and side projects