5 ms·
I find Ruby really close to CL/Clojure with regard to happily not using design patterns. I usually write pure code and use long method chains -- it mimics the U
by kunley 16y ago
I find Ruby really close to CL/Clojure with regard to happily not using design patterns. I usually write pure code and use long method chains -- it mimics the Unix paradigm with small tools connected with pipes. I rarely write proper classes actually and I'm happy with it.
If anobody is interested, I described this style of coding here http://inthephase.org/partial-function-application-in-ruby http://inthephase.org/partial-function-application-in-ruby
I also think that the oo-like call chain:
data.transform1.transform2...transformN
is better readable than:
transformN ...(transform2(transform1(data)))
because the order is transformations is not reversed, so one
sees what's going on with the data in the first pass as he reads, there's no need to mentally reverse the chain. The expressiveness is the same, but the readability of the former wins IMO.
- jpr 16y agoI think the oo-like call chain is nicer when you don't have any arguments and stuff doesn't nest. The difference of static vs. instance methods also makes it slighly more complicated to comprehend. I think overall the simplicity of Lisp-style nesting wins when the expressions get more complicated.
- kunley 16y agoGood point -- instance methods make it all a bit dirty. I usually use some meta trickery to turn toplevel methods, which can be mentally eq to defuns, into oo-chainable stuff. Well I suppose I just should clean this code and put an example on a blog.
- prospero 16y agoIn Clojure you can rewrite the second example as (-> data transform1 transform2 ... transformN). Macros are a hell of a thing.
- deleted 16y ago[deleted]
- deleted 16y ago[deleted]