<?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: Java vs Objective-C: The Smackdown</title>
	<atom:link href="http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/</link>
	<description>software engineering on the mac</description>
	<pubDate>Fri, 29 Aug 2008 06:54:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: XCode 3.0 &#171; PaQueSepas</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-24792</link>
		<dc:creator>XCode 3.0 &#171; PaQueSepas</dc:creator>
		<pubDate>Tue, 16 Oct 2007 17:37:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-24792</guid>
		<description>[...] Algo que me llama la atención del nuevo XCode 3.0 es que tiene Objective-C 2.0. Y Objective-C 2.0 tiene ya garbage collector. Ya han habido algunos artículos al respecto (inclusive una pequenia comparativa entre Java y Objective-C), que si el garbage collector va a traer como efecto que haya más aplicaciones de mala calidad, que si es una ventaja o desventaja. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Algo que me llama la atención del nuevo XCode 3.0 es que tiene Objective-C 2.0. Y Objective-C 2.0 tiene ya garbage collector. Ya han habido algunos artículos al respecto (inclusive una pequenia comparativa entre Java y Objective-C), que si el garbage collector va a traer como efecto que haya más aplicaciones de mala calidad, que si es una ventaja o desventaja. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-6019</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 14 Feb 2007 21:49:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-6019</guid>
		<description>No mention of Matisse? Swing programming couldn't be easier with it.</description>
		<content:encoded><![CDATA[<p>No mention of Matisse? Swing programming couldn&#8217;t be easier with it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-862</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Thu, 09 Nov 2006 11:28:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-862</guid>
		<description>Hello Mr. Joachim Bengtsson,

as for constructors in Java,
I think, that's the deal:
They are guaranteed to give you a new object of the requested class. They are the low level feature for doing just that. I couldn't deny it ;-)

If some languages are strict at that, this is not necessarily a bad thing. Objective C does it differently, yes, but in other languages there are other ways to accomplish this.

&#62; In other languages, you may *only* return
&#62; the instance that was just created,
&#62; while [[foo alloc] init] might actually
&#62; return an NSProxy instance, or anything.

Confusing and dangerous if miss this fact because of not knowing Objective C well - but I guess, in all languages you're bound to learn them before you use them, so that's ok ;-) But:

&#62; Cleaner than saying “You must use this static
&#62; member to create an instance of this class”. 

Why cleaner? Just different. Isn't it very clean to have a guarantee for what a special thing as a constructor (more precisely: the "new" operator) does? And isn't it clean to have methods - which were always used for all the kinds of "arbitrary" stuff you need - do the other, less "predictable" things? At least in Java I find it quite clean to make my class's constructors private, gently pushing its clients towards using a factory method when the want some instance. my 2c.</description>
		<content:encoded><![CDATA[<p>Hello Mr. Joachim Bengtsson,</p>
<p>as for constructors in Java,<br />
I think, that&#8217;s the deal:<br />
They are guaranteed to give you a new object of the requested class. They are the low level feature for doing just that. I couldn&#8217;t deny it <img src='http://www.losingfight.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>If some languages are strict at that, this is not necessarily a bad thing. Objective C does it differently, yes, but in other languages there are other ways to accomplish this.</p>
<p>&gt; In other languages, you may *only* return<br />
&gt; the instance that was just created,<br />
&gt; while [[foo alloc] init] might actually<br />
&gt; return an NSProxy instance, or anything.</p>
<p>Confusing and dangerous if miss this fact because of not knowing Objective C well - but I guess, in all languages you&#8217;re bound to learn them before you use them, so that&#8217;s ok <img src='http://www.losingfight.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> But:</p>
<p>&gt; Cleaner than saying “You must use this static<br />
&gt; member to create an instance of this class”. </p>
<p>Why cleaner? Just different. Isn&#8217;t it very clean to have a guarantee for what a special thing as a constructor (more precisely: the &#8220;new&#8221; operator) does? And isn&#8217;t it clean to have methods - which were always used for all the kinds of &#8220;arbitrary&#8221; stuff you need - do the other, less &#8220;predictable&#8221; things? At least in Java I find it quite clean to make my class&#8217;s constructors private, gently pushing its clients towards using a factory method when the want some instance. my 2c.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-861</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Thu, 09 Nov 2006 11:11:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-861</guid>
		<description>Hello Andy,
as for
&#62; I’m still not buying the free functions argument.
Why not?

&#62; Why does the language feel the need
&#62; to force namespaces on me?

We always had them in form of packages and that was a very good idea - compared to the prefixes we used to apply to classnames in Smalltalk. Sure, you could place classes in the "default package", but after a few occasions (where I just tried out some Java feature the quick and dirty way) I stopped doing that: Now I *always* place classes in packages. It's just a routine.

So I guess you would at least want to keep the "free" functions assigned to packages, right? But packages are mapped to diretories, only classes and interfaces are mapped to files (if you are using a file system, that is ;-) )

So, in order to keep the source code in some file we would have to extend the pattern with an extra rule for "free" functions. Plus you would still want some "import feature" for these (unless you dare to work with the default package).

Wouldn't it be slightly cumbersome to be forced to look for an unknown function in two areas: Classes and packages? And note that the usual scopes of protected or private would not be applicable to functions being "package members". Confusing? Maybe for some.

Then consider reflection: You would have extend those APIs in order to handle "free" functions and hence bloat the language somewhat further. Just because you don't want namespaces to be "enforced" upon you (what would you do with that facility? use namspaces anyway in 99.99% of the cases even though not forced to?) And then, as you say:
&#62; It’s not horrific...

Sure ;-) And perhaps that's why I immediately accepted it as it is saving my energy for thinking up more powerful extensions.

&#62; but why the arbitrary distinction?

Isn't the introduction of new, even more "free" functions than statics some "arbitrary distinction", too? And even more so?

&#62; ...would be nice if the compiler
&#62; could hide that from me.

Sure. And having static imports is as good as it gets here. Remember that we would need that feature anyway, even for functions that are package members. My guess is that, basically, this feeling of a "lack of free functions" was due to the lack of static imports - which made their use really a bit annoying. Java 5+ and a decent IDE should be able to fix that :)</description>
		<content:encoded><![CDATA[<p>Hello Andy,<br />
as for<br />
&gt; I’m still not buying the free functions argument.<br />
Why not?</p>
<p>&gt; Why does the language feel the need<br />
&gt; to force namespaces on me?</p>
<p>We always had them in form of packages and that was a very good idea - compared to the prefixes we used to apply to classnames in Smalltalk. Sure, you could place classes in the &#8220;default package&#8221;, but after a few occasions (where I just tried out some Java feature the quick and dirty way) I stopped doing that: Now I *always* place classes in packages. It&#8217;s just a routine.</p>
<p>So I guess you would at least want to keep the &#8220;free&#8221; functions assigned to packages, right? But packages are mapped to diretories, only classes and interfaces are mapped to files (if you are using a file system, that is <img src='http://www.losingfight.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> )</p>
<p>So, in order to keep the source code in some file we would have to extend the pattern with an extra rule for &#8220;free&#8221; functions. Plus you would still want some &#8220;import feature&#8221; for these (unless you dare to work with the default package).</p>
<p>Wouldn&#8217;t it be slightly cumbersome to be forced to look for an unknown function in two areas: Classes and packages? And note that the usual scopes of protected or private would not be applicable to functions being &#8220;package members&#8221;. Confusing? Maybe for some.</p>
<p>Then consider reflection: You would have extend those APIs in order to handle &#8220;free&#8221; functions and hence bloat the language somewhat further. Just because you don&#8217;t want namespaces to be &#8220;enforced&#8221; upon you (what would you do with that facility? use namspaces anyway in 99.99% of the cases even though not forced to?) And then, as you say:<br />
&gt; It’s not horrific&#8230;</p>
<p>Sure <img src='http://www.losingfight.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> And perhaps that&#8217;s why I immediately accepted it as it is saving my energy for thinking up more powerful extensions.</p>
<p>&gt; but why the arbitrary distinction?</p>
<p>Isn&#8217;t the introduction of new, even more &#8220;free&#8221; functions than statics some &#8220;arbitrary distinction&#8221;, too? And even more so?</p>
<p>&gt; &#8230;would be nice if the compiler<br />
&gt; could hide that from me.</p>
<p>Sure. And having static imports is as good as it gets here. Remember that we would need that feature anyway, even for functions that are package members. My guess is that, basically, this feeling of a &#8220;lack of free functions&#8221; was due to the lack of static imports - which made their use really a bit annoying. Java 5+ and a decent IDE should be able to fix that <img src='http://www.losingfight.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-858</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 08 Nov 2006 18:30:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-858</guid>
		<description>Romain Guy,

Thanks for the links and info. I will check it out.</description>
		<content:encoded><![CDATA[<p>Romain Guy,</p>
<p>Thanks for the links and info. I will check it out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-857</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 08 Nov 2006 18:29:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-857</guid>
		<description>Joachim,

I never said calling free functions from initializer lists was pretty, just that it was doable. :-)

I do have to agree with the singleton case. I have a couple of examples in the interpreter (type classes), where I just want one instance. That is handy.</description>
		<content:encoded><![CDATA[<p>Joachim,</p>
<p>I never said calling free functions from initializer lists was pretty, just that it was doable. <img src='http://www.losingfight.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I do have to agree with the singleton case. I have a couple of examples in the interpreter (type classes), where I just want one instance. That is handy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Romain Guy</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-856</link>
		<dc:creator>Romain Guy</dc:creator>
		<pubDate>Wed, 08 Nov 2006 17:25:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-856</guid>
		<description>Andy,

We created this whole demo in about two weeks worth of work and we were 2.5 people working on it. There is more to the application than what is shown in the screenshot and videos (the application can generate an applet which shows a fullscreen animation of your travel on a map.)

Almost everything you see in the screenshots are standard controls for which we custmozied the look. The "tasks" are just labels, the navigation bar is made of labels, the photo albums is a regular list, the drop shadow text that shows the description on an album is a standard text area, etc. The only custom controls are the 3D ones and the map viewer.

The source code is available under BSD license at http://aerith.dev.java.net and we have several online presentations that explain how we achieved some of the effects (see http://www.jroller.com/page/gfx?entry=no_fluff_just_stuff_extreme)</description>
		<content:encoded><![CDATA[<p>Andy,</p>
<p>We created this whole demo in about two weeks worth of work and we were 2.5 people working on it. There is more to the application than what is shown in the screenshot and videos (the application can generate an applet which shows a fullscreen animation of your travel on a map.)</p>
<p>Almost everything you see in the screenshots are standard controls for which we custmozied the look. The &#8220;tasks&#8221; are just labels, the navigation bar is made of labels, the photo albums is a regular list, the drop shadow text that shows the description on an album is a standard text area, etc. The only custom controls are the 3D ones and the map viewer.</p>
<p>The source code is available under BSD license at <a href="http://aerith.dev.java.net" rel="nofollow">http://aerith.dev.java.net</a> and we have several online presentations that explain how we achieved some of the effects (see <a href="http://www.jroller.com/page/gfx?entry=no_fluff_just_stuff_extreme" rel="nofollow">http://www.jroller.com/page/gfx?entry=no_fluff_just_stuff_extreme</a>)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joachim Bengtsson</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-854</link>
		<dc:creator>Joachim Bengtsson</dc:creator>
		<pubDate>Wed, 08 Nov 2006 07:59:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-854</guid>
		<description>Also, with explicit super constructor calls, you can return something that *isn't* an instance of super, for example a singleton instance. In other languages, you may *only* return the instance that was just created, while [[foo alloc] init] might actually return an NSProxy instance, or anything. Cleaner than saying "You must use this static member to create an instance of this class".</description>
		<content:encoded><![CDATA[<p>Also, with explicit super constructor calls, you can return something that *isn&#8217;t* an instance of super, for example a singleton instance. In other languages, you may *only* return the instance that was just created, while [[foo alloc] init] might actually return an NSProxy instance, or anything. Cleaner than saying &#8220;You must use this static member to create an instance of this class&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joachim Bengtsson</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-853</link>
		<dc:creator>Joachim Bengtsson</dc:creator>
		<pubDate>Wed, 08 Nov 2006 07:51:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-853</guid>
		<description>Andy,

I don't know if it's because I'm more used to objc than any other language, but I find myself quite often needing parameter preprocessing. Also, I've noticed that several of my fellow programmers in my class find themselves, in C++, in situations where they want to preprocess parameters. (And calling free functions is Plain Ugly :P)

I really like Ruby. In Ruby, if you don't call super explicitly by just running "super" (which calls the super constructor with the same arguments as "you got yourself"), it will be called implicitly. You can also call it explicitly, without arguments (above behaviour) or with any number of arguments. This is really nice. However, I prefer named constructors to implicit and anonymous such.

I prefer:
 - (id) initAsPlaceholderFor:(id)foo;
 - (id) initReplacing:(id)foo;
to both
 def initialize foo
and
  MyClass(Foo foo) {...}
  MyClass(Foo foo, Boolean shouldReplace) {...}</description>
		<content:encoded><![CDATA[<p>Andy,</p>
<p>I don&#8217;t know if it&#8217;s because I&#8217;m more used to objc than any other language, but I find myself quite often needing parameter preprocessing. Also, I&#8217;ve noticed that several of my fellow programmers in my class find themselves, in C++, in situations where they want to preprocess parameters. (And calling free functions is Plain Ugly :P)</p>
<p>I really like Ruby. In Ruby, if you don&#8217;t call super explicitly by just running &#8220;super&#8221; (which calls the super constructor with the same arguments as &#8220;you got yourself&#8221;), it will be called implicitly. You can also call it explicitly, without arguments (above behaviour) or with any number of arguments. This is really nice. However, I prefer named constructors to implicit and anonymous such.</p>
<p>I prefer:<br />
 - (id) initAsPlaceholderFor:(id)foo;<br />
 - (id) initReplacing:(id)foo;<br />
to both<br />
 def initialize foo<br />
and<br />
  MyClass(Foo foo) {&#8230;}<br />
  MyClass(Foo foo, Boolean shouldReplace) {&#8230;}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrP</title>
		<link>http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-847</link>
		<dc:creator>MrP</dc:creator>
		<pubDate>Wed, 08 Nov 2006 00:05:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.losingfight.com/blog/2006/11/07/java-vs-objective-c-the-smackdown/#comment-847</guid>
		<description>Andy, 

just to clarify, in java there is no such thing as pass by reference. None. Period. _All_ parameters passed to a method are pass by value. 

Primitive types, as you correctly describe, send a copy of their value to the method. For object references they also send a copy, but _of the reference_ (not the object) which point to the same object as the caller caller scope, and thus you can modify that object within your method. 

This distinction becomes important if you try to write something like a swap method, eg:

public static void swap(Foo a, Foo b)
{
  Foo tmp = a;
  a = b;
  b = tmp;
}

calling this method, you will find that the swap occurs _within_ the method, but not in the caller's scope, and the caller will find their objects not swapped.</description>
		<content:encoded><![CDATA[<p>Andy, </p>
<p>just to clarify, in java there is no such thing as pass by reference. None. Period. _All_ parameters passed to a method are pass by value. </p>
<p>Primitive types, as you correctly describe, send a copy of their value to the method. For object references they also send a copy, but _of the reference_ (not the object) which point to the same object as the caller caller scope, and thus you can modify that object within your method. </p>
<p>This distinction becomes important if you try to write something like a swap method, eg:</p>
<p>public static void swap(Foo a, Foo b)<br />
{<br />
  Foo tmp = a;<br />
  a = b;<br />
  b = tmp;<br />
}</p>
<p>calling this method, you will find that the swap occurs _within_ the method, but not in the caller&#8217;s scope, and the caller will find their objects not swapped.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.485 seconds -->
