Re: Interesting take on Paradigms (OO vs Procedural)



On Mar 29, 6:08 am, "Rick Smith" <ricksm...@xxxxxxx> wrote:
<http://www.cs.berkeley.edu/~jrs/4/lec/14>
-----
Why did the originators of object orientation rename "structures" to
"objects"
and "procedures" to "methods"?

Because they weren't 'programmers', they were simulation modellers.
Simula was/is a language for writing computer based simulations. For
example a petrol (gas) station will have a number of pumps, staff and
cars will arrive at various rates wanting various products and
services. Queuing theory will show some features, such as average
wait times, but simulation will give more information.

What is required in a simulation language is the ability to specify
different behaviours in the various objects being simulated. Some
drivers will bypass a gas station if the queue looks too long, or will
wait a variable time in the queue before giving up. 'classes',
'objects' and 'methods' is the language (jargon) of this activity, and
has been since before there were computers.

Hubris and arrogance, in my opinion.

Which seems to be inadequately informed.

Some
people believe object orientation is a completely new "paradigm" for
programming.

The first was Simula 68 which is now 40 years ago. Smalltalk was soon
after. 'C with classes' (later called C++) was 1981. But the paradigm
comes pre-computer simulation modeling.


The best known paradigms for computer languages are these.
- Procedural languages: Fortran, C, Pascal
- Functional languages: Lisp, Scheme, Haskell
- Logic languages: Prolog
- Object-oriented languages: Java, Smalltalk, C++

These are different because they originated in different disciplines.
Cobol from accounting, Fortran from engineering, APL from mathematics.
Each brought their own terminology and methodology which had been
developed independently for many decades before computers existed.

The first three of these really use very different ways of thinking about
how
to program a computer.

No. They are computerisations of the different disciplines that they
derived from. The "different ways of thinking" were well before there
were computers.

Object-oriented languages are mostly a gloss on
procedural languages.

It happens that OO features were grafted on to existing computer
languages when these features were an advantage. For example C with
Classes was originally implemented via a translator, cfront, that
generated C code. Later this was added directly into the compiler.

Because of the cfront translator then every OO feature had to map to
an existing C mechanism. Thus class data is a struct, overloading is
done with name mangling. At the C level it looks like a 'gloss', yes.

The one part of object-orientation that really stands out, and might give it
claim to being a separate "paradigm," is _polymorphism_.
-----

C++ solves many problems that exist in C. For example name space
pollution. C also is difficult to extend. If, for example, you want a
new numeric type, eg complex, then you have to do it with function.
You need to have a set of functions that will implement all the
mechanisms that are required for each of the data types that could be
used:
'struct complex complex_add_real(struct complex a, real b)'
'struct complex complex_add_long(struct complex a, long b)'
....
....

By creating a class for complex then the operations can be overloaded
and type complex can be used as if it were a built-in type. Instead of
having to change the compiler to include complex as a type that can
take part in expressions so that it can replace, or supplement,
Fortran the same thing can be achieved with a general mechanism that
allows many other types to be added.

The main advantage (IMHO) that OO adds to Cobol (or indeed any
language) is the ability to have multiple instances. Cobol has had the
ability to CALL routines to modularise programs. For example the
printer handling can be a CALLed program that deals with all the needs
of the printer. Different modules could be called dynamically by just
changing the program name variable so that different characteristics
of the particular printers could be dealt with appropriately
(polymorphism). The different modules can, in the end, call a base
module that does the common stuff (emulating inheritance). The
problem has been when the program wants to use two printers at the
same time and these may be the same type. The code has to be
duplicated, or the called programs enhanced to allow the relevant data
to be held in a array or some such.

With OO, one can create a second (or third) printer object and just
use that.

.



Relevant Pages

  • Re: Interesting take on Paradigms (OO vs Procedural)
    ... Because they weren't 'programmers', they were simulation modellers. ... Functional languages: Lisp, Scheme, Haskell ... Cobol from accounting, Fortran from engineering, APL from mathematics. ... Thus class data is a struct, ...
    (comp.lang.cobol)
  • Re: Not enough parallelism in programming
    ... >> Trying to model this in occam and I suspect in most any SW par language ... SW languages don't want or need the ... Funnily enough nor do some hardware projects if some simplifying ... simulation trades speed and simplicity for the event driven simulator ...
    (comp.arch)
  • Re: Interesting take on Paradigms (OO vs Procedural)
    ... but simulation will give more information. ... drivers will bypass a gas station if the queue looks too long, ... these terms are not in the jargon of GPSS users. ... Turning to my* copy of "Programming Languages. ...
    (comp.lang.cobol)
  • Re: ML Classes - What is the right way to construct classes?
    ... I don't think this is unique to MATLAB. ... pass the struct back out again. ... Not breaking the code during refactoring is a different problem. ... In the OO languages I know, ...
    (comp.soft-sys.matlab)
  • Re: off-topic: open challenge to Christian Lynbeck
    ... > declarations in other languages. ... implementations have type safe linkage only with respect to function ... Suppose that some function takes an argument of ``struct foo''. ... This is a mismatch that won't be caught by C++ implementations. ...
    (comp.lang.c)