On Tue, Feb 15, 2011 at 3:11 PM, Raoul Duke <rao...@gmail.com> wrote:
> you might also sorta be saying that there are lots of different kinds
> of polymorphism in programming, and that we need to know when to/not
> use any given form of it, which i'd agree with :-)

We're probably in violent agreement, yeah :)

I think one of the big sticking points for a lot of folks raised on OO
- and Java in particular - is moving to a mental model where types are
"not needed" and adopting, for example, duck typing as a way to
achieve polymorphism without types.

When I first got into FP it was via languages that either had no types
or only very weak types. When I first got into OO, it was via C++
which lets you abuse the type system in interesting ways (and of
course you have full generic programming via templates so type-checked
duck typing is essentially possible :) In '97, I got into Java and,
whilst I liked the clean syntax and straightforward approach to most
everything, I found the type system very restrictive (and still do).
Since around 2001 I've been doing nearly all of my programming in
scripting languages that have very weak type systems and when I'm
writing OO in those languages, I tend to forego type checking in a lot
of places so I don't have to introduce interfaces or base classes that
my own classes then have to implement / extend, unless there's
specific reasons for using an explicit hierarchy of types (which I
find is rarely the case).

If your domain model can be represented by a simple vector / map /
set, then you have a very rich set of tools (in Clojure) to operate on
your domain model. If your domain model is represented by fixed types,
you have to write all sorts of wrapper functions to be able to apply
those operations. One of the nicest things about Clojure in this area
is that once you have a basic set of operations defined on your simple
data structures, it's easy to incrementally wrap it up in as much of a
typed API as you want via records, protocols and macros etc to create
an aesthetically pleasing façade around the core functionality.

Hope that makes sense?
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

-- 
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

Reply via email to