Well, all I can say is: Check out Project Lombok :)

Even properties is a vague term. Which pick-n-mix from this selection
of properties (heh) of what folks tend to mean when they say
"properties" are you interested in:

1. Simple syntax, or even completely automated, generation of getX and
setX(T) methods for any declared field.

2. Translating "x.foo = y" into x.setFoo(y), and the same for getter
access, either completely automated, or only if 'foo' is marked as
property somehow.

(Technically one could also imagine a scenario where the methods are
an implementation detail you never see, like e.g. python, but on the
JVM that's never going to happen, so, I've split it up like that).

3. Simple syntax, or even completely automated, generation of
addPropertyListener or addFooChangeListener and associated methods
including firing these listeners when the setter is called.

4. Library or language feature to let you bind any two properties
together (one changes when the other changes, and if you want, vice
versa too).


Lombok only does #1 for you. But #2 I find irrelevant (you save no
typing, and you do obscure an implementation detail which is
particularly important within the class containing the property), and
#3 and #4 very cool, but not something scala does as far as I know.

Java HAS closures right now, they are just unwieldy. An anonymous
inner class is a portable code block that closes over the state of its
immediate context. It's just that, while it understands you when you
e.g. write to a variable from outer, it then generates a compiler
error. It still closes over state, and you can thus use this feature
to accomplish everything you can do with closures. I grant fully that
syntax needs thorough cleaning up, but "higher level" does not seem to
apply.

On Sep 17, 6:51 pm, Cédric Beust ♔ <[email protected]> wrote:
> I agree with everything you said except this particular point:
>
> On Fri, Sep 17, 2010 at 8:18 AM, Reinier Zwitserloot 
> <[email protected]>wrote:
>
> > In any java library that isn't completely worthless, the code is
> > "getField()". If you get annoyed at writing out the accessor, use
> > lombok. Claiming that as a benefit to scala seems like you're grasping
> > for reasons.
>
> I think properties are a big deal and the little syntactic sugar they add
> helps reduce noise considerably.
>
> Actually, when I try to think of the top three features I'd like to see in
> Java, they are, in order of decreasing priority:
>
>    1. Properties
>    2. Closures
>    3. ...
>
> Of all the languages that implement properties, I think C# has the best
> syntax but Scala's is also great. I particularly like the class constructors
> and the case class constructors, both of which capture very elegantly what I
> want to do with my classes most of the time (take a few key values in the
> constructor, store them in fields and expose these fields as properties).
>
> Notice that I didn't fill item 3 above because I just can't come up with a
> feature that I think is as important as the first two. I'm leaning toward
> traits.
>
> --
> Cédric

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to