3 ms·
Another way of looking at this, which is well loved in the PL community, is that there is no one exact interpretation of a fragment of syntax. Haskell is intere
by tel 11y ago
Another way of looking at this, which is well loved in the PL community, is that there is no one exact interpretation of a fragment of syntax. Haskell is interesting because it has both operational and equational semantics and you can choose which you'd like to apply at any given time.
What's nice about this is that it removes the "programmer" from the equation and instead augments language with a bouquet of interpretations. Another Haskell interpretation, e.g., is the static nature of its typing relation.
This is a good way of "understanding monads" as well. They're an algebraic structure which captures just enough to let us talk about a variety of sequential/operational semantic choices for our syntax. At the end of the day, though, they're just data and we can imbue them with all of the semantic notions we enjoy via the interpreter pattern. This is even more emphasized with the "Free Monad" pattern which lets the structure of the monad be very, very close to the syntactic notion.
- jerf 11y ago"What's nice about this is that it removes the "programmer" from the equation and instead augments language with a bouquet of interpretations." Implicitly, I'm invoking the idea that a programmer is looking at a particular runtime. I feel like I have to put that in, or the whole distinction between declarative and imperative completely collapses anyhow. "X.sort()" conceptually simply invokes sorting behavior, possibly with a certain set of guarantees, but in practice, it's very unusual for that to be running so abstractly that the programmer can not penetrate down to relevant runtime details. And when that does happen, generally forces are created that start pushing all the switchable runtimes towards bug-for-bug compatibility, e.g. the web browser's Javascript runtime. It's not a "bad" thing that it collapses in that case, it just does, that is, consider this the mathematical "collapses" rather than the architectural. You have to have a certain amount of specificity in my opinion or there is no reasonable way to discuss "declarative" vs. "imperative".
- tel 11y agoI think you do need "bug for bug" compatibility between semantics—because the other choice is worse—but that drives home what it takes to genuinely have alternative semantic choices: sufficient concision of definition to be able to maintain the choices! This is standard for programmers, though. It's architecture like any other.