Hacker News new | ask | show | jobs
by seniorsassycat 2654 days ago
'idiomatic' vs 'best practices'?
2 comments

Thanks for that! "Idiomatic" is such a better word for describing what you actually want. "Best practices" implies that we know for sure that the practice will result in a better outcome. This is almost never true because programming is a very situational activity requiring a lot of judgement calls. If you turn off your brain and apply "best practices", the result is almost always horrific.

However, "idomatic" means writing in a way that other people are likely to be able to understand. That's a great goal! Often it's worth it to write code that isn't quite as good for the situation if it is more idiomatic. It's a judgement call still, but it's still important to know what is and isn't idiomatic so that you can make that judgement call.

My inner Northcote Parkinson sort of triggers on 'best practices'. Best tends to imply that all the other ways to skin the cat are 'bad.' Which is likely objectively untrue.

Idiomatic is more neutral and means basically just do it the way everyone else tends to. The real advantage to that is you generally avoid pitfalls and annoying other coders.

They can mean very similar things so that the question could be:

How to learn idioms when you have no one to teach you?

To which I think we land on the recommendation: seek good examples and mimic them. Trouble is finding them.
It is. I work in c# and if we take idiomatic to be how most devs write c#, then idiomatic c# is garbage.
But the question still remains... how do you determine what "good examples" are?