5 ms·
The paper wasn't linked as far as I can tell but is probably https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7738192/pdf/elife-58906.pdf https://www.ncbi.nlm.nih.g
by JonChesterfield 2y ago
The paper wasn't linked as far as I can tell but is probably https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7738192/pdf/elife-58906.pdf https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7738192/pdf/eli...
> 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
I have a suspicion that writing code and understanding that written by someone else are different skill sets.
- fmbb 2y agoI feel like this is akin to asking someone to read a fairytale and to tell you how many times a person crossed a bridge in it, or what they carry in their hand in the end, or where the apple is when all is done. I don’t think this is about understand what is written, it’s about figuring out what that which is written means.
- wanderingstan 2y agoThat’s an excellent point. I’ve realized that I sometimes read code in more of a “story” mode, where I’m just looking for the gist of what’s happening and what it is “about” rather than the nuts and bolts of how it actually works.
- bigyikes 2y ago“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.
- rav 2y agoBoth 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 :-)
- Bootvis 2y agoThere is CWEB. Literate programming is the ultimate story mode.
- NavinF 2y agowtf is CWEB? I presume you're referring to something other than "China Internet Index Bull 2X ETF"?
- gshubert17 2y agoSee: http://literateprogramming.com/cweb_download.html http://literateprogramming.com/cweb_download.html
- eru 2y agoThe clue is in the next sentence. If you look for cweb by itself, you might get weird results, because there are only so many four letter acronyms / words. Look for 'literate programming cweb' or just 'literate programming'.
- kloop 2y agoIf you forward declare things there are. The compiler really just cares about the shape and the symbol it has to call.
- shermantanktop 2y agoBut there’s a postmortem, in the core file. Maybe that’s just a photo of the crime scene.
- bandie91 2y agoin C there is only epic mode :)
- lynx23 2y agoSure 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.
- threecheese 2y agoThat’s so interesting. I find myself organizing code to have minimum-understandable units, which ends up following the narrowing project->folder->file… abstraction all the way down - the end product resembles more a taxonomy than a story. I love your metaphor though and I am going to try it right away.
- lloeki 2y agoSee https://en.wikipedia.org/wiki/Literate_programming https://en.wikipedia.org/wiki/Literate_programming
- Wowfunhappy 2y ago> “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!
- yashasolutions 2y agowell, it is like introducing the characters before they play a role
- eru 2y agoCompare https://en.wikipedia.org/wiki/In_medias_res https://en.wikipedia.org/wiki/In_medias_res
- saurik 2y agoYeah: 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 :/.
- eru 2y agoThat'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) 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.
- layer8 2y agoDifferent, but not entirely different, both use the same kind of reasoning about program behavior. And the article is not about writing code, other than to the extent that it should be comprehensible by others.
- tgv 2y agoThat would already support the thesis, because formulating and understanding natural language share quite a bit.
- nextaccountic 2y agoPerhaps reading code activates the same arras as reading prose in English, but running code in your head activates other areas
- Wowfunhappy 2y agoIf 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.
- evilduck 2y agoMaybe? I don’t need to read and calculate every iteration of some loop to understand that it’s mapping. While if I need to determine the actual output value of a function, I might.
- nextaccountic 2y agoSometimes working out the details what is the right output of a piece of code (like, in the line x = f(15), is x 2345 or 2346?) is very time consuming It's also sometimes unnecessary to understand the high level picture of what the code does (like "oh, this computes the GCD using Euclidean algorithm, I had to code this in uni once") So, most people read in a higher level fashion and understand just fine. It's really like reading math. When you read 23443 + 54454 * 454534, do you need to work out the computation to understand what this does?
- eru 2y ago> If you read code and don't think about what it's doing, are you really "reading" it? A lot of code doesn't _do_ anything. And you can still read it. Eg I'm thinking about type declarations, or constraint based programming, etc.
- usrusr 2y agoI'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.
- MisterKent 2y agoLots of people doubting this, and saying running === comprehension. Here's an exercise for you: how much did Bill spend at the grocery store? Bill and Tom went to the show store, and Bill bought a black pair of shoes for 23.56. Tom got a pair of red shoes for 40.30. Then they went to the grocery store, and Tom bought a loaf of bread for 3.50 and a gallon of milk for 5.99. Bill also bought a loaf of bread but didn't get any milk. Anyone can tell that answering that specific question uses a different part of the brain than answering "what did tom and Bill do?" And further uses a completely different part than: "modify the story to add a barbershop visit for Bill after the shoe store" which will require parsing the grammar to inject an extra story and keep things consistent. Big picture !== Small details !== Writing !== Editing existing The study feels incomplete if the four types of understanding are not being equivalently asked for both a story and the code.