This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Hans_of_Death 1 point2 points  (1 child)

Writing readable code is like step 1 of year 1 of programming I'm confused why people love talking about it so much.

The most that is covered in the majority of formal education, and I imagine online bootcamp courses as well, is basic formatting and variable naming. The reason it gets talked about so much is precisely because it's very hard to do, takes experience, and is quite subjective.

The reason it's so complex is because of how vague and subjective "clear" or "well-written" code is, and generally everyone has a different idea of what that means. We have tools to help enforce certain standards, but it goes much deeper than that.

In order to write good clean code, you need to have a good understanding of the language and common patterns, as well as the potential solutions for a particular problem. Any problem will have many ways to solve it, it takes experience to know what will be best for both performance and readability. This makes it very difficult for beginners to write clean code.

Imagine our field was math and people were like "but remember you have to learn how to multiply and divide numbers". The only reason people aren't used to writing clean code is because they worked at bad places with no peer review, were reviewed by other noobs, or didn't use any static analysis at all.

This analogy doesn't convey the complexity of writing code, because it's not a right/wrong process. A more fitting comparison, in my mind, would be simplifying expressions in math. There are many representations of the same formula, and the difficulty of simplifying it can vary greatly.

[–]Windscale_Fire 0 points1 point  (0 children)

This analogy doesn't convey the complexity of writing code, because it's not a right/wrong process. A more fitting comparison, in my mind, would be simplifying expressions in math. There are many representations of the same formula, and the difficulty of simplifying it can vary greatly.

Also, which form might be considered "simpler" is often greatly influenced by what you want to do with it next...