[Prev][Next][Index][Thread]

Re: Newbie question: Dylan and OOP?



Doug Ball wrote:

>I am a Dylan new comer and have not yet written any large applications
in Dylan.  
>Do those of you who use OOP in other languages find Dylan’s
>encapsulation of data and methods separately is helpful or that it
degrades OOP?  

Well, C++ has "friend", and whilst it used to be sneered at it's now
recognized that good friend declarations help encapsulation. Why do I
mention this? Well, friend is used to get methods that "belong to" other
objects access to the internals of a C++ object. C++ programmers tended
to avoid this as it violated their idea of encapsulation, and you got
some pretty strange code as a result. In Dylan this is a non-issue, as
methods don't belong to objects or objects to methods. You get more
freedom in mapping the problem domain and you don't find yourself
constrained so much by having to fit everything into abitrary objects.
After an initial Java/C++ culture shock, I now find Dylan's approach
much cleaner and more powerful: just think of two hierachies, one of
objects, one of methods.

Multiple return values are good, too. :-)

>For me it seems a lot harder to do OOP but I am new to Dylan.  I would
be very 
>curious to hear your perspective, maybe I am looking at it wrong =)

Well, you can program Dylan functionally or procedurally if you like.
It's a very flexible language.
I'm not suprised you find OOP hard. Mainstream OOP isn't easy or
natural. The closest language I've found to a natural, end-user language
is SQL (!). That said, Dylan is much better than the C-syntax family of
languages for OOP (IMHO) because:

- You don't have trouble with getting objects to do things they weren't
designed to. You can make methods that use any object you like (as long
as it's not sealed off) even if you've never seen the implimentation of
that object.
- You don't have to artificially package methods into utility classes.
- You don't have to use "utility structs" to return data as you can
return multiple values.
- Dylan's package/namespace system is simpler and more powerful than C++
or Java's by a long stretch.
- Dylan's macro system is more powerful and safer than C++'s, and people
are starting to realize there are things that macros are useful for
again after years of friend-style neglect.

To see some good Dylan code examples, take a look at:

http://www.gwydiondylan.org/learning.phtml

, especially:

http://devworld.apple.com/dev/techsupport/develop/issue21/21strassman.html

- Rob.

-- 
Rob Myers - http://www.robmyers.org/   
"Look out honey 'cause I'm using technology,
 Ain't got time to make no apology" - Iggy Pop.


Follow-Ups: References: