What makes code hard to read: Visual patterns of complexity (2023)
21–30 of 383 posts
Re: What makes code hard to read: Visual patterns of complexity (2023)
#22Re: What makes code hard to read: Visual patterns of complexity (2023)
#23Kudos to seeinglogic for trying to quantify that “readablity” is. We need a lot more of this. (I feel like the most common definition of readability in use today is “readable to me“.) I have a half-baked thought that we could find the actual dimensions of readability if we gave a test to a very large group of people and asked them to pick a sentence that describes what the code does. Each question would be timed. The…
Yes one of the core challenges here is that we learn to read code. So what you learn to read and write shapes what you find readable. And lots of factors shape what you learn to read and write, including what you are trying to do, who you’re doing it with, what besides coding you knew how to do ahead of time, what other languages you know, etc. One stark possibility is that a lot of “readability” concerns after the l…
Re: What makes code hard to read: Visual patterns of complexity (2023)
#24http://literateprogramming.com/
For a book-length discussion of this see:
https://www.goodreads.com/book/show/39996759-a-philosophy-of...
previously discussed here at: https://news.ycombinator.com/item?id=27686818 (and other times in a more passing mention --- "Clean Code" adherents should see: https://news.ycombinator.com/item?id=43166362 )
That said, I would be _very_ interested in an editor/display tool which would show the "liveness" (lifespan?) of a variable.
Re: What makes code hard to read: Visual patterns of complexity (2023)
#25I love dostoyevsky and wodehouse, both wrote very well, but also very differently. While I don't think coding is quite that open a playing field, I have worked on good code bases that feel very different qualitatively. It often takes me a while to "get" the style of a code base, just as a new author make take a while for me to get.
Re: What makes code hard to read: Visual patterns of complexity (2023)
#26Earlier quoted context omitted.
That's very one-dimensional. It's usually easy to tell what the code does, but what's hard is to modify or add functionality to it. And this is because of various levels of abstractions that hide how things are interconnected.
Poor abstractions. Good abstractions make it easier to change things, by decomposing the code into cohesive pieces with low coupling so that you can swap them out and having to think about the surrounding pieces beyond their interfaces. A good interface is small and logical.
Re: What makes code hard to read: Visual patterns of complexity (2023)
#27Earlier quoted context omitted.
> If a method is long to read from top to bottom, the answer isn't always splitting it into 5 smaller ones, sometimes life just has inherent complexity. Yes! This. I find it much easier to parse a long function where I can scroll down it and just read it top to bottom, then having a function which calls out to lots of other functions and I'm jumping around the code base, back and forward. Just reading the long functi…
> [than] having a function which calls out to lots of other functions and I'm jumping around the code base, back and forward. i agree with longer functions and less jumping around, but there's also some nuance i find. I sometimes find converting a complicated multi-line condition into something like the below is much easier for me to read, so long as the function is named in a clear way and the function definition is…
something_is_valid = something > 0 and something != foo and something > bar
if something_is_valid:
# ....
It achieves the same thing without needing to scroll.Re: What makes code hard to read: Visual patterns of complexity (2023)
#28There is a (large, I believe) aspect of good code that is fundamentally qualitative & almost literary. This annoys a lot of computer programmers (and academics) who are inclined to the mathematical mindset and want quantitative answers instead. I love dostoyevsky and wodehouse, both wrote very well, but also very differently. While I don't think coding is quite that open a playing field, I have worked on good code ba…
Doesn't matter how it looks. If its not possible to understand what a function accomplishes within a reasonable amount of time (without requiring hours upon hours of development experience), it's simply bad.
Re: What makes code hard to read: Visual patterns of complexity (2023)
#29Earlier quoted context omitted.
> the answer isn't always splitting it into 5 smaller ones To someone who just read a book about it, it is. I've heard this called "rabbit hole" programming; it's function after function after function, with no apparent reason for them other than the line count. It's maddening.
I think the whole Uncle Bob clean code movement has a lot to answer for.
...
#ifndef foo
break;
case SomeCondition:
doSomething().
#endif
moreCode();
break;
I'll take the worse uncle Bob can throw at me over that mess.Re: What makes code hard to read: Visual patterns of complexity (2023)
#30I my view, code complexity is best expressed in the size of it's syntax tree, with maybe an additional term for the number of unique nodes. The real mistake here is the assumption that local reductions in complexity make a meaningful difference to overall complexity. Small local decreases in complexity may guide you towards the local minimum of complexity, but will never substantially change the complexity of the cod…