Why were weakly typed programming languages created
Values and type system
The main task of programming is to manipulate values. In order to be able to manipulate values, all values in the languages C and C ++ must be assigned to a unique type that defines the structural interpretation of the underlying data. Using this type, the compiler can convert the program code into the appropriate assembler commands. This well-known concept is a basic, powerful, and far-reaching concept of the C and C ++ languages.
The C and C ++ languages specify a small number of basic types as well as the ability to nest types within each other, which means that any complex types can be created. All possible types can be found on the types page.
In assembler you work with data, in C and C ++ you work with values. Each value has a dedicated type that determines the structural interpretation of the underlying data. The programmer no longer has to worry about storing the data, but can trust that the manipulations of values will be translated into the desired assembler commands by the compiler based on the knowledge of the type.
There are three different types of values in C and C ++: A fixed value in the program code (a so-called), the content of a variable and the return value of an operator:
|Fixed value variable containing a value operator returning a value||3.14159; int x = 42; x + x;|
Fixed values are written directly into the program code and, based on the syntax (how they are written), implicitly define a type. These values are already permanently coded into the program during compilation and afterwards can no longer be addressed by the programmer, let alone changed. The notation of such values is described in more detail on the page about fixed values.
Variables designate a location in the memory or in a processor register that can be addressed and changed by the programmer. In order to address this point, a symbol is set as a placeholder for the place you are looking for, i.e. a user-defined name. When this symbol appears in the program text, the value of the variable is automatically addressed. So that the compiler knows how to interpret the data at the point to be addressed when a symbol occurs, a type must be assigned to each symbol. This assignment is known as a declaration.
Operators allow values to be linked with one another. Each operator defines what kind of input values it requires and what kind of return value it delivers. For example, the addition operator requires two input values and provides a return value. The type of return value is precisely specified for each operator. The detailed specifications can be read from the respective operators. The programmer can use the return values in expressions to sequentially connect several operations one after the other, to interleave them, or to finally save the return value in a variable.
It should be noted that functions can also return a value. In C and C ++, however, function calls are processed with the function call operator.
Designations of typifications
Most modern programming languages have some form of typing. A language that requires explicit instructions for conversions between different types is called (also or in German). In contrast, typifications, which allow automatic conversions and, for example, dynamic evaluations of types, are referred to as (also or in German).
There is also a second description of the typification. Programming languages that require a type for each value are referred to as (also or in German or). In contrast, there are programming languages which automatically determine the type of a value (as well as that of a variable) or even change it dynamically, without the programmer ever having to specify a type. Such languages are referred to as (also or in German or even).
All of these English and German terms are very confusing. However, they don't really matter as long as programming is in one language. When porting between different typed languages, however, such keywords are inevitably lashed out, which is why the author tries to classify C and C ++ in these terms as well:
The programming languages C and C ++ are strictly typed, which means that every value has a firmly declared (static) type. However, when it comes to the question of whether C and C ++ are strongly or weakly typed, different sources argue. The author personally tends towards the weak variant, because: The languages C and C ++ allow a value to be reinterpreted (more or less) at will, if so desired. For example, it is possible to interpret a value as a value (arithmetic conversion), cast this value as an address and address the content of the address as an object of a polymorphic class. This example makes little sense, but there are situations in which weak typing is used explicitly, for example when calculating array indices. However, since such conversions almost always have to be done explicitly and modern compilers usually output warnings or even errors if type conversions do not make sense, the languages C and especially C ++ can also be described as strongly typed. However, by explicitly specifying what the programmer wants, warnings can usually be removed.
Imprint © Tobias StammEmail
- How do I learn to design software
- Where does Himalayan salt come from
- What is UPI and USSD
- Why does Oculus build its own GPU
- What is the formula for Glauber's salt
- Mattis was right to step back
- Which public offices make the most money?
- Why did Mahmohan Singh Narendra Modi strike
- How do mustard seeds grow
- What made people dislike Hillary Clinton?
- Which company has the coolest ticker symbol
- Which texts are you scared of?
- How can I cancel my AFLAC account?
- Where and how are chromosomes formed
- What causes peace
- Are you psychologically tormented
- What is a bezel crystal
- Microsoft is a copy of Apple
- Are there Gnostic Christians today
- The OnePlus 5
- Every compound sentence needs a comma
- What is a Stream Horse Racing website
- Which is for sure WordPress or Magento
- Is the shower filter for hard water