4 ms·
C++, Java and C# aren't really object oriented languages --- they're scalar languages with object systems bolted on. The giveaway is that they're full of types
by david-given 10y ago
C++, Java and C# aren't really object oriented languages --- they're scalar languages with object systems bolted on. The giveaway is that they're full of types which aren't objects; ints, pointers, floats, booleans, etc. These are handled and implemented entirely differently to the object types. e.g.: compare a Java int (a scalar type) with a Java Integer (an object type).
In a proper object-oriented language, everything is an object, including these. That allows you to do some really interesting things which are at the heart of the OO mindset. e.g. Smalltalk avoids having to use conditionals almost completely via dynamic dispatch:
b ifTrue: [ 'b is true!' print ]
b is a Boolean; ifTrue:block is an abstract method called on Boolean. But the values true and false are actually instances of subclasses of Boolean; True's implementation of ifTrue evaluates the block, and False's doesn't, and that's how you get different behaviour depending on whether b is true or false. The core language neither knows nor cares that booleans are special.
(Actually, the bytecode does care, and has special accelerated opcodes to make operations of booleans fast for performance reasons, but that's just an implementation detail.)
- dualogy 10y agoLuckily I first encountered "OO" after having already learned the concept of structs/records in Pascal, this way I did not have to seriously entertain the idea that simple scalars oughta be anything-but..