3 ms·
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 parti
by chongli 2y ago
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.
- eru 2y agoSure, but your human doesn't necessarily gain that sense of purpose by executing the function in their head. More likely, they are looking at the name of the function and its arguments and return values first, and work from there. I wasn't arguing here that any existing compiler shows a human level understanding of code. Just that there are many ways to understand code, and executing in your head is but one of tools in your arsenal.
- nextaccountic 2y agoHumans 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?)
- eru 2y ago> 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. Well, it also depends on whether the suspect that the code has a bug. Normally, we try to understand code by taking shortcuts through function names and structure, and fill the rest of in via pattern matching. But if I suspect that a piece of code has a bug, I work hard to turn off these higher levels and concentrate on what's actually written.