Live data from Hacker News

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

news.mit.edu

151–160 of 212 posts

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

#152

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

Reading code and not running it is like reading a Spanish text but not knowing Spanish. Running it is equivalent to comprehension.

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 comprehend code.

In eg Rust or Haskell just looking at the types is pretty useful. Or in linear programming, you might want to think about the constraints expressed, but not actually do any arithmetic yourself.

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

#153
post #27

Earlier quoted context omitted.

Even if you consider it communication, that doesn't make it a language. Plenty if communication happens through other means. If we look at the debug session or bash scripting, the closest thing of a two way communication. It doesn't "answer" in code. I see code closer to something like a Floor Plan an architect may use or a CAD drawing from an engineer. Both of them also communicate, but they are not considered langu…

> Even if you consider it communication, that doesn't make it a language In my first comment, I have broken down the definition of language I found and (supposedly) successfully applied each part of it to programming languages (communication being only one of the features). Where is my mistake? Either the definition is wrong, or incomplete, or one of the matches I made is erroneous, or I missed a match. > an architec…

A language is ... does not mean ... is a language. A dog is an animal but an animal is not always a dog.

I think it's clear for the both of us that PLs are not the same as languages. I would just go a little further and calling it a misnomer. For me that is a helpful framing, especially once you go into visual programming.

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

#154

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.

> “Story” mode is why I like to organize my code top-down, often with definitions appearing after their usages. Yes, it drives me nuts that e.g. Python makes you put the definitions before their use!

I'm not sure what you have in mind, but if you put your "main" Python code inside a "main()" function, you can put that main() wherever you want (like at the top). You just have to call it at the bottom of the file, below anything it refers to.

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

#155

Earlier quoted context omitted.

> “Story” mode is why I like to organize my code top-down, often with definitions appearing after their usages. Yes, it drives me nuts that e.g. Python makes you put the definitions before their use!

well, it is like introducing the characters before they play a role

[deleted]

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

#156
post #148

Earlier quoted context omitted.

well, it is like introducing the characters before they play a role

Compare https://en.wikipedia.org/wiki/In_medias_res

Yeah: to me, it really depends on the story being told, and frankly even then it might depend a bit on the proclivities and interests of the person reading the story.

The one thing I'd say almost never works for reading code, though, is the thing people seem to insist is best practice: scattering everything into a hundred separate files with no clear order at all!

Trying to understand that code is like sitting down to an encyclopedia and then being asked to somehow use it to answer to the ultimate question of life, the universe, and everything.

The worst is when you grep the code for "main" in an attempt to at least come to your own idea of order, and it turns out that a bunch of files have their own main functions for various unit tests in files the build system just happens to ignore :/.

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

#157
post #156
post #148

Earlier quoted context omitted.

Compare https://en.wikipedia.org/wiki/In_medias_res

Yeah: to me, it really depends on the story being told, and frankly even then it might depend a bit on the proclivities and interests of the person reading the story. The one thing I'd say almost never works for reading code, though, is the thing people seem to insist is best practice: scattering everything into a hundred separate files with no clear order at all! Trying to understand that code is like sitting down t…

That's part of why Knuth came up with Literate Programming: he wanted to be able to present the reader of his code with a coherent order that makes sense to understand the project.

Given the strict formal requirements on order of languages like Pascal, Knuth had to come up with a clever preprocessing scheme to satisfy both the reader and the compiler. (See his tool, https://en.wikipedia.org/wiki/Web_(programming_system) )

Modern languages are a bit more flexible, but can still benefit from some re-ordering.

> The worst is when you grep the code for "main" in an attempt to at least come to your own idea of order, and it turns out that a bunch of files have their own main functions for various unit tests in files the build system just happens to ignore :/.

I used to use tools like grep a lot, but I found that my productivity really improved a lot when I set up an environment that supports 'jump to definition' and 'jump to references' etc.

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

#158

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.

> “Story” mode is why I like to organize my code top-down, often with definitions appearing after their usages. Yes, it drives me nuts that e.g. Python makes you put the definitions before their use!

    > Python makes you put the definitions before their use!
Is this true for methods in classes?

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

#160
post #27

Earlier quoted context omitted.

> Even if you consider it communication, that doesn't make it a language In my first comment, I have broken down the definition of language I found and (supposedly) successfully applied each part of it to programming languages (communication being only one of the features). Where is my mistake? Either the definition is wrong, or incomplete, or one of the matches I made is erroneous, or I missed a match. > an architec…

A language is ... does not mean ... is a language. A dog is an animal but an animal is not always a dog. I think it's clear for the both of us that PLs are not the same as languages. I would just go a little further and calling it a misnomer. For me that is a helpful framing, especially once you go into visual programming.

> 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 "struct" when you define a type)

Given the definition "A dog is a domesticated animal that has four legs and barks", everything that is an animal, domesticated, that has four legs and that barks is indeed a dog, and something that misses even one characteristic is not a dog (though I made up the definition, it is likely wrong).

Again, polysemy. Not all uses of be are equal. So:

> A language is ... does not mean ... is a language

Indeed, though not for the reasons you had in mind when "A language is ..." is a definition of language: both things around your "does not mean" are indeed true (when you were probably hinting at the second part being false, given your dog example), but the first "is" is definitional, and the second is membership. Both are true because the definition actually defines membership for each individual object described by the definition, and by putting the list of requirements of the definition at the beginning of the sentence, you are describing a particular item that trivially matches the definition. Almost like I did in my example (except I used "everything that", instead of "a").

> I think it's clear for the both of us that PLs are not the same as languages

As natural languages, yes. Which, granted, we would call just languages in everyday life.

> visual programming

How is this related?

I respect your opinion that language in programming language is a misnomer but have not been convinced so far and the more you are writing, the more I'm convinced that your internal definition of language is just too restrictive and I'm also not seeing how this restriction/framing actually helps.

I'm a simple person. You give me a definition of A, you give me something S, if S has all the characteristics given in the definition, S is definitely a A according to this definition.

Now, we can discuss the definition and how it's not entirely (or at all) satisfying, complete, appropriate or useful, and how it could be improved, or how the trick of using qualifiers to further restrict the definition does not cut it.

On this last point, I, so far, have not felt the need to change the definition of language I know to express my ideas clearly, and have been happy to use qualifiers like "natural" or "programming" when needed and unclear from the context. In particular, I have not encountered a situation where calling a programming language a language lead to confusion or bad consequences.

Post reply on HN