Live data from Hacker News

To the brain, reading computer code is not the same as reading language (2020)

news.mit.edu

171–180 of 212 posts

Re: To the brain, reading computer code is not the same as reading language (2020)

#171
post #95

Earlier quoted context omitted.

I’ve seen the same thing, it might be generational. Someone arguing that we need an isNotEqual(a, b) helper in addition to isEqual(a, b), because that’s supposedly “cleaner” and more readable than !isEqual(a, b). They were very vehement about it, but I don’t get that at any level. It’s more lines of code to write and maintain, more unit tests, more characters to type at the usage site and to me, reads exactly the sam…

For me, reading isNotEqual() introduces an extra mental variable. I have to spend extra effort to keep track of the bar over the statement that doesn't exist in the text. But that said, I see no reason that someone couldn't learn to parse notX as fluently as I parse !X. I suppose it's one of those fashions that change with the times. Probably a big reason that I stick to good old C a lot of the time.

One problem is that when refactoring it's easy to make a monster like "if (!notX()) ..."

Re: To the brain, reading computer code is not the same as reading language (2020)

#172

Earlier quoted context omitted.

Perhaps reading code activates the same arras as reading prose in English, but running code in your head activates other areas

If you read code and don't think about what it's doing, are you really "reading" it? Reading code without running it in your head feels like reading prose without actually comprehending it.

I'd put most of my code reading much closer to "inferring intention" than to "running in my head". It's really more like navigating through a complex building, looking for certain rooms than simulating execution. "running in my head" is to reading code like "pronouncing in my head" is to reading prose. Both aren't the norm.

Re: To the brain, reading computer code is not the same as reading language (2020)

#173

At the risk of just being flippant, duh . Language is a means for expressing thoughts, feelings, emotions, and data. Code is a means for instructing a machine how to behave. One encapsulates as much of the experience of being a human as we've been able to cram into it, and the other is a shopping list. They are not the same.

There's quite some things that seem to only/best be expressed as code or mathematical formulas, rather than as natural language. (things like cellular automata come to mind)

Granted, but what about this would suggest that code or math should necessarily activate the language center?

Re: To the brain, reading computer code is not the same as reading language (2020)

#174
post #53

I'm more surprised that anyone with any experience in programming languages has actually thought this could be the case. Making programming languages superficially more like human languages is one of the classic rookie mistakes of programming language design. (See Perl's "do what I mean" paradigm and the chaos that resulted from it) I think two important differences right there are that programming languages are more…

Knowing and using a bunch of programming languages, and also knowing and using several human languages to various levels, I'm firmly in the camp which says that these are totally, utterly different things. Learning a programming language is just as learning any other particular skill (though it's better if you have a programmer's brain, or rather, interest), while learning a human language is.. just very different. And tremendously more difficult, and it doesn't help that it's mostly a semi-conscious business, in fact "studying" in the general sense gives very little return.

Re: To the brain, reading computer code is not the same as reading language (2020)

#176
post #160

Earlier quoted context omitted.

