As a programmer, you need to have some idea of semantics in order to get anything done. Even something as simple as the expression
x + 1
presupposes that the symbol +
has something to do with addition, the symbol 1
names a literal number, and the symbol x
names something that can be understood numerically. Your understanding doesn't have to be complete (how does that supposed addition handle overflow?), and it doesn't have to be correct (maybe x
is a string and +
performs concatenation), or even consistent, but you can't work with no understanding whatsoever.Does that seem like a reasonable point of view?
Understanding is a tricky thing. A compiler produces useful programs in the target language, but it doesn't "understand" the semantics, does it?
ReplyDeleteOf course, a human needs to understand.
I don't know if a human needs to understand - I've done plenty of 'programming' in unfamiliar setups/environments by copy/pasting, modifying some key things, or programming by mimesis.
ReplyDeleteThis can lead to problems, natch, but things can get done this way.
"Of course, a human needs to understand."
Different people have very different understandings of that term :P
I don't know if a human needs to understand - I've done plenty of 'programming' in unfamiliar setups/environments by copy/pasting, modifying some key things, or programming by mimesis.
ReplyDeleteThis can lead to problems, natch, but things can get done this way.
"Of course, a human needs to understand."
Different people have very different understandings of that term :P
How did you decide *what* to copy and paste? Did you just choose two points in the source code at random? Or did you attempt to discover rudimentary meaning? “I don't know what exactly this does, but it looks like it does it 3 times, and I want it to do 4 times” or “this piece of opaque code seems to generate the doohicky because if I comment it out, the doohicky is gone, but the surrounding stuff is still there”.
ReplyDeleteYes you need to understand if you want to enjoy programming.
ReplyDeleteFrom the R6RS standard:
ReplyDelete"It is important to distinguish between the mathematical numbers, the Scheme objects that attempt to model them, the machine representations used to implement the numbers, and notations used to write numbers."
"Yes you need to understand if you want to enjoy programming."
ReplyDeleteI don't think so, actually (not for me). I enjoy being confused, and the process of learning. This is part of enjoying programming for me: learning new stuff. If I can write serviceable code at the same time as trying to figure things out, all the better : )
"How did you decide *what* to copy and paste? Did you just choose two points in the source code at random? Or did you attempt to discover rudimentary meaning?"
Right, there are degrees of understanding. I think the threshold where you can start writing code (when I get to beyond copy/pasting) is always a significant milestone for me in learning new programming stuff.
Also maybe related is the relative difficulty in reading vs writing code in a given language ( inform 7 sis maybe most exemplary as an example of this). You can understand a piece of code in I7 without too much effort - it pretty much explains itself, but that doesn't mean at all that you have to know the underlying grammatical rules or constructs that would enable you to write such code yourself.
How many languages have formal semantics?
ReplyDeleteI think that semantics would be description what happens with computer during execution of the program. There should be only one semantics, although style of presentation can differ.
ReplyDeleteThen that reality can be described using mathematical abstractions, this time on many different ways.
I'm not sure about term "formal" as it implies lack of meaning, while semantics is about meaning. So, it can be confusing. Maybe concrete and abstract semantics, or real and ideal semantics.
Rog asks: How many languages have formal semantics?
ReplyDeleteFew that I know of. (I assume you mean published formal semantics. Presumably all of them have some semantics even if no one knows what they are.)
Kazimir Majorinc said: I think that semantics would be description what happens with computer during execution of the program.
That would be the operational semantics. There are other ways of expressing semantics: denotational and axiomatic are the two main approaches and there are dozens of variations.
I'm not sure about term "formal" as it implies lack of meaning, while semantics is about meaning.
In the arguments I have about programs and meanings, I often find that people think I'm trying to nitpick about little academic details. I'll ask “How can I know this program does what I think it does?” and I'll get replies like ‘You just know, ok? If it bothers you, go off with the program verification weenies and analyze to your heart's content.’ But I'm interested across the entire spectrum of analysis from casual reasoning to proof chains. (Actually, I don't care much for proofs, I assume someone does and I'll hear if they prove or disprove something interesting.) So when I say “formal”, I'm using the term to contrast against “informal” or “casual” analysis where a programmer looks at a program for a few moments and gets some idea about what it does. That is a kind of analysis, and it is crucial to developing software. If you cannot analyze software at that level, you're pretty much stuck.