Discussion about this post

User's avatar
suman suhag's avatar

Anything that is an advanced form like polymorphism can be expressed in more primitive forms. That is why machine code is really primitive — control is done by primitive tests with branch (close by) or jump (further away — although the two forms are probably over-complication). Data must be manually moved around from store to register, etc. Being able to say ‘3 + 4’ is much easier and more sophisticated.

This is abstraction — it makes the programmer’s job easier.

Polymorphism provides an abstraction over dispatch. Whenever there is a code selector, such as if or case (switch in more primitive languages, expressing in more imperative terms), this is really a means to dispatch the correct code.

We have two cases: where dispatch is done on a data value, or where it is done on type. Polymorphism covers the type case. Using polymorphism the programmer thinks in terms of types — the system automatically dispatches the correct code based on type.

This is more abstract thinking and it means there is a whole lot less code in a program to implement dispatch. That is dispatch is implicit rather than explicit.

This saves programmers thinking about a lot of detail which is required by implementation in terms of primitive mechanisms.

The more abstract and sophisticated forms cover anything primitive forms can do. This is why there are cautions against using primitive such as gotos (they cause a mess of control structures) and pointers (they undermine data structures and even security).

The problem is that primitives are easy to understand, beginning programmers can get them straight away. The sophisticated abstract mechanisms take more understanding and appreciation of how they make the job of creating large-scale complex software easier in the long run.

Now most people like to know how things work underneath. That is good, but the real lesson in understanding is that lower levels are not needed for programming, except for the system levels that implement the abstract levels.

In this answer is the key to understanding everything about programming!

Expand full comment
suman suhag's avatar

Anything that is an advanced form like polymorphism can be expressed in more primitive forms. That is why machine code is really primitive — control is done by primitive tests with branch (close by) or jump (further away — although the two forms are probably over-complication). Data must be manually moved around from store to register, etc. Being able to say ‘3 + 4’ is much easier and more sophisticated.

This is abstraction — it makes the programmer’s job easier.

Polymorphism provides an abstraction over dispatch. Whenever there is a code selector, such as if or case (switch in more primitive languages, expressing in more imperative terms), this is really a means to dispatch the correct code.

We have two cases: where dispatch is done on a data value, or where it is done on type. Polymorphism covers the type case. Using polymorphism the programmer thinks in terms of types — the system automatically dispatches the correct code based on type.

This is more abstract thinking and it means there is a whole lot less code in a program to implement dispatch. That is dispatch is implicit rather than explicit.

This saves programmers thinking about a lot of detail which is required by implementation in terms of primitive mechanisms.

The more abstract and sophisticated forms cover anything primitive forms can do. This is why there are cautions against using primitive such as gotos (they cause a mess of control structures) and pointers (they undermine data structures and even security).

The problem is that primitives are easy to understand, beginning programmers can get them straight away. The sophisticated abstract mechanisms take more understanding and appreciation of how they make the job of creating large-scale complex software easier in the long run.

Now most people like to know how things work underneath. That is good, but the real lesson in understanding is that lower levels are not needed for programming, except for the system levels that implement the abstract levels.

In this answer is the key to understanding everything about programming!

Expand full comment
1 more comment...

No posts

Ready for more?