Types and Typing in programming languages

The most important thing in programming languages is data types. Each language has many types of data like boolean, integer, float, character, string, array, records, lists, tuples, unions, etc. Some of them are primitive data types, and others are complex. The primitive types play a central role in all languages; on the contrary, the complex data types don’t have a realization in some languages. A data type also means predefined operations that can be performed for it. For example, for the integer type, you can use the simple arithmetical operations like addition, subtraction, multiplication, and division; for the string data type available operations are like concatenation, union, subtraction, etc.; for the complex data type include objects, arrays, etc. Thus, many specific operations that can be different from one to another which depending on a language.

The program may be written by using any data type, but the relevant type is determined by the ease with which the results of the program can be performed. It other words, the data type must be bounded to the objects that in the real-world problem being addressed. The right chosen data type facilitates further support and modifies a program. In the modern world, when all around us changes frequently, it is especially important to have the ability to change a program in the appropriate way. Also, a computer program it is only the paradigm of a data manipulation, so in this meaning, the data is a structure that can be manipulated by the operations with data types. Thus, by matching the real problem with the right tool, the result may bring profit and solve the problem. On the contrary, an inappropriate data type may be the cause that freezes or slows down the program. In a negative scenario, using the wrong data type can lead to losing the data.

Lost data and errors are the most common problems in programming. On the design stage sometimes mistakes are allowed, so when the real users try to use a program, they can run into a problem. For instance, imagine some application where users need to fill numeric data into a field, and they can write a decimal number into the field, but the handler of that field accepts only a real or an integer data type, then the error is very expected. The way the program will behave, in this case, depends on the type of typing in the programming language. There are two typing classifications: the first is strong, and the second is weak. Based on the example above, if the application had used the strong typing, then the program would have been interrupted by an error like a segmentation fault. But, if the weak typing had been used, then the program would have lasted, but the user was perplexed and confused when his entered number like – 1.4 transformed into something like 1. It means the entered number was converted implicitly, or it may be named type coercion. However, an error wouldn’t have occurred, if a programming language had strong typing, and the type casting was used in the application.

In that case, the decimal number – 1.4 would be explicitly converted into 1 without any errors. The reason why in a programming language that has strong typing is needed to make the type casting to prevent the errors is the static typing. Overall, there are another two types of classification of the languages: static and dynamic. In the static type, each variable has its own type of data. It means that a certain range or a certain size of memory is allocated for this variable. So, when the program is running, and the variable is assigned with a value with a different data type that requires more memory, then the error of segmentation data occurs. In other words, the CPU tries to write the data to the address that lies outrange of the allocated memory and may corrupt another programs data in the nearby memory blocks. To prevent the corruption of the data, the error occurs. But if the type casting is used, the “oversized” value will be cast to the variable type. And the situation is the same as it would be implicit conversion. In the languages with the dynamic types, the conversation happens implicitly, but the variable can change its own type to the type of the value. The dynamically typed languages also may not have explicit typing; thus, in the source code, there are no variables with data types, and the code execution program converts them in the appropriate way based on the values types they are assigned to.

Honestly, this is only my point of view. There are many people with the different views who can disagree with me, because there are no clear rules to determining what the terms above are meant. They don’t exist because each language is used every day by a sheer number of people in different conditions to solve various tasks or problems, and most importantly, they are evolving every day.