6 ms·
A semantics is a property a programming language, not the style you happen to program in. --- @lmm > In practice no practical language provides formal semant
by catnaroek 9y ago
A semantics is a property a programming language, not the style you happen to program in.
---
@lmm
> In practice no practical language provides formal semantics for the entire language
Programming languages are mathematical objects and always have a formal semantics, regardless of whether someone has taken the trouble to write it down or not.
What I'm saying is - the formal semantics that most languages have preclude the existence of compound values. Without those, you can't define interesting functions, and thus you can't program in a functional style.
- lmm 9y agoIn practice no practical language provides formal semantics for the entire language, only for restricted subsets of it i.e. particular styles within the language.
- lmm 9y agoResponding to edits: > Programming languages are mathematical objects and always have a formal semantics, regardless of whether someone has taken the trouble to write it down or not. Not true for the usual plain-english meaning of "programming language". Plenty of things we call programming languages take a "the implementation is the spec" view, or simply can't be assigned any useful semantics in a way that's at all aligned with the defining characteristics of the language in question. Even in, say, Haskell, io explicitly lacks formal semantics. > What I'm saying is - the formal semantics that most languages have preclude the existence of compound values. Without those, you can't define interesting functions, and thus you can't program in a functional style. Python tuples are perfectly cromulent compound values. Python has a bunch of builtin classes for which the equality operators that are available in the language are all kind of useless, sure, but that's true in almost all languages.
- catnaroek 9y ago> Plenty of things we call programming languages take a "the implementation is the spec" view, And do you think the implementation isn't a mathematical object itself? > or simply can't be assigned any useful semantics in a way that's at all aligned with the defining characteristics of the language in question. This is a contradiction in terms. By definition a semantics is a mathematical descrpition of the meaning of a programming language, i.e., the behavior of its programs. Sometimes a semantics exposes significant differences between the mental model of programmers and what a programming language really is, but the solution is not to turn a blind eye to reality. > Python tuples are perfectly cromulent compound values. So long as they have object identities, they are not values. Values are merely represented in memory - they truly exist in the language's semantics.
- lmm 9y ago> And do you think the implementation isn't a mathematical object itself? Only if you're taking the Tengmark "mathematical universe" view. The implementation is not necessarily any more mathematical than, say, a table. > This is a contradiction in terms. By definition a semantics is a mathematical descrpition of the meaning of a programming language, i.e., the behavior of its programs. Sometimes a semantics exposes significant differences between the mental model of programmers and what a programming language really is, but the solution is not to turn a blind eye to reality. The meaning expressed in a language is some alignment of what the writer intended and what the reader understood. If different readers don't reach a shared understanding then there is no meaning. It would be desirable for our programs to always have meanings that aligned with their behaviour, but we shouldn't turn a blind eye to the fact that many programs don't. > So long as they have object identities, they are not values. Values are merely represented in memory - they truly exist in the language's semantics. Any practical programming language will give you some way to find the memory address of a particular value, so values that we usually consider as semantically identical are not actually indistinguishable in practice. We deal with this by only assigning semantics to a subset of the language that excludes those operations. Python without "is" may be more obviously a subset than, say, Haskell without unsafeCoerce, but both are subsets.
- catnaroek 9y ago> It would be desirable for our programs to always have meanings that aligned with their behaviour, but we shouldn't turn a blind eye to the fact that many programs don't. The meaning of a program is its behavior, period. If reality doesn't agree with your views, it's your fault, not reality's. > Any practical programming language will give you some way to find the memory address of a particular value, so values that we usually consider as semantically identical are not actually indistinguishable in practice. Standard ML doesn't give you any way to get the memory address of a particular value, so values that are semantically identical are actually indistinguishable in practice. > We deal with this by only assigning semantics to a subset of the language that excludes those operations. That doesn't make sense. Semantics is a property of the real programming language you are using, not the fictitious one you wish you were using.