July 10, 2012

Data types and Platonism

The handling of data types is a feature of high level programming languages! Each piece of data is handled by the computer according to its type. There are different operations for all the different data types. Operations like addition or multiplication are applied on each different type in a different way.

But the computer itself does not group data into types! It's just a device which manipulates binary signals very fast. It's the software responsible for compiling or interpreting your program which translates a line of code into an appropriate sequence of machine instructions, and this compilation or interpretation is done according to the types of the pieces of data involved.

Data types were introduced into the world of computing because that's just how the human brain works: we always group things into types and categories.

According to the ancient Greek philosopher Plato, the types of things exist in a separate world which he called the world of ideas. In the real physical world there are lots of different cats around us, but in the world of ideas there is only one ideal cat which represents the way all of them must look like and behave.

This is a very useful philosophical concept! In the computer there are only 1's and 0's just like in the physical world there are only protons, electrons and neutrons. But we cannot think like that! As a matter of fact, even protons and neutrons are human abstractions which have almost nothing to do with reality. Our mind is unable to grasp pure reality in itself. The desire to overcome or feel like overcoming this limitation of our mind and grasp reality as it is, this is called the passion for the Real by modern philosophers like Slavoj Zizek. Indeed the cult of the so-called Real Programmer who reads and writes machine language like no one else is a very nice example of this passion.

So this is why we have data types! Unless you are an autistic savant, chances are that you're not a "real" programmer. You can grasp the concept of binary arithmetic - this skill must be mastered on a high level by computer engineers - but nevertheless it's very painful and inhuman to think like that. We think in terms of integers, strings, floating point decimals and all that. 

Modern programming languages actually allow you to create your own data types with their unique structure and behaviour and things allowed to do with them. This is called Object-oriented Programming. Although you can define data structures like IP addresses in early languages like C as well, but they are not types with their own unique operating functions and structural limitations which you can design into them. This is only possible in object-oriented languages like C++. You see, a type is a lot more than a simple structure of data. A type is no less than a platonic idea. The way actual programming languages practically approach this notion of Platonism is called the type system.

No comments: