<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: What Properties in Java Should Have Looked Like</title>
	<atom:link href="http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/</link>
	<description>Longer than a blog; shorter than a book</description>
	<pubDate>Sun, 07 Sep 2008 18:11:59 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Chad Grant</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-194397</link>
		<dc:creator>Chad Grant</dc:creator>
		<pubDate>Fri, 22 Feb 2008 09:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-194397</guid>
		<description>"More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead. Come to think of it, this was meant to be a real advantage and boost over Java and now most experienced C# programmers prefer and evangelize the Java way in C#."

That's just a flat out lie. There are no c# programmers evangelizing properties as Java does, and if you find one, they're a moron. Properties are a very important part of the whole .net framework. C# coders live in that framework and to code in the backassward way as the framework would be ignorant.</description>
		<content:encoded><![CDATA[<p>&#8220;More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead. Come to think of it, this was meant to be a real advantage and boost over Java and now most experienced C# programmers prefer and evangelize the Java way in C#.&#8221;</p>
<p>That&#8217;s just a flat out lie. There are no c# programmers evangelizing properties as Java does, and if you find one, they&#8217;re a moron. Properties are a very important part of the whole .net framework. C# coders live in that framework and to code in the backassward way as the framework would be ignorant.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JavaSPEKTRUM BlogosphÃ¤re &#187; Blog Archiv &#187; BlogosphÃ¤re (aus JavaSPEKTRUM 02/07)</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-62357</link>
		<dc:creator>JavaSPEKTRUM BlogosphÃ¤re &#187; Blog Archiv &#187; BlogosphÃ¤re (aus JavaSPEKTRUM 02/07)</dc:creator>
		<pubDate>Tue, 06 Mar 2007 07:01:38 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-62357</guid>
		<description>[...] Eine gewaltige Debatte hat JavaSE-Plattform-Chef Danny Corward mit seinem Vorschlag angestoÃŸen, Java um das Konzept von Eigenschaften (Properties) zu erweitern, den Zugriff auf &#8220;Ã¶ffentliche&#8221; Attribute also nicht Ã¼ber die JavaBean-Konvention von get- und set-Methoden, sondern Ã¼ber eine spezielle Syntax zu kapseln. Vielfach wird die konkret vorgeschlagene Syntax - ein Pfeil (&#8221;-&#62;&#8221;) wie beim Zeigerzugriff in C++ - kritisiert, so z.B. von Kirk Pepperdine. Weniger syntaktisch, sondern inhaltlich betrachtet Cay Horstmann das Thema. Er zeigt, wie sich 64 Zeilen Code auf 12 zusammenschrumpfen lassen und versucht, die typischen Gegenargumente (&#8221;meine IDE generiert die Bean-Methoden fÃ¼r mich&#8221;, &#8220;Getter und Setter sind sowieso schlechtes Design&#8221;) zu entkrÃ¤ften. Elliotte Rusty Harold beschreibt, wie Java Properties aussehen sollten &#8212; aber auch, warum man sie seiner Meinung nach gar nicht braucht: Seiner Meinung nach reichen die bestehenden Sprachmittel vÃ¶llig aus. Zustimmung dazu gibt es von Dave Megginson (Achtung Schockgefahr: Er vergleicht den Vorschlag mit einer kosmetischen Operation und illustriert die Analogie mit einem Bild eines Popstars, das man MinderjÃ¤hrigen lieber ersparen sollte.) Megginsons und Harolds Ansicht nach sollte man aufhÃ¶ren, Java um immer neue Elemente zu erweitern. Wer andere Konzepte will, mÃ¶ge doch einfach eine andere Sprache verwenden. Mike Champion, bei Microsoft fÃ¼r XML-Standards verantwortlich, verweist in einem Kommentar auf die Analogie zu C#: VÃ¶llig unwichtig, welche Merkmale Microsoft zu Visual Basic hinzufÃ¼gt, C#-Entwickler fragen immer nur danach, wann sie diese auch in ihrer Umgebung nutzen kÃ¶nnen. Wer all den Links gefolgt ist, die unzÃ¤hligen Kommentare gelesen hat und immer noch nicht befriedigt ist, dem seien die Diskussionen bei InfoQ und JavaLobby empfohlen. [...]</description>
		<content:encoded><![CDATA[<p>[...] Eine gewaltige Debatte hat JavaSE-Plattform-Chef Danny Corward mit seinem Vorschlag angestoÃŸen, Java um das Konzept von Eigenschaften (Properties) zu erweitern, den Zugriff auf &#8220;Ã¶ffentliche&#8221; Attribute also nicht Ã¼ber die JavaBean-Konvention von get- und set-Methoden, sondern Ã¼ber eine spezielle Syntax zu kapseln. Vielfach wird die konkret vorgeschlagene Syntax - ein Pfeil (&#8221;-&gt;&#8221;) wie beim Zeigerzugriff in C++ - kritisiert, so z.B. von Kirk Pepperdine. Weniger syntaktisch, sondern inhaltlich betrachtet Cay Horstmann das Thema. Er zeigt, wie sich 64 Zeilen Code auf 12 zusammenschrumpfen lassen und versucht, die typischen Gegenargumente (&#8221;meine IDE generiert die Bean-Methoden fÃ¼r mich&#8221;, &#8220;Getter und Setter sind sowieso schlechtes Design&#8221;) zu entkrÃ¤ften. Elliotte Rusty Harold beschreibt, wie Java Properties aussehen sollten &#8212; aber auch, warum man sie seiner Meinung nach gar nicht braucht: Seiner Meinung nach reichen die bestehenden Sprachmittel vÃ¶llig aus. Zustimmung dazu gibt es von Dave Megginson (Achtung Schockgefahr: Er vergleicht den Vorschlag mit einer kosmetischen Operation und illustriert die Analogie mit einem Bild eines Popstars, das man MinderjÃ¤hrigen lieber ersparen sollte.) Megginsons und Harolds Ansicht nach sollte man aufhÃ¶ren, Java um immer neue Elemente zu erweitern. Wer andere Konzepte will, mÃ¶ge doch einfach eine andere Sprache verwenden. Mike Champion, bei Microsoft fÃ¼r XML-Standards verantwortlich, verweist in einem Kommentar auf die Analogie zu C#: VÃ¶llig unwichtig, welche Merkmale Microsoft zu Visual Basic hinzufÃ¼gt, C#-Entwickler fragen immer nur danach, wann sie diese auch in ihrer Umgebung nutzen kÃ¶nnen. Wer all den Links gefolgt ist, die unzÃ¤hligen Kommentare gelesen hat und immer noch nicht befriedigt ist, dem seien die Diskussionen bei InfoQ und JavaLobby empfohlen. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: albert bulawa</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-59940</link>
		<dc:creator>albert bulawa</dc:creator>
		<pubDate>Sat, 24 Feb 2007 22:10:37 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-59940</guid>
		<description>Properties are bad and should not be allowed in Java. Of course, it *looks* nice to be able to say foo.x = 4 instead of foo.setX(4) but it's all there is. All other things being downsides.

1. Public field access is mostly understood as a fast, failsafe operation but "property access" is NOT. With such a syntax you have to prepare yourselves for a = operator (or, in case of the getter, worse still, the . "operator") throwing at least runtime exceptions. But why disallow checked exceptions on accessors? And the fast bit: property access may use a database ot a webservice or whatever gizmo you can imagine and it may last seconds, not nanoseconds as we are mentally prepared with public fields.
2. What about x = y = z? Setters are void, and for a good reason, but you can't have x = y = z without breaking this. It is a minor issue, though... and I like this syntax to disappear anyway
3. It's next to impossible to get this right in the compiler. You should be able to replace the class with properties (a version using simple passthrough or plain public fields to a version using accessors or the other way around) without breaking its clients' binary or source code. That means the compiler has to use indirection anyway because it cannot know whether or when you're going to replace that library JAR.
4. This must be transparent as well to the Reflection API, and consistently with the source code. Look at how badly it's broken in C#.

More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead. Come to think of it, this was meant to be a real advantage and boost over Java and now most experienced C# programmers prefer and evangelize the Java way in C#. 

So please leave the properties where their place is: in the "failed experiments" drawer.</description>
		<content:encoded><![CDATA[<p>Properties are bad and should not be allowed in Java. Of course, it *looks* nice to be able to say foo.x = 4 instead of foo.setX(4) but it&#8217;s all there is. All other things being downsides.</p>
<p>1. Public field access is mostly understood as a fast, failsafe operation but &#8220;property access&#8221; is NOT. With such a syntax you have to prepare yourselves for a = operator (or, in case of the getter, worse still, the . &#8220;operator&#8221;) throwing at least runtime exceptions. But why disallow checked exceptions on accessors? And the fast bit: property access may use a database ot a webservice or whatever gizmo you can imagine and it may last seconds, not nanoseconds as we are mentally prepared with public fields.<br />
2. What about x = y = z? Setters are void, and for a good reason, but you can&#8217;t have x = y = z without breaking this. It is a minor issue, though&#8230; and I like this syntax to disappear anyway<br />
3. It&#8217;s next to impossible to get this right in the compiler. You should be able to replace the class with properties (a version using simple passthrough or plain public fields to a version using accessors or the other way around) without breaking its clients&#8217; binary or source code. That means the compiler has to use indirection anyway because it cannot know whether or when you&#8217;re going to replace that library JAR.<br />
4. This must be transparent as well to the Reflection API, and consistently with the source code. Look at how badly it&#8217;s broken in C#.</p>
<p>More and more C# programmers are warning adepts *not to use* properties and to write explicit accessors instead. Come to think of it, this was meant to be a real advantage and boost over Java and now most experienced C# programmers prefer and evangelize the Java way in C#. </p>
<p>So please leave the properties where their place is: in the &#8220;failed experiments&#8221; drawer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eamonn McManus</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-58037</link>
		<dc:creator>Eamonn McManus</dc:creator>
		<pubDate>Mon, 19 Feb 2007 14:27:33 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-58037</guid>
		<description>This is just a nitpick, but the Java compiler does allow an identifier to begin with $, and always has.</description>
		<content:encoded><![CDATA[<p>This is just a nitpick, but the Java compiler does allow an identifier to begin with $, and always has.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frits Jalvingh</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-55603</link>
		<dc:creator>Frits Jalvingh</dc:creator>
		<pubDate>Sun, 11 Feb 2007 14:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-55603</guid>
		<description>Thanks for so far the best observation on how properties should work in Java! The current proposals using "-&#62;" and such are all crap, and muck up the language. I like your variant using the 'property' keyword best; the '$' names look like a kludge.

I agree that it would be a really good idea to reduce the importance of "backwards compatibility" in these discussions. The need for it is often only perceived and not really needed. Take the "Generics" implementations for instance: lots of older code does not compile with -source 1.5. Which is no problem _at all_ because we _have_ -source 1.4! You can easily compile "legacy" code with a legacy version of the language; the only thing you need to keep "backwards compatibility" is to maintain the ability within the JVM to handle the generated code. This is how most "older" code is compiled nowadays anyway.

A good way to see how perceived "backwards compatibility" can really hurt is the Generics implementation. The moronic braindead idiot that allowed for type erasure should be shot! It has reduced the Generics system to a barely functional syntactic layer only, with really stupid limitations (why on EARTH would anyone in his right mind accept a generics implementation which is unable to do class ... new T()" ) AND huge reduced functionality around Reflection and metaprogramming. And the reason for this enormous crappy cludge: they wanted to be backwards compatible with JVM 1.4... Which they aren't anyway. Horror.

I would also make another point for all the people that do not want to extend the language because they think there are already other (usually more verbose ways) of doing whatever needs to be done. Think for instance about the "enum" functionality introduced in 1.5. A computer language is a way to express a problem solution. How effective you can be in expressing such a solution is a direct advantage: if you have to write "boilerplate" for very common solutions this is a problem of the language! It reduces the visibility of the "real" problem *and* it often reduces the knowledge that the compiler has about the actual thing being done - leading to lousy (or no) error messages or reduced code quality.
To me the plethora of stupid "getXxx" and "setXxx" methods is an indication of a blunder in language design. Saying I can do something in a language does not make it the right way because a good language is supposed to make common things easy.

I would advice people to look at C# for some examples of good language design, not only wrt to the language but also wrt the process: don't be too afraid for changes.</description>
		<content:encoded><![CDATA[<p>Thanks for so far the best observation on how properties should work in Java! The current proposals using &#8220;-&gt;&#8221; and such are all crap, and muck up the language. I like your variant using the &#8216;property&#8217; keyword best; the &#8216;$&#8217; names look like a kludge.</p>
<p>I agree that it would be a really good idea to reduce the importance of &#8220;backwards compatibility&#8221; in these discussions. The need for it is often only perceived and not really needed. Take the &#8220;Generics&#8221; implementations for instance: lots of older code does not compile with -source 1.5. Which is no problem _at all_ because we _have_ -source 1.4! You can easily compile &#8220;legacy&#8221; code with a legacy version of the language; the only thing you need to keep &#8220;backwards compatibility&#8221; is to maintain the ability within the JVM to handle the generated code. This is how most &#8220;older&#8221; code is compiled nowadays anyway.</p>
<p>A good way to see how perceived &#8220;backwards compatibility&#8221; can really hurt is the Generics implementation. The moronic braindead idiot that allowed for type erasure should be shot! It has reduced the Generics system to a barely functional syntactic layer only, with really stupid limitations (why on EARTH would anyone in his right mind accept a generics implementation which is unable to do class &#8230; new T()&#8221; ) AND huge reduced functionality around Reflection and metaprogramming. And the reason for this enormous crappy cludge: they wanted to be backwards compatible with JVM 1.4&#8230; Which they aren&#8217;t anyway. Horror.</p>
<p>I would also make another point for all the people that do not want to extend the language because they think there are already other (usually more verbose ways) of doing whatever needs to be done. Think for instance about the &#8220;enum&#8221; functionality introduced in 1.5. A computer language is a way to express a problem solution. How effective you can be in expressing such a solution is a direct advantage: if you have to write &#8220;boilerplate&#8221; for very common solutions this is a problem of the language! It reduces the visibility of the &#8220;real&#8221; problem *and* it often reduces the knowledge that the compiler has about the actual thing being done - leading to lousy (or no) error messages or reduced code quality.<br />
To me the plethora of stupid &#8220;getXxx&#8221; and &#8220;setXxx&#8221; methods is an indication of a blunder in language design. Saying I can do something in a language does not make it the right way because a good language is supposed to make common things easy.</p>
<p>I would advice people to look at C# for some examples of good language design, not only wrt to the language but also wrt the process: don&#8217;t be too afraid for changes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Masklinn</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-54023</link>
		<dc:creator>Masklinn</dc:creator>
		<pubDate>Mon, 05 Feb 2007 16:31:09 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-54023</guid>
		<description>&#62; Thatâ€™s why â€˜the first reason doesnâ€™t apply to regular getters/settersâ€™, but does apply to properties. Or am I missing something here?

Yes you are, because a property is not a public field, it doesn't even have to _back_ a public field.

Let's give a trivial and non-existent example: you've got a property a on your object A.

This means that you can, of course, call A.a and have a result back. Your property is a simple pass-through (ie you could've made your `a` field a public field and it would be the same. It _should_ be the same, in fact).

Now you realize that you should change your implementation, and that your private field `a` should really be replaced by a computation based on `b` and `c`, because your `a` private field really doesn't pull its weight. Are you locked? Nope, just replace your passthrough interface by a computing one: instead of `return a` write `return compute(b, c)` and instead of `a=value` write `b, c = someInverseComputation(value)`. Boom, you're done. And it's very often what's done in Python or Ruby. The _point_  of interface is that they _look_ like public fields (I like to call them "virtual public fields") but they're not. This really means that your interface is independent from the implementation, and the only reason why you use a property or a method is whether or not it makes sense.

And if properties and public fields behave the same at the interface-level (meaning that you can declare a public field in an interface, or a property, and they're declared the same way, as long as there's either a public field or a property that satisfies the contract everything's ok) then you don't have to wrap everything in getters and setters "just in case", uselessly boosting the number of indirections and making the code less clear: you use public fields, and if you need to "hide" them or change your implementation, just swap them with properties.</description>
		<content:encoded><![CDATA[<p>&gt; Thatâ€™s why â€˜the first reason doesnâ€™t apply to regular getters/settersâ€™, but does apply to properties. Or am I missing something here?</p>
<p>Yes you are, because a property is not a public field, it doesn&#8217;t even have to _back_ a public field.</p>
<p>Let&#8217;s give a trivial and non-existent example: you&#8217;ve got a property a on your object A.</p>
<p>This means that you can, of course, call A.a and have a result back. Your property is a simple pass-through (ie you could&#8217;ve made your `a` field a public field and it would be the same. It _should_ be the same, in fact).</p>
<p>Now you realize that you should change your implementation, and that your private field `a` should really be replaced by a computation based on `b` and `c`, because your `a` private field really doesn&#8217;t pull its weight. Are you locked? Nope, just replace your passthrough interface by a computing one: instead of `return a` write `return compute(b, c)` and instead of `a=value` write `b, c = someInverseComputation(value)`. Boom, you&#8217;re done. And it&#8217;s very often what&#8217;s done in Python or Ruby. The _point_  of interface is that they _look_ like public fields (I like to call them &#8220;virtual public fields&#8221;) but they&#8217;re not. This really means that your interface is independent from the implementation, and the only reason why you use a property or a method is whether or not it makes sense.</p>
<p>And if properties and public fields behave the same at the interface-level (meaning that you can declare a public field in an interface, or a property, and they&#8217;re declared the same way, as long as there&#8217;s either a public field or a property that satisfies the contract everything&#8217;s ok) then you don&#8217;t have to wrap everything in getters and setters &#8220;just in case&#8221;, uselessly boosting the number of indirections and making the code less clear: you use public fields, and if you need to &#8220;hide&#8221; them or change your implementation, just swap them with properties.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johann Thomas</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-53952</link>
		<dc:creator>Johann Thomas</dc:creator>
		<pubDate>Mon, 05 Feb 2007 09:00:57 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-53952</guid>
		<description>just another style of property syntax:

Borland Delphi Pascal also has properties (wasn't it, that the one how developed this language also was the creator of C#) and you can define the names of the getter and setter methods. These will be called, even if you access the property field directly:

[tt]
mybook.count = 3 ; // still calls setCount(...)
 // for following declaration

type
  Book = class
  private
    // User defined attributes
    title: Char;
    FCount: Integer;
    // User defined methods
    procedure setCount(cnt: Integer); virtual;
    ...
  public
    ...
    // Access methods
    function getTitle: Char;
    procedure setTitle(newTitle: Char);
    // Properties
    property count: Integer read FCount write setCount;
  ...
implementation
  ...
[/tt]</description>
		<content:encoded><![CDATA[<p>just another style of property syntax:</p>
<p>Borland Delphi Pascal also has properties (wasn&#8217;t it, that the one how developed this language also was the creator of C#) and you can define the names of the getter and setter methods. These will be called, even if you access the property field directly:</p>
<p>[tt]<br />
mybook.count = 3 ; // still calls setCount(&#8230;)<br />
 // for following declaration</p>
<p>type<br />
  Book = class<br />
  private<br />
    // User defined attributes<br />
    title: Char;<br />
    FCount: Integer;<br />
    // User defined methods<br />
    procedure setCount(cnt: Integer); virtual;<br />
    &#8230;<br />
  public<br />
    &#8230;<br />
    // Access methods<br />
    function getTitle: Char;<br />
    procedure setTitle(newTitle: Char);<br />
    // Properties<br />
    property count: Integer read FCount write setCount;<br />
  &#8230;<br />
implementation<br />
  &#8230;<br />
[/tt]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Serodio</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-53003</link>
		<dc:creator>Daniel Serodio</dc:creator>
		<pubDate>Thu, 01 Feb 2007 14:14:43 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-53003</guid>
		<description>There should be operator overloading for BigInteger and BigDecimal. Reading code that uses these classes hurts</description>
		<content:encoded><![CDATA[<p>There should be operator overloading for BigInteger and BigDecimal. Reading code that uses these classes hurts</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hallvard TrÃ¦tteberg</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-52939</link>
		<dc:creator>Hallvard TrÃ¦tteberg</dc:creator>
		<pubDate>Thu, 01 Feb 2007 09:56:23 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-52939</guid>
		<description>If I understand you correctly, what you want is the simplicity of the dot syntax (p.x) with the power of methods (including overloading). In the Common Lisp Object System (CLOS), a field (call slot) definition generated getter and setter methods (collectively called accessor methods), so you could use the power of methods to handle constraints, update dependent fields etc. Normally you would use these methods, but you could also set the field directly using a special, low-level method. If you redefined an accessor method, I believe you could call the auto-generated one from the redefinition (but not from outside), so it wasn't completely overwritten.

If you take the idea of mapping primitive syntax to method, you could also define that [] mapped to elementOf (or whatever name you choose) and [] = mapped to setElementOf, and was legal for any class, so Maps and List could use the same syntax as arrays. I believe Dylan (an language which tried to make Common Lisp look more like a standard language) did this, and this resulted in quite nice code to  both write and read.

I know this looks a bit like operator overloading, but it's different from and not as dangerous as overloading the mathematical operators (like + and -), where you expect certain rules from algebra to apply.

A meta comment: It seems to me that some people participating in this (and other) discussions assume Java's designers were ignorant of these problems and/or their possible solutions. I think that's wrong, e.g. Guy Steele co-wrote the Common Lisp specification, and was at Sun early enough to influence the design of Java. There are so many opinions about these things that it's good that they didn't make decisions about them too early. Whether we can reach consensus on adding keywords like property (which I think is a good idea, based on my experience with CLOS) now is a different question. It will also be interesting to see if the open sourcing of Java makes the process more open to such suggestions (as long as they're compatible with the JVM).</description>
		<content:encoded><![CDATA[<p>If I understand you correctly, what you want is the simplicity of the dot syntax (p.x) with the power of methods (including overloading). In the Common Lisp Object System (CLOS), a field (call slot) definition generated getter and setter methods (collectively called accessor methods), so you could use the power of methods to handle constraints, update dependent fields etc. Normally you would use these methods, but you could also set the field directly using a special, low-level method. If you redefined an accessor method, I believe you could call the auto-generated one from the redefinition (but not from outside), so it wasn&#8217;t completely overwritten.</p>
<p>If you take the idea of mapping primitive syntax to method, you could also define that [] mapped to elementOf (or whatever name you choose) and [] = mapped to setElementOf, and was legal for any class, so Maps and List could use the same syntax as arrays. I believe Dylan (an language which tried to make Common Lisp look more like a standard language) did this, and this resulted in quite nice code to  both write and read.</p>
<p>I know this looks a bit like operator overloading, but it&#8217;s different from and not as dangerous as overloading the mathematical operators (like + and -), where you expect certain rules from algebra to apply.</p>
<p>A meta comment: It seems to me that some people participating in this (and other) discussions assume Java&#8217;s designers were ignorant of these problems and/or their possible solutions. I think that&#8217;s wrong, e.g. Guy Steele co-wrote the Common Lisp specification, and was at Sun early enough to influence the design of Java. There are so many opinions about these things that it&#8217;s good that they didn&#8217;t make decisions about them too early. Whether we can reach consensus on adding keywords like property (which I think is a good idea, based on my experience with CLOS) now is a different question. It will also be interesting to see if the open sourcing of Java makes the process more open to such suggestions (as long as they&#8217;re compatible with the JVM).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://cafe.elharo.com/blogroll/what-properties-in-java-should-have-looked-like/#comment-52679</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 31 Jan 2007 14:20:08 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/what-properties-in-java-should-have-looked-like/#comment-52679</guid>
		<description>&#62; Is the first reason the â€œtype of the interfaceâ€ part?

Partly. The principle at stake here is that changing the implementation should not break the interface. A property mixes implementation (the variable holding a value) and interface (how the property is accessed), just like a public variable. Getters/setters separate interface from implementation. That's why 'the first reason doesn't apply to regular getters/setters', but does apply to properties. Or am I missing something here?</description>
		<content:encoded><![CDATA[<p>&gt; Is the first reason the â€œtype of the interfaceâ€ part?</p>
<p>Partly. The principle at stake here is that changing the implementation should not break the interface. A property mixes implementation (the variable holding a value) and interface (how the property is accessed), just like a public variable. Getters/setters separate interface from implementation. That&#8217;s why &#8216;the first reason doesn&#8217;t apply to regular getters/setters&#8217;, but does apply to properties. Or am I missing something here?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
