Ad
  • Custom User Avatar

    "not be easy for the average joe coder to reason about"

    The catch here is, of course, that while you code is intended to be read by somebody, it's not for everybody, and just like backwards compatibility, you have to cut off at some point. If someone's pulling "average joe" as an argument to readability, that usually means they can only recognize C-like code, which are written like a step of instructions for monkeys to execute.

    The good thing about JS (and various other programming language which has caught up in this aspect) is that you can write in functional syntax and doesn't need to write for loops again, and in most cases you'll only end up like within twice the time taken for for loops, while having a big benefit: you're preserving the program's logic content, rather than its sequential content. Programmers want to know the intent and logic of some code, not the steps of them (that's just implementation).

    Though, yeah, golfing and removing all spaces are probably a bit too much for some people. Even then, the logic of the program is there, and you can easily use tools like JSbeautifier to unpack the golf. After learning how to write code functionally, reading these are actually pretty easy (unlike C-like code, they have no bounds in possible ugliness! :P)

  • Custom User Avatar

    I'm somewhat of a noob and I mean no criticism. Are golf solutions REALLY considered "Best Practices"? Is it just my inexperience or would this solution (as elegant and concise as it is), not be easy for the average joe coder to reason about. I'm willing to accept that it IS my lack of experience but I would like the comments of others. Thanks!