patternMinor
Differences between programming model and programming paradigm?
Viewed 0 times
programmingdifferencesbetweenandmodelparadigm
Problem
-
What is the relation and difference between a programming model and
a programming paradigm? (especially when talking about the
programming model and the programming paradigm for a programming
language.)
-
Wikipedia
tries to answer my question in 1:
Programming paradigms can also be compared with programming models that are abstractions of computer systems. For example, the
"von Neumann model" is a programming model used in traditional
sequential computers. For parallel computing, there are many
possible models typically reflecting different ways processors can
be interconnected. The most common are based on shared memory,
distributed memory with message passing, or a hybrid of the two.
But I don't understand it:
-
Is it incorrect that the quote in Wikipedia says "the 'von Neumann model' is a programming model", because I understand
that the Von Neumann model is an architectural model from
https://en.wikipedia.org/wiki/Von_Neumann_architecture?
-
Are the parallel programming models "typically reflecting different ways processors can be interconnected"? Or are parallel
architectural models "reflecting different ways processors can be
interconnected" instead?
-
In order to answer the question in 1, could you clarify what a programming model is?
Is it correct that a programming model provided/implemented by a
programming language or API library, and such implementation isn't
unique?
From Rauber's Parallel Programming book, "programming model" is
an abstraction above "model of computation (i.e. computational
model)" which is in turn above "architectural model". I guess that a
programming model isn't just used in parallel computing, but for a
programming language, or API library.
What is the relation and difference between a programming model and
a programming paradigm? (especially when talking about the
programming model and the programming paradigm for a programming
language.)
-
Wikipedia
tries to answer my question in 1:
Programming paradigms can also be compared with programming models that are abstractions of computer systems. For example, the
"von Neumann model" is a programming model used in traditional
sequential computers. For parallel computing, there are many
possible models typically reflecting different ways processors can
be interconnected. The most common are based on shared memory,
distributed memory with message passing, or a hybrid of the two.
But I don't understand it:
-
Is it incorrect that the quote in Wikipedia says "the 'von Neumann model' is a programming model", because I understand
that the Von Neumann model is an architectural model from
https://en.wikipedia.org/wiki/Von_Neumann_architecture?
-
Are the parallel programming models "typically reflecting different ways processors can be interconnected"? Or are parallel
architectural models "reflecting different ways processors can be
interconnected" instead?
-
In order to answer the question in 1, could you clarify what a programming model is?
Is it correct that a programming model provided/implemented by a
programming language or API library, and such implementation isn't
unique?
From Rauber's Parallel Programming book, "programming model" is
an abstraction above "model of computation (i.e. computational
model)" which is in turn above "architectural model". I guess that a
programming model isn't just used in parallel computing, but for a
programming language, or API library.
Solution
A programming model is implied by the system architecture. If your system architecture is a register machine, your programming model will consist of machine code operations on registers. If your architecture is a stack machine, your programming model will consist of stack operations. A Von Neumann architecture and a Harvard architecture will have other programming models. Self modifying code p.e. wil be possible in a Von Neumann architecture but not in a Harvard architecture.
A programming paradigm is more highlevel: it is the way a problem is modelled (imperative or declarative, Object oriented, functional, logic,...). A single paradigm language supports one of these. Multiparadigm languages are more a sort of Swiss armyknive which take elements out of more paradigms.
Every architecture (and corresponding model) will have his own set of machine code instructions. This machine code language itself will follow the imperative paradigm (do this , do that, read register A, add the value to register B,... or put a value on top af the stack, put another value on top of the stack, add the two values on top..., etc...)
(At least I never saw a non-imperative hardware processor)
A high level language (of whatever paradigm) will be compiled or interpreted to this machine code.
About parallelism: If we consider interconnected processors it will be clear that the way they interconnect will be part of the programming model. An old INMOS transputer p.e. connects with four other transputers. The machine code wil have instructions to communicate with the naburing transputers.
But also on recent systems the way to provide mutual exclusion will have to be resolved on low level. On a one processor system we will have to put the interrupts on and off when leaving or entering the critical section. On a multiprocessor system we will need a monoatomic 'test and set' instruction. This is part of the programming model.
Parallel computing paradigms are high level models to use parallelism. Think on languages who have threaded objects, or use semaphores and monitors as language elements.
When we program on different operating systems, different API's will be used. (or even if we program on the same system but we use an other library - a graphics library p.e.). This will change our programming model. the low level code will be different, but if there is a good abstraction (sort of code once, compile anywhere) this will be invisible in the high level language. If not, you will have to make small changes in your code. But since you will use the same high level language, there will be no change of paradigm.
A programming paradigm is more highlevel: it is the way a problem is modelled (imperative or declarative, Object oriented, functional, logic,...). A single paradigm language supports one of these. Multiparadigm languages are more a sort of Swiss armyknive which take elements out of more paradigms.
Every architecture (and corresponding model) will have his own set of machine code instructions. This machine code language itself will follow the imperative paradigm (do this , do that, read register A, add the value to register B,... or put a value on top af the stack, put another value on top of the stack, add the two values on top..., etc...)
(At least I never saw a non-imperative hardware processor)
A high level language (of whatever paradigm) will be compiled or interpreted to this machine code.
About parallelism: If we consider interconnected processors it will be clear that the way they interconnect will be part of the programming model. An old INMOS transputer p.e. connects with four other transputers. The machine code wil have instructions to communicate with the naburing transputers.
But also on recent systems the way to provide mutual exclusion will have to be resolved on low level. On a one processor system we will have to put the interrupts on and off when leaving or entering the critical section. On a multiprocessor system we will need a monoatomic 'test and set' instruction. This is part of the programming model.
Parallel computing paradigms are high level models to use parallelism. Think on languages who have threaded objects, or use semaphores and monitors as language elements.
When we program on different operating systems, different API's will be used. (or even if we program on the same system but we use an other library - a graphics library p.e.). This will change our programming model. the low level code will be different, but if there is a good abstraction (sort of code once, compile anywhere) this will be invisible in the high level language. If not, you will have to make small changes in your code. But since you will use the same high level language, there will be no change of paradigm.
Context
StackExchange Computer Science Q#49421, answer score: 5
Revisions (0)
No revisions yet.