this post was submitted on 17 May 2024
10 points (91.7% liked)

Programming Languages

1167 readers
1 users here now

Hello!

This is the current Lemmy equivalent of https://www.reddit.com/r/ProgrammingLanguages/.

The content and rules are the same here as they are over there. Taken directly from the /r/ProgrammingLanguages overview:

This community is dedicated to the theory, design and implementation of programming languages.

Be nice to each other. Flame wars and rants are not welcomed. Please also put some effort into your post.

This isn't the right place to ask questions such as "What language should I use for X", "what language should I learn", and "what's your favorite language". Such questions should be posted in /c/learn_programming or /c/programming.

This is the right place for posts like the following:

See /r/ProgrammingLanguages for specific examples

Related online communities

founded 1 year ago
MODERATORS
 

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.

Thanks.

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

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 4 points 6 months ago* (last edited 6 months ago) (1 children)

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.

[โ€“] [email protected] 1 points 6 months ago

++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.