Re:What Makes Code Hard to Read: Visual Patterns of Complexi...
by brabel on Wednesday March 12, 2025 @03:30AM
(#43340692)
Are you really confused when people don't think 3 operations constitutes "long"?
I would guess anyone with half a brain would agree 3 operations is not long, maybe 5 or 6 and you will have many people agreeing, and above that most.
[ Parent
| on HN ]
Re:What Makes Code Hard to Read: Visual Patterns of Complexi...
by aquariusDue on Wednesday March 12, 2025 @07:27AM
(#43342091)
Here's an abomination of my own design in Rust for example:
for (index, node) in nodes
.expect("Error: No blocks for the Body")
.children()
.expect("Error: blocks node has no children")
.nodes()
.iter()
.enumerate()
{
let block = Block::new(node, index);
self.blocks.push(block);
}
Re:What Makes Code Hard to Read: Visual Patterns of Complexi...
by maleldil on Wednesday March 12, 2025 @03:32PM
(#43346845)
Why the for loop instead of mapping the enumerate iterator into Block::new and collect::Vec?
Re:What Makes Code Hard to Read: Visual Patterns of Complexi...
by aquariusDue on Thursday March 13, 2025 @05:33AM
(#43351625)
I lack a good answer other than it didn't occur to me, now I have some code to refactor. Thanks!
Re:What Makes Code Hard to Read: Visual Patterns of Complexi...
by maleldil on Thursday March 13, 2025 @11:37AM
(#43354393)
FWIW, I've had to write similar code when there's some complex "folding" operation. I use map/filter a lot, but fold/reduce/accumulate always seemed harder to understand than a for loop. I also prefer nested loops rather than nested iterators.
Re:What Makes Code Hard to Read: Visual Patterns of Complexi...
by dsego on Wednesday March 12, 2025 @08:06AM
(#43342350)
I agree with the sentiment but I don't think the mocking insult was necessary as per the HN guidelines https://news.ycombinator.com/newsguidelines.html