Skip to main content

Tall Cafe Mocha to go

Posted by daniel on October 27, 2004 at 6:52 AM PDT

Cocoa for Java programmers

To a midwesterner used to the change of seasons, it doesn't really
feel like fall here at the Mac OS X conference in Santa Clara,
California. It's a fun conference with cool talks on Subversion,
automation, and plenty of coding tricks, techniques, and worthwhile
conventions. But there is not the change of colors, falling leaves, or
smell of fall that we get back home this time of year. It's the time
to sit in the back yard in front of a fire with a warm cup of
cocoa fortified by a shot of espresso.

Honestly, I wasn't even thinking of this until I went to Stu
Halloway's excellent talk yesterday on Cocoa for Java programmers. Of
course his talk had nothing to do with autumn in Cleveland. He
presented some of the gotchas for experienced Java programmers who
would like to program in Objective C using the Cocoa framework for
targetting Mac OS X development.

The first obvious difference is the syntax of swapping the dots
used to call methods in Java ( i.e.

foo.bar().anotherCall().stillAnotherCall()
) for nested square
brackets. He moved on to memory management issues and reflection. In
each case he was able to quickly explain a Cocoa concept by using Java
as a common frame of reference. There are enough Java programmers that
many books and presentations are beginning from the standpoint of
assuming you understand the Java programming language. In the early
years of Java, the reverse was true. You saw titles like Java for C
developers. We are now the establishment we once tried to overthrow.


In today's Weblogs,
John Reynold has responded to reader requests with href="http://weblogs.java.net/blog/johnreynolds/archive/2004/10/tapestry_compon_1.html">Tapestry
Component Examples: contrib:Tree and contrib:Table in which he
"created a suit of examples on how to use the Tapestry Tree
component. I've also added some new examples to the Tapestry Table
component suite."


In Also
in Java Today
, Eugene Kuleshov is exploring the ASM Bytecode
Toolkit, applying it to the metadata feature introduced in J2SE 5.0.
In href="http://www.onjava.com/pub/a/onjava/2004/10/20/asm.html">Create
and Read J2SE 5.0 Annotations with the ASM Bytecode Toolkit, he
shows how annotations are represented in Java bytecode, and how the
ASM bytecode-manipulation toolkit can work with them, even in pre-5.0
JVMs, noting that the article's code "allows you to read annotation
data that is not available through the Java 5 reflection API."

Brian Goetz most recent article on "Java theory and practice"
explains href="http://www-106.ibm.com/developerworks/library/j-jtp10264/"> More
flexible, scalable locking in JDK 5.0 . He describes the new
locking model in Tiger and motivates the change by saying that
pre-Tiger "synchronization is good, but not perfect. It has some
functional limitations -- it is not possible to interrupt a thread
that is waiting to acquire a lock, nor is it possible to poll for a
lock or attempt to acquire a lock without being willing to wait
forever for it. Synchronization also requires that locks be released
in the same stack frame in which they were acquired, which most of the
time is the right thing (and interacts nicely with exception
handling), but a small number of cases exist where
non-block-structured locking can be a big win."


In Projects and
Communities
, the
Mac Java
community links to a MacDevcenter article by Mike
Butler on href="http://www.macdevcenter.com/pub/a/mac/2004/10/22/cocoa.html">
Making Cocoa-Java apps scriptable so AppleScripts can be used to
automate your Java applications on the Mac.

The Java Games
community features a forum on href="http://www.javagaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=J2ME">J2ME
game development. Check out this thread on the challenges of
developing a href="http://www.javagaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=J2ME;action=display;num=1094444057">
J2ME wordbuilding game.

Vikstar would like to " Allow passing of href="http://forums.java.net/jive/thread.jspa?messageID=4661&tstart=0#4661">
primitive types to generic declarations. There are many useful places
for this, one example is anyware where seperate methods have to be
created for each number primitive type."

Dog provides an example of how "the 'class' keyword would be very
useful. It is a common pattern to say something like:

private
final static Logger = new Logger(MyClass.class.getName());
when
copying around code it is often easy to miss the reference to the
MyClass class and end up logging in the wrong place. The 'class'
keyword would solve this."


In today's
Forums
, Monika Krug " would like a method in FileWriter
that adds the system-dependent linebreak character after the line: href="http://forums.java.net/jive/thread.jspa?messageID=4530&tstart=0#4530">
.writeln(String). As FileWriter inherits its write methods from
OutputStreamWriter and Writer, it should probably be defined in one of
these."


In today's java.net
News Headlines
:

Registered users can submit news items for the href="http://today.java.net/today/news/">java.net News Page
using our news
submission form
. All submissions go through an editorial
review before being posted to the site. You can also subscribe to
the href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net
News RSS feed.


Current and upcoming
Java Events
:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e"> events submission
form. All submissions go through an editorial review before being
posted to the site.


Archives and Subscriptions: This blog is delivered
weekdays as the
Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.

Cocoa for Java programmers