Live data from Hacker News

It's all Greek to me: Thoughts on code readability and aesthetics

avraam.dev

41–50 of 63 posts

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#41
post #31

I'm more troubled that we might be banishing perfectly good features for the flimsiest of reasons. Take, for example, JavaScript's double-equals == versus triple-equals === comparison operators. (I already know you have a strong opinion on these!) The language designer saw fit to include both. Now, if I introduce one bug where I need to use === explicitly instead of ==, should I advocate for a ban the use of == acros…

> The language designer saw fit to include both.

=== wasn't introduced until ECMAScript 3 in 1999, originally there was only == when the language was created in '95.

The accepted wisdom is to prefer the newer === in the interest of clarity and consistency. With ==, it's easy to forget about one of the types it overloads (e.g. string vs. number) when making changes to existing code, and correct-looking code may behave unexpectedly for one of these types.

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#42
post #15

OT question from non-native speaker: those commas that mimics speech pauses are syntactically acceptable in English? (Or Greek?) > In Greece, we have a similar phrase [...] > Readable code, is a piece of code [...] > In Germany, they say [...]. > In 16th century, in the Habsburgermonarchy [...] > [...] but let me, tell you a secret: [...] > Readable code, is a piece of code [...] (I'm from Bohemian village where we w…

A comma separates clauses that make grammatical sense on their own, or at least where one of them does. So "In Greece, we have a similar phrase" is fine, because "we have a similar phrase" is complete in itself. Whereas "Readable code, is a piece of code" is not correct, because "is a piece of code" is not complete - it's missing a subject. Likewise, "In Germany, they say" and "In 16th century, in the Habsburgermonarchy" are fine, but "but let me, tell you a secret" is not.

As a native speaker, i can understand those sentences well enough, but they look wrong, and i wouldn't expect a fluent native writer to write them.

I have a Greek friend who is similarly scattershot with commas (eg "Hey send me, the photo of your office!"). I wonder if this comes from mapping some feature of Greek sentence structure onto English?

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#43

>Next time we have a conflict with a colleague on what is “readable”, let’s ask ourselves “Am I talking about understandability or I am talking about aesthetics?” This is why I'm in favor of auto-formatters like Black for Python. Nobody really likes it, but nobody really hates it either and you get used to it. What this does is that it completely removes the style component of the discussion, leading to better and mo…

I'd say the main reason for strict formatting is the organizational one: when you really need for the same file to be edited by many people and not turn into a mess. Otherwise, it may be convenience, as I don't have to maintain consistency manually. May be, because in languages where there are multiple syntactic ways to do things (Python, JS), I want flexibility in emphasizing things. (Even if I don't overuse it.) It…

    languages where there are multiple syntactic ways to do things 
Python zen says: the should be one (and preferably only one) obvious way to do it. Perl might fit your description better.

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#44
post #36

Earlier quoted context omitted.

1, 3 and 4 are acceptable but unnecessary, and would probably be frowned upon by English teachers. The other examples are incorrect.

> 1, 3 and 4 ... As we’re talking about comma usage in English, it may be worth noting that there is wide disagreement about the Oxford, Harvard, or serial comma[1] in lists; no matter which choice you make, it will look wrong to many people. [1] https://en.m.wikipedia.org/wiki/Serial_comma

But that's a question of style and tradition, not correctness. "I, went, home" is incorrect, no matter if you adhere to Chicago or Oxford.

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#45
post #40

Earlier quoted context omitted.

If you can't explain why your idea is good to a junior engineer, voting is the lead of your problem. If you mistrust half your team as a rule, how can you trust anything to get done well?

It's hard to explain to junior engineers why chasing fads is a bad idea. Why boring technology is often the best choice. That's only something that most people figure out with experience.

Seniors often don’t like doing new things for the simple reason that they already know how to do things a different way and they don’t feel like learning something new.

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#46
post #15

OT question from non-native speaker: those commas that mimics speech pauses are syntactically acceptable in English? (Or Greek?) > In Greece, we have a similar phrase [...] > Readable code, is a piece of code [...] > In Germany, they say [...]. > In 16th century, in the Habsburgermonarchy [...] > [...] but let me, tell you a secret: [...] > Readable code, is a piece of code [...] (I'm from Bohemian village where we w…

While overall the article is well-written (grammatically), the author uses too many commas in a number of sentences. I wouldn't say that their comma use is "unacceptable", but it's not proper. An editor would remove many of them, and an English teacher would ding them if grading it.

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#47
post #19

In our world of Ship It/Get Shit Done/Move Fast Break Things, code readability doesn't stand a chance. I find there's little allowance for time spent thinking about the poor sucker who has to read my code, lest the sprint burndown chart suffers. That's why code linters and formatters are so important. When applied correctly, it's the closest we can come to having the entire codebase looking like it was written by one…

This might be true at some shops, but if so, they're doing it wrong. You can move fast and still maintain code readibility. No matter how fast you're moving, code shouldn't be accepted into a shared repository unless it meets minimum standards. A well-functioning agile team cuts corners by not over-engineering, by not waiting for elusive completion, by releasing minimally-viable products that provide user value to get feedback and drive further development. Even breaking things is ok, but sloppiness is not. When you push out crap code to meet an arbitrary velocity target, you're just digging an inescapable hole of tech debt. If you're not thinking about the poor sucker who has to read your code, you're doing it wrong.

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#48
post #42
post #15

OT question from non-native speaker: those commas that mimics speech pauses are syntactically acceptable in English? (Or Greek?) > In Greece, we have a similar phrase [...] > Readable code, is a piece of code [...] > In Germany, they say [...]. > In 16th century, in the Habsburgermonarchy [...] > [...] but let me, tell you a secret: [...] > Readable code, is a piece of code [...] (I'm from Bohemian village where we w…

A comma separates clauses that make grammatical sense on their own, or at least where one of them does. So "In Greece, we have a similar phrase" is fine, because "we have a similar phrase" is complete in itself. Whereas "Readable code, is a piece of code" is not correct, because "is a piece of code" is not complete - it's missing a subject. Likewise, "In Germany, they say" and "In 16th century, in the Habsburgermonar…

I am Greek and we don't use that many commas. Definitely not in this way. I think the Greek language is also not as flexible with comma placement as perhaps English is.

What I've noticed is that some people never learned how to use them. They just write a sentence (or a whole essay) and generously sprinkle some commas afterwards, normally wherever they would make a short pause. I've seen this with colleagues from Germany, Greece, Russia and the US.

Re: It's all Greek to me: Thoughts on code readability and aesthetics

#50
post #36

Earlier quoted context omitted.

1, 3 and 4 are acceptable but unnecessary, and would probably be frowned upon by English teachers. The other examples are incorrect.

> 1, 3 and 4 ... As we’re talking about comma usage in English, it may be worth noting that there is wide disagreement about the Oxford, Harvard, or serial comma[1] in lists; no matter which choice you make, it will look wrong to many people. [1] https://en.m.wikipedia.org/wiki/Serial_comma

Well, it will look jarring, annoying, and wrong to those people who are wrong.
Post reply on HN