<p>I am familiar with the standard computation models like the RAM model, stack model etc. And I also know that operational semantics for a language views the language features as transitions in a transition system. I would like to know whether while designing the language do people have a formal model in mind to guide the design.</p>

<semantics>
What computation models are typically used when designing a language?
CC BY-SA 4.0
2024-11-15T04:43:37.217Z
If my motivation for designing the language was an academic or pedagogical exploration of a particular computation model then yes. But most languages are designed to *meet the requirements of a particular constituency of software developers*, not to reify a particular model of computation.
Eric Lippert
<p>To begin with, a model of computation is only needed to define <a href="https://en.wikipedia.org/wiki/Operational_semantics" rel="nofollow noreferrer">operational semantics</a>, i.e. how a program executes. A language's semantics can be defined instead by <a href="https://en.wikipedia.org/wiki/Denotational_semantics" rel="nofollow noreferrer">denotational semantics</a>, which define the meanings of its terms (e.g. statements or expressions) and which terms have the same meanings as which other terms. Denotational semantics need not be defined with reference to a model of computation.</p>
<p>Formal models used by academic computer scientists are often used to analyse algorithms, so they are designed according to that need, not the needs of designing actual programming languages that can be run on real computers. For example, in the <a href="https://en.wikipedia.org/wiki/Word_RAM" rel="nofollow noreferrer">Word RAM model</a> it's assumed that registers have a number of bits which grows when the algorithm's input size does ─ but obviously no real computer has such registers. So no real programming languages are defined with respect to the Word RAM model, for example.</p>
<p>Instead, the operational semantics of real programming languages are typically defined in reference to a &quot;<a href="https://en.wikipedia.org/wiki/Virtual_machine" rel="nofollow noreferrer">virtual machine</a>&quot; or &quot;<a href="https://en.wikipedia.org/wiki/Abstract_machine" rel="nofollow noreferrer">abstract machine</a>&quot; which is usually invented for the purpose of defining the semantics of that particular language. For example, the &quot;C abstract machine&quot;, the &quot;Java virtual machine&quot;, and so on. In C's case, the abstract machine <a href="https://utcc.utoronto.ca/%7Ecks/space/blog/programming/CAsAbstractMachine" rel="nofollow noreferrer">was invented <em>after</em> the language was</a>, but either way it is a model of execution specifically designed for the purpose of defining C's semantics.</p>
<p>Of course, there are also other languages which are <em>implemented</em> in terms of e.g. the Java virtual machine, but their semantics may or may not be defined in relation to it.</p>

CC BY-SA 4.0
2023-05-20T05:10:50.170Z
2024-11-13T19:23:05.087Z
2024-11-13T19:23:05.087Z
kaya3
CC BY-SA 4.0
2023-05-20T13:05:40.717Z
So semantics often comes after the fact and does not guide the language creation process?
jude
CC BY-SA 4.0
2023-05-20T13:13:16.840Z
@jude No ─ the semantics of the language are often designed before or alongside the language implementation, though they may be formalised later. C is a bit of a special case, because for a long time it was thought of as a glorified assembly language ─ i.e. the compiler would convert your C code into corresponding machine code, without comprehensive guarantees about what the behaviour of that machine code would be.
kaya3
# What computation models are typically used when designing a language?
Posted by: username_0 on 2023-05-20
I am familiar with the standard computation models like the RAM model, stack model etc. And I also know that operational semantics for a language views the language features as transitions in a transition system. I would like to know whether while designing the language do people have a formal model in mind to guide the design.
**Tags:** semantics
> **Comments:**
> **username_1**: If my motivation for designing the language was an academic or pedagogical exploration of a particular computation model then yes. But most languages are designed to *meet the requirements of a particular constituency of software developers*, not to reify a particular model of computation.  
---
## 1 answers
### Answer by username_2 on 2023-05-20. Score: 3 | Accepted answer
To begin with, a model of computation is only needed to define [operational semantics](https://en.wikipedia.org/wiki/Operational_semantics), i.e. how a program executes. A language's semantics can be defined instead by [denotational semantics](https://en.wikipedia.org/wiki/Denotational_semantics), which define the meanings of its terms (e.g. statements or expressions) and which terms have the same meanings as which other terms. Denotational semantics need not be defined with reference to a model of computation.

Formal models used by academic computer scientists are often used to analyse algorithms, so they are designed according to that need, not the needs of designing actual programming languages that can be run on real computers. For example, in the [Word RAM model](https://en.wikipedia.org/wiki/Word_RAM) it's assumed that registers have a number of bits which grows when the algorithm's input size does ─ but obviously no real computer has such registers. So no real programming languages are defined with respect to the Word RAM model, for example.

Instead, the operational semantics of real programming languages are typically defined in reference to a "[virtual machine](https://en.wikipedia.org/wiki/Virtual_machine)" or "[abstract machine](https://en.wikipedia.org/wiki/Abstract_machine)" which is usually invented for the purpose of defining the semantics of that particular language. For example, the "C abstract machine", the "Java virtual machine", and so on. In C's case, the abstract machine [was invented *after* the language was](https://utcc.utoronto.ca/%7Ecks/space/blog/programming/CAsAbstractMachine), but either way it is a model of execution specifically designed for the purpose of defining C's semantics.

Of course, there are also other languages which are *implemented* in terms of e.g. the Java virtual machine, but their semantics may or may not be defined in relation to it.
> **Comments:**
> **username_0** (2023-05-20): So semantics often comes after the fact and does not guide the language creation process?  
> **username_2** (2023-05-20): @jude No ─ the semantics of the language are often designed before or alongside the language implementation, though they may be formalised later. C is a bit of a special case, because for a long time it was thought of as a glorified assembly language ─ i.e. the compiler would convert your C code into corresponding machine code, without comprehensive guarantees about what the behaviour of that machine code would be.  
---
