Live data from Hacker News

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

avraam.dev

31–40 of 63 posts

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

#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 == across the entire program? How about if I introduce this bug twice? Three times? What if I've only heard from a senior dev that triple-equals is "bad"? Or should we test the least-experienced member of the team and let their understanding make the decision for us? What happens when that team member gets more experience, do we lift the ban?

Double- versus triple-equals example is probably one of the most clear cut trade-offs and worth exploring. What about all of the other rules? Double versus single quotes, for example? What about declaring arrays using array-literal syntax versus using the new operator?

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

#32
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…

Most modern writers use fewer commas. It was common in 19th century English to use commas for pacing like in the article. So native speakers are familiar with the style, but I don’t recommend imitating it.

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

#33
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…

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

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

#35
post #18

We really should stop formatting the actual code to make it 'readable'. The editor or IDE should take care of formatting the displayed code to our preferences with a built in linter/prettier. That should end the pointless and annoying discussion.

I read your comment too fast and I almost dismissed it, thinking you were talking, like everyone else, about formatters (gofmt, rustfmt). But what you are saying is much more interesting, as we are all allowed to keep our preferences. Is there any major editor/IDE working on this? You are making me miserable, now that I read this I can't live with just formatters anymore :D

I mean, that’s the most common argument on why tabs are better the spaces. It’s also an argument I tend to be sympathetic too.

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

#36
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…

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

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

#37
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 threequal operator aside, my experience is that none of these decisions really matter in themselves. What is far more important is agreement and consistency. Use the same style everywhere, enforce it automatically, don’t bikeshed over it, and get on with doing actual things that matter.

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

#38
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…

[deleted]

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

#39
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…

Safety pretty much always comes at a cost (of some kind) Even if that cost is just being forced into a more restrictive model. In some cases this actually limits what you can do, but in the case of JS's === it's about doing what the programmer is expecting. I think many people would agree that JS casts types too liberally at times [1], and using === is a good way to avoid the confusion that can cause.

Other language features cause other confusions.

Quotes generally boil down to arguments about escaping, and have good reason for existing. Having a rule for when to use what quotes should be pretty inferable from when you need to use what quote to escape the data in question.

New array vs literal is more a pure aesthetics issue, and I can only really say, choose whatever you think the majority of people would read faster. Don't be different just to be different, and move on.

1: https://www.destroyallsoftware.com/talks/wat

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

#40

Earlier quoted context omitted.

I worked in a place where my team lead wanted us to vote on a technical decision. I found that unfair because half of the team was at a junior level.

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.
Post reply on HN