5 ms·
> 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 princip
by catnaroek 11y 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 11y 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 11y 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.