3 ms·
because some gem developer wanted to be clever Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever a
by skylan_q 10y ago
because some gem developer wanted to be clever
Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?
-Brian Kernighan
https://en.wikiquote.org/wiki/Brian_Kernighan https://en.wikiquote.org/wiki/Brian_Kernighan
I love Ruby. I hate Rubyistas that make code that's impossible for others to read or comprehend. I find the rails source actually pretty good here.
No it doesn't. What is even going on in there?!?
LOL didn't you read lines 385-472 of some_ruby_interpreter_file.c on MRI version 2.2.1p347?
...
When we're looking to write programming languages to make our ability to program more concise and powerful, clever tricks and hacks defeat the purpose. Those belong in the 90's and earlier.
- catnaroek 10y ago> clever tricks and hacks defeat the purpose. There is nothing wrong with clever tricks (would you dismiss HAKMEM?), as long as they follow from simple principles that can be applied systematically. Alas, everything is ad-hoc in Ruby-land.
- collyw 10y agoI moved from Perl to Python a few years ago. While I preferred the cleverness that Perl allowed me to do, I often found that I would shoot myself in the foot by being too clever too early. Python feels more restrictive (in that it doesn't encourage you to use fancy tricks - even though they are often available). But I feel I write clearer more maintainable code.
- catnaroek 10y agoYou're right that the “clever” tricks that dynamic languages allow (and, to varying degrees, encourage) make programs less easily comprehensible for humans and machines alike. However, this is an indictment of dynamism, not cleverness. As an example of why clever tricks aren't always a bad thing, Haskell's lens library is essentially a big bag of tricks for manipulating compound data structures. However, lens differs from your typical dynamic metaprogramming library in significant ways: (0) Its design actually follows from a few, simple and very general principles. So you don't need to memorize the entire lens API; instead, you can use the principles to discover the API. The only other thing that offers a similar degree of discoverability is IntelliSense, but IntelliSense for dynamic languages is typically not as good as it is for languages like Java and C# - especially when dynamic metaprogramming is used! (1) You don't need to resort to arcane reflection hacks to figure out what's going on in lens code. Parametricity (free theorems) and type class laws (provided that you follow them, and this is usually very easy to check) tell you everything you need to know. (2) Since lenses, traversals, prisms, etc. are ridiculously general, the time and effort you invest in learning them pay off over a wider range of projects.