Pascal not considered harmful - was Re: Rich kids are into COBOL

Brent Hilpert hilpert at cs.ubc.ca
Thu Feb 19 22:13:49 CST 2015


On 2015-Feb-19, at 5:35 PM, Sean Conner wrote:

> It was thus said that the Great Eric Smith once stated:
>> On Thu, Feb 19, 2015 at 1:15 PM, ben <bfranchuk at jetnet.ab.ca> wrote:
>>> I never could figure out the point of Objects.
>> 
>> The point of objects is to support data abstraction by disallowing any
>> old random code in a large system from directly manipulating the
>> innards of the objects, and instead require that to be done by methods
>> declared to be part of the object.
>> 
>>> Every data type is different.
>> 
>> If that weren't true, you'd only need one kind of object.
>> 
>> Perhaps what you're questioning is inheritance, which is useful but
>> isn't necessarily a required feature of objects. Inheritance is based
>> on the idea that while two types aren't identical, they may have
>> similarities. As a trivial example, integers and floats are different
>> data types, but they both support arithmetic.
> 
>  Perhaps a better example would be a serial port device class [1], which
> inherits behavior from a character device class, which inherits behavior
> from the device class.  
> 
>  -spc (But I've never found object oriented programming all that compelling
> 	myself ... )
> 
> [1]	A class is the definition of an object.  Or in other words, an
> 	object is an instantiated (created) class.

In my practical experience, I'd say the most useful benefit of OOP is the polymorphism, allowing higher-level code to call alternatives of modules of lower-level code while only changing the initialisation, rather than having to alter or switch every call to a module subroutine.

In the typical I/O example, a terminal or a printer or a network port appear as the same byte-stream paradigm and calling routines. While one can respond we already have that in UNIX and the C I/O library, there the polymorphism takes place either at the system-call level or in the ugliness of the C I/O lib implementation (go look inside).
The point being it is most useful to be able to do that wherever ones wishes, in a formalised manner.

In the 80's, before OOP was a big thing, I developed a semi-formal technique to provide for polymorphism while writing C code although it was pushing the C standard a bit (casting pointers, macros, indirect function calls, etc). I was quite enthused as OOP came on and looked forward to having the ability 'officially' provided in the language and compiler.
Instead, we got C++. Yup, the polymorphism is there - along with an ocean of feature bloat, and 25 years later still no one standard for an OOP C.



More information about the cctalk mailing list