Re:Code Quarterly's Interview with Rich Hickey
by swannodette on Thursday June 09, 2011 @08:08PM
(#2639249)
> and could be worked around trivially by making every object respond to a dictionary protocol. This would give you the best of both worlds.
You do realize that's the approach Clojure takes right?
Re:Code Quarterly's Interview with Rich Hickey
by cageface on Thursday June 09, 2011 @10:32PM
(#2639555)
The whole point of OO is that you don't want code reaching into the internal member data of the object. The real reason that algorithmic code reuse is so difficult in C++ and Java is that they lack usable first-order function literals.
Re:Code Quarterly's Interview with Rich Hickey
by DanielRibeiro on Friday June 10, 2011 @09:53PM
(#2642986)
Not to mention that lack of structural typing and Mixins make it even harder to actually have reuse. Dynamic languages like Python and Ruby solve this beautifully, and so do Go and Scala on the more static type side.
Re:Code Quarterly's Interview with Rich Hickey
by kenjackson on Thursday June 09, 2011 @07:49PM
(#2639206)
Don't most mainstream languages now give you this?
I think Javascript, C#, Ruby, Python give you this. C++ and Java don't.
And as you say, you do lose a fair bit giving this away.
Re:Code Quarterly's Interview with Rich Hickey
by swannodette on Thursday June 09, 2011 @08:14PM
(#2639263)
No all those languages suffer (except JS) from the fact they don't give you uniform access. Consider the different forms of access for dict types, array types, object types in said languages.
Re:Code Quarterly's Interview with Rich Hickey
by kenjackson on Thursday June 09, 2011 @08:18PM
(#2639274)
I have to admit that this distinction seems really minor. But maybe I'm missing something here. I'd love to see an example if anyone has one.
Re:Code Quarterly's Interview with Rich Hickey
by swannodette on Thursday June 09, 2011 @09:23PM
(#2639416)
(get "foo" 0) ; \f
(get {:foo 'bar} :foo) ; bar
(get #{0 1 2} 1) ; 1
(get [:a :b :c] 1) ; :b
(def path [0 :foo 1])
(get-in [{:foo "bar"} 1 2] path) ;\a
Being able to deal with data generically in a first class manner is very, very useful. You can only get this in all the languages you've mentioned (including JS) w/ more or less custom code writing.
But switching to dictionaries wholesale for this reason seems to throw out the baby with the bathwater. The loss of abstraction is real, and could be worked around trivially by making every object respond to a dictionary protocol. This would give you the best of both worlds.