loading...

re: HackerRank Is Teaching You to Write Terrible Code VIEW POST

FULL DISCUSSION
 

I agree for the most part. I'm a huge advocate for responsible coding. Shoot, a huge part of Dead Simple Python is dedicated to it. More on coding challenges and good practice in a moment...


With that said, I think there is an exception for competitive code golfing (which I usually do over on Codingame instead of HackerRank), which I've found to be beneficial in a different way:

  • The goal of making the code as compact as possible forces me to understand the underlying processes and alternative ways of doing things. Brute-force seldom wins in length-based code golfing.

  • The same processes you should follow to make your code smaller in length-based code golfing are the same processes you would use in real world refactoring, although the outcomes are different. You always start by writing a simple, straightforward solution and verifying it works, and then you begin rewriting it piece-by-piece until it's a small as possible.

  • Time-restricted code golfing hones your ability to distill human thought (the prompt) into computer logic quickly and efficiently. In practice, this has helped me write better code in real world scenarios; it takes me less time to work out the logic, so I have more time to pay attention to matters of design and good practice. (After all, don't we usually skip good practice because of time?)

These unique benefits justify terrible variable naming practices in that specific context, so long as one remembers to use good names elsewhere.


None of that is to invalidate your concerns, of course. One should be aware of the profound differences between code golfing and real-world coding, and HackerRank doesn't always make that difference clear. Given its lack of time constraints, and the fact it isn't formal length-based code golfing (as far as I know), there's no reason why you shouldn't apply good practice to your code there! I literally always delete HackerRank's default code.

Personally, I do prefer Codingame, as it has proper multiplayer code golfing which is separate from the standard coding challenges. Their default code is almost always better, too.

 

Thanks for making me aware to Codingame. Didn't realize that was a thing.

code of conduct - report abuse