Registered: Sep, 2005
Re: Seeking the Joy in Java
Posted: Aug 24, 2006 11:48 AM
> Good points. But what are the alternatives? I can think of
> 1. Forget about
each in collections.
> 2. Start from scratch, and forget about code that creates
> old-style collections.
> 3. Require that users write lots of wrapper code that
> transforms old style into new style collections.
> I think (1.) is giving up, and (2.) is impractical.
> Remains (3.), creating wrappers. That's what's often done
> in practice, but it's very cumbersome. It gives you the
> kind of verbosity that often hides rather than clarifies
> meaning. So one way to regard implicits is that they are
> automatically generated wrappers.
I like this idea of implicits and I am warming up to them more and more. They seem to also allow a 'bolt-on' approach to OO. For example, I'm a big proponent of mimimalist interfaces in Java because they are much easier to implement (which is why we should be creating interfaces: so people can implement them) but the obvious trade-off is that they may take more effort to use.
The implicit feature (I think) solves this. It allows me to create my minimalist interface and provide bolt-ons for the convienience features. Even better, (I think) it allows anyone to provide sets of convienience methods for specific needs without procedural style helper classes.
> With the right tool support, this could be practical also
> for inexperenced users. For instance, we could have a mode
> in the IDE which shows automatically generated implicits
> in the source. That would remove the voodoo and put
> implicits on the same level as, say, refactorings. I'll
> see whether we can that build the Scala Eclipse plugin.
When you say 'automatically generated' you mean the additions to a class provided by the implicit wrapper, right? Implicit objects are not being created automatically or anything are they?
> > The other thing I think you can address right now it
> > documentation. One of the things I found really
> > frustrating was that the Ord class described in the
> > tutorial does not exist.
> The tutorial was out of date with the API in that respect.
> Thanks for pointing this out!
I also seem to recall that the variance specified in the API was not what was actually in the definition of Ordered but this could be a misunderstanding on my part.
I guess the real issue with implicits isn't the feature but making the value well known and understood. I don't think keeping features from people that we don't trust is a good solution.