Hacker News new | ask | show | jobs
by marta_morena_23 2275 days ago
"Don't spend much time on making your code look nice"...

Well, thanks a lot. You just made your code much harder to read, improve, change and check for correctness. This is actually a self-contradiction. If the code changes often, then its even more important to make it "look nice". This is something that beginner programmers don't get on several levels: Nice code

* can be reviewed more quickly (broadcasting effect)

* can be checked for correctness much more easily

* is pleasant to work with

* can be changed more easily

* can often even compiled into more efficient machine code

The reason why beginners (and this is not about time invested! Many programmers still are beginners after 30 years in the field) think code doesn't need to look nice is mostly because

1. They don't consider that most of the cost of code comes from maintenance. Writing it is really A FRACTION of the time people will spend with your code over time.

2. They don't consider that creating bugs is one of the most expensive parts of software development.

3. They don't consider that code is read far more often than it is being written.

4. They are simply not ABLE to produce good code and doing so would take them a lot of time.

Now giving the advice to not focus on good/nice code is a recipe for staying a beginner for the rest of your life and making every project your work on a nightmare for everyone else involved.

2 comments

FYI - the author of the blog post created https://prettier.io/ which is a very opinionated (automatic) javascript code formatter. His assertion about "nice code" was that you shouldn't spend effort on making it look nice. Let a tool do that for you.

Personally I dislike some the default formats that prettier have chosen but if it prevents a single minute of discussion on my team about how the should be formatted, it pays dividends over time. And eventually we, as humans seem to get used to just about anything.

While I agree, what they actually said was "if you spend most of your time making your code look pretty", which is obviously too much time, IMO. There needs to be balance.