> A dog is an animal but an animal is not always a dog. In this sentence, "is" describes membership (a bit like isinstance in Python, or instanceof in Java or JS). In a definition, this is not the same "is". In a definition, "is" is the definitional "is", and what is after the "is" is supposed to be a comprehensive list of things you need to match to be called the term preceding the "is" (a bit like "class" or "struc…

> How is this related? That is sort of my point, if you think of a PL as a language, visual programming is not related. You are drawing a line somewhere between PL and visual programming. If you think of a PL as a specification, it is the same thing just presented differently.

You can see the vocabulary and the rules of a language as a specification (for the set of productions of the language) if you wish. A language is a specification (although the reverse might not be true).

Visual programming certainly deals with a (visual) programming language, which is still a language. A language doesn't need to be textual. It only needs grammar rules and vocabulary. For instance, taking the example from [1]:

- the "set" block and the "for" block are elements ("words") of the vocabulary of "Snap!"

- 'an identifier i needs to appear in a "set" block before appearing in a "for" block' is a grammar rule of "Snap!" (I would guess)

- 'a "set" block can appear in the body of a "for" block' is also a grammar rule of "Snap!"

You can even build a 1:1 mapping between VL and TL, where VL is the visual language and TL is an equivalent textual language, so the notions are essentially the same.

For me, where the notion of language can be criticized is that for natural languages, the grammar rules and the vocabulary set are ever changing and not always well defined. The rules + vocabulary thing is a model at best.

[1] https://en.wikipedia.org/wiki/Visual_programming_language

Re: To the brain, reading computer code is not the same as reading language (2020)

#177
post #101

Earlier quoted context omitted.

“Story” mode is why I like to organize my code top-down, often with definitions appearing after their usages. It makes the code read more like a story from top to bottom. Some like to organize their code such that any term always appears before it is used. Like a math proof or something. I find this somewhat pleasing but unhelpful for understanding the “story” you mention.

Both programs and math proofs are allowed to be written in story mode where definitions can come after their usages. Unless you write in C. There's no story mode in C :-)

Sure there is, what do you think header files are? Just use a prototype and defer the actual code to a lter point in the file, voila, story mode.

Re: To the brain, reading computer code is not the same as reading language (2020)

#178
post #151

Not reading but writing code, I have a similar feeling as playing the piano, especially in highly interactive programming languages like Clojure or Common Lisp. Does anyone have similar experiences?

Not me. Far from it, actually. Playing music feels very distinct from programming. However, mathematicians and computer scientists are more drawn to Bach than other people. There's some connection between music appreciation and programming.

Re: To the brain, reading computer code is not the same as reading language (2020)

#179
post #152

Earlier quoted context omitted.

Compilers understand code pretty well, but they don't run it. (Similarly, if you are a human translating code from C to Pascal, you'll want to understand it, but you won't necessarily execute it by hand to get that understanding.) How could you run code, when you don't know the inputs? You can reason through how the code could run with some example inputs, but that's just one of many tools we have in our belt to comp…

I’ve never seen a compiler that can answer the question: “what is the purpose of this function?” On the other hand, if I ask a human that question about a particular function and they are unable to answer it satisfactorily, I would have an extremely difficult time believing that they understand it.

Humans don't necessarily run the code step by step in their read to answer this question, either.

Quoting again the part that that prompted the discussion:

> While the programmers lay in a functional magnetic resonance (fMRI) scanner, the researchers showed them snippets of code and asked them to predict what action the code would produce

The question wasn't about whether the programmers understood the code but whether they can predict what the code will output.

I hypothesize that either the programmer recognizes the purpose of the code or they don't.

If they do recognize, their brain will probably engage with the code differently, in a more high level way, taking into account the bigger picture; but if they don't they probably need to execute it step by step to have any chance of predicting what they do, which is akin to doing a calculation.

It also depends on whether the code is a tangled mess or well structured; how descriptive are function names and variable names; whether the code has comments; etc.

And of course in real world code there is a mix of both modes of reasoning. And the point is, those two modes of reasoning might as well activate different regions of the brain. (or maybe not?)

Re: To the brain, reading computer code is not the same as reading language (2020)

#180
post #176

Earlier quoted context omitted.

> How is this related? That is sort of my point, if you think of a PL as a language, visual programming is not related. You are drawing a line somewhere between PL and visual programming. If you think of a PL as a specification, it is the same thing just presented differently.

You can see the vocabulary and the rules of a language as a specification (for the set of productions of the language) if you wish. A language is a specification (although the reverse might not be true). Visual programming certainly deals with a (visual) programming language, which is still a language. A language doesn't need to be textual. It only needs grammar rules and vocabulary. For instance, taking the example…

Interesting! You seem take "language" really far / different.

How about something like editing an image in Photoshop? There's a vocabulary (the commands) they get applied to the image. There are also rules (constraints). One could argue using photoshop is communicating with a computer, what to do with an image.

So while I say language is a misnomer for PL, you say it's a misnomer for natural languages. ;-)

Post reply on HN