3 ms·
Isn't the abstraction, and sticking to the abstraction, the job of the programmer, and not the language? We all speak English here; you can say, "let's all spe
by whacked_new 18y ago
Isn't the abstraction, and sticking to the abstraction, the job of the programmer, and not the language?
We all speak English here; you can say, "let's all speak like Yoda now." Quite easy, that is. But the underlying language doesn't need to change; other people can invent different rules and create different settings where these rules apply strictly.
So imperatively, your socket program is like this:
f = file("/hello.txt")
p = makeport(8934)
s = makesocket(p)
s.send(f)
s.destroy()
which is perfectly fine. This is basically a line by line translation from your English-looking pseudocode to this OO-code-looking pseudocode. Using s-expressions would make the whole process read much more like speaking:
Let's say I wanted to send a file:
Using the socket that uses the port 8934, send the file hello.txt, and destroy the socket.
Plain English, right? Reorder into:
Destroy the socket that is used to send the file hello.txt and is created with port 8934.
Translate to s-expr:
(destroy-socket (send-file (make-file "hello.txt") using (make-socket (make-port 8934)))
I'm taking liberties with the send-file function syntax.
Looks ugly, but that's pretty close to the natural language representation. If you parse the syntactic tree it will almost overlap completely.
- delackner 18y agoThe inversion you applied to the plain english makes it into a format that is, while technically english, the sort of construct that one imagines an alien or robot might produce when trying to talk to us. If you actually spoke like that people would look at you very strangely, and this is the difficulty in understanding s-expressions that I think a lot of people have. That said, since my own programming style in C-derived languages seems over the years to slowly be attempting to imitate s-expressions, I think a lot of the mental difficulty people mention is just being overly comfortable with the familiar.