4 ms·
> APL is generally readable For me it seems that the big disconnect is between people who read code vs. people who pattern match code. I never read a piece of
by vidarh 7y ago
> APL is generally readable
For me it seems that the big disconnect is between people who read code vs. people who pattern match code.
I never read a piece of code start to finish to understand it - I glance at it and expect to see patterns, and then explore based on pattern recognition. I only read details piecemeal.
That doesn't work if there are no clear visual patterns, and I'm extremely picky about syntax and layout of code as a result, not for the code to be readable, but on the contrary, for it to be possible for me to glance at a piece of code and have intuitions about it from seeing shapes of code layout laid out spatially.
I'm not sure if there are reasonable ways of reconciling those two ways of looking at code.
- qznc 7y agoBC: Do you ever look at your own code and think, "What the hell was I doing here?" AW: No, I guess I don't. This is from an interview of Arthur Whitney (AW) who made K, an APL derivative. https://queue.acm.org/detail.cfm?id=1531242 https://queue.acm.org/detail.cfm?id=1531242
- sedachv 7y agoIn my experience working with other programmers, it is very common for people to only learn to visually pattern match on code formatting and stop there. This is the code reading equivalent of functional illiteracy. Using = instead of ==, missing break statements, all kinds of semantically significant mistakes become completely invisible when you look at the shape of the code instead of reading to see what it does. In my experience, people who can only read code by visual layout do very poor code reviews. Another annoying thing, as you point out, is that this makes people hung up on code formatting style to an unreasonably extreme degree. People who only learn to look at the layout literally cannot "read" an unfamiliar layout, which tends to frustrate them, and in a lot of cases seems to hurt their ego, because their conception of themselves as competent programmers is challenged. The way to "reconcile" that is to learn to read code for its meaning.
- vidarh 7y agoWhat you find 'annoying' I find about speeding up processing. I can 'pattern match' code far faster than I can read the text, so the alternative where I read every token is to dramatically slow down my mental processing of the code. To me, reading every token is the functional illiteracy, the way only new learners spell their way through each word of a natural language. I've never seen people make it to the point where they pattern match without being capable of reading the language properly. I slow down and read everything when I need the details, the way I slow down when I read an unfamiliar word, or when I need to ensure I get every detail of a complex paragraph. But most of the time reading at character or even word level is a waste of time. Unless you're dealing with a language like J or K etc. that doesn't lend itself to visual matching. To me that is a fundamental problem with those languages. But I get that people who program them tend to read token by token instead, and if that is what you want to do it needs to be compact.
- sedachv 7y ago> I can 'pattern match' code far faster than I can read the text No you can't. You are getting the impression that you understand what the code does from its shape. This works only when the code does what you already assume it does before you start reading the code.
- vidarh 7y agoYou are jumping to (wrong) conclusions. I very explicitly used pattern matching as distinct from reading because the entire point is that when you pattern match you don't need to understand fully what the code does. It's a faster way to narrow down location in a code base, not removing the need from reading at all. So you are expressing violent agreement even though you suggest "I can't". Yes, it "only" works when the code matches my assumptions. But that is most of the time. On the few occasions I'm wrong I end up reading a bit more code than I otherwise would. But overall I end up spending far less time reading code than if I didn't visually pattern match, because most of the time I only need to carefully read the pieces of code I need to understand the precise details of at that moment. None of us ever read all the code we depend on and understand every aspect of it. We depend on documented functionality and testing to ensure the pieces we don't have time to read - or access to - behaves how we expect, and otherwise code to deal with failures to conform. Reading everything and understanding it only works for tiny programs. Even then recognising patterns helps,the same way we don't spell our way through sentences.