It might be worth mentioning that, ultimately, python class instances are 
syntactical sugar built around an internal __dict__. It gets twistier, 
since classes are also instances of the base class object.

It would be tricky (though I've seen an example...maybe in Joy of Clojure? 
I think the author's conclusion was that it was an interesting experiment, 
but not worth doing in practice) to implement inheritance using clojure 
maps.

For me, the conceptual difference has been that it's better to just write 
functions that work on simple data structures, rather than tying a few 
together into a unit that only work on a single data structure (plus its 
derived classes). Clojure's emphasis on functional purity is another major 
piece of this puzzle.

Unit testing is one thing that becomes much easier with this approach.

I deal with a ton of python code that has tests built around dozens of mock 
objects mimicking things like database records from an ORM. And then we 
mock out a few low-level HTTP calls in base classes so the class instances 
we're trying to test in isolation don't break when we run the tests with no 
web server to call. Then someone refactors the code, and all the tests 
break because they're tied to a specific package/module structure.

By contrast, if you have your business logic in one set of pure functions, 
and you keep your side-effecting parts well isolated on the fringes of your 
system, you don't need any of that. Just call the business logic function 
with appropriate values and double-check the results.

You absolutely can write python code that way. But your pythonic colleagues 
will hate you for it.

Hope that helps,
James

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/c570d4aa-df51-47a1-bbdf-1efd61c5c7fa%40googlegroups.com.

Reply via email to