News for hackers. Stuff that matters.
Re:What Makes Code Hard to Read: Visual Patterns of Complexi... by davidw on Tuesday March 11, 2025 @01:46PM (#43335117)
Without syntax highlighting, "book.author for book in books if book.page_count > 1000" requires a lot more effort to parse because white space like newlines is not being used to separate things out.
Re:What Makes Code Hard to Read: Visual Patterns of Complexi... by syklemil on Tuesday March 11, 2025 @03:49PM (#43336356)
You've had some answers already, but I also think this is a good argument for syntax highlighting. With tools like tree-sitter it's pretty easy these days to get high quality syntax highlighting, which allows us humans to receive more information in parallel. A lot of the information we pick up in our daily lives is carried through color, and being colorblind is generally seen as a disability (albeit often a mild one which can be undetected for decades).

Syntax highlighting in print is more limited because of technological and economic constraints, which might leave just bold, italics and underlines on the table, while dropping color. On screens and especially in our editors where we see the most code, a lack of color is often a self-imposed limitation.

Re:What Makes Code Hard to Read: Visual Patterns of Complexi... by davidw on Tuesday March 11, 2025 @03:53PM (#43336385)
That's not the point though. If you need the syntax highlighting to quickly make out the structure, perhaps the visual layout is not as good as it could be.
Re:What Makes Code Hard to Read: Visual Patterns of Complexi... by syklemil on Tuesday March 11, 2025 @04:00PM (#43336438)
I consider syntax highlighting to be a part of the _visual_ structure. Visibility is more than just whitespace and placement!
Re:What Makes Code Hard to Read: Visual Patterns of Complexi... by nicwolff on Tuesday March 11, 2025 @03:14PM (#43336013)

    authors_of_long_books: set[Author] = {
        book.author 
        for book in books 
        if book.page_count > 1000
    }
Re:What Makes Code Hard to Read: Visual Patterns of Complexi... by xen0 on Tuesday March 11, 2025 @02:18PM (#43335455)
Set comprehensions are normal in mathematics and, barring very long complex ones, I find them the easiest to parse because they are so natural.

They're just a tad more verbose in Python than mathematics because it uses words like 'for' and 'in' instead of symbols.