Ask HN: What's your opinion, implicit vs. explicit?

2 points by RUG3Y ↗ HN
The Zen of Python states "Explicit is better than implicit."

In [this article](http://www.paulgraham.com/popular.html), PG states that "Anything that can be implicit, should be." The context is about the brevity of code.

In general, I'm a fan of brevity, but I also dislike overly complicated code - by that I mean, code that is difficult to read. I'd like to hear opinions and ideas about how you balance these opposing ideas when you're writing code. My personal context is the Python language.

5 comments

[ 3.7 ms ] story [ 18.0 ms ] thread
Explicit, explicit, explicit. I'll take readability over brevity any day (and twice on Sundays) and I believe relying on implicit behavior and various forms of "black magic" hurts readability. Saving a few keystrokes for the sake of saving keystrokes is a false economy if it makes the code harder to read for the next poor sap who comes along and has to read it (which, guess what, may be the poor sap who wrote it in the first place!).
I agree with you, but I'm currently dealing with a Python codebase that is very verbose and is written in classes with 5 - 6 levels of inheritance - it's a nightmare. This type of code organization couldn't be considered "explicit", could it?
"Explicit" isn't necessarily "verbose", just clearer. Sometimes this means bubbling more details to the top in the same amount of code, like taking surprising side effects out of a complex function and calling them more directly.
Thanks for sharing your thoughts.
Code is read much more often than it is written. I'll take something verbose and explicit over something magical and brief any day of the week. It's why I'm preferring Elixir to Ruby for any side projects. Elixir is so explicit about how everything works. There's little magic happening behind the scenes.