Question about 'Design Concepts in Programming Languages' -- 3 Types of Semantics, what do the mean?
from to on 17 May 2024 02:50

Based on my understanding of what is written in this book, I understood that ‘Operational Semantics’ is something for imperative language, and ‘Denotational semantics’ is for functional languages. In a way, the former is more 'practical 'and the latter is more ‘theoretical’.

So I made the thread in the Rust instance about GC being possible by Rust being an ‘imperative language with denotational semantics’ and people told me I am wrong.

I kinda knew I am wrong, I just went all brazen-like. So I am not brazen anymore.

What exactly did I get wrong about the difference between Operational vs. Denotational semantics? Just a hint would be good.

There’s another type of semantics, Axiomatic. That I don’t even attempt or try to understand! This one is really puzzling for me.

These are complex subjects and I wanna understand them; and you only understand complex subjects if you ask people.


PS: No academic dishonesty, I am not a student.


threaded - newest on 17 May 2024 03:53 collapse

You have both operational and denotaional semantics in all languages.

Operational semantics are “what does this code do,” and denotaional semantics are “what does this code mean” in a more abstract sense.

In an imperative language, what a given piece of code means is “execute these instructions,” so the denotaional semantics are basically equivalent to the operational semantics.

But for higher level languages, these kinds of semantics can differ. For example, in Prolog, the denotaional semantics of a given clause boils down to some formula of predicate logic, while the operational semantics is that a Prolog interpreter will perform a depth first search through the formulas to find acceptable bindings to the variables.

You can imagine another language using the same syntax as Prolog where the denotaional semantics still boils down to formulas of logic, but the operational semantics might be a breath first search through those formulas.

In other words, the denotaional semantics are the more abstract meaning of the code (like, does this code represent data, or formulas, or instructions, or something else) and the operational semantics are the more concrete meaning of the code, i.e. what should happen when the code is executed.

Generally, the denotaional semantics are what you are using in the higher level optimizers, and the operational semantics are what you are using in the lower level optimizers. on 17 May 2024 03:59 collapse

++A; thanks! So, in a domain-specific language, like ASDL which I implemented, it’s mostly the denotational semantics at work, but in a GPL like C, it’s mostly operational. Am I right?

btw if you got the time, could you pls explain axiomatic semantics, that would be great. I don’t at all understand this one. Thanks.