Skip to main content

C's A Beauty(?)

Posted by editor on July 18, 2005 at 7:47 AM PDT

Re-appreciating Java style and conventions

So I'm working on a project that will eventually be open-sourced here on java.net if I can get the time to get enough interesting code working... no, I don't want to give away too much yet... and it involves working with straight C, so I can expose some stuff to Java.

Having worked only in Java for eight years, and having not done straight C since college, this is a heck of a wake up call. Everything that I'm used to doing right, doing the Java way, isn't there. For example: let's say you have several lines of code, each of which may fail for various reasons. In Java, the try and catch allow you to collect the exception handling in one place. Not in C, you don't. The QuickTime tradition (darn, said too much) is that you have to get a return code from every call, compare it to the no-error flag, and then goto... no, really, I'm serious!... goto some labelled block where you figure out what you've allocated and initialized and de-allocate and de-initialize it.

Yuck.

And did I mention the concept of passing an empty pointer as a parameter to a function, and looking at the contents of that pointer after the call? Yep. After all, it can't return you a pointer -- the ability to return a value is already taken, by the error handling (see above). So you mix inputs and outputs in your parameter list, and if you're a Java programmer, you cringe a little bit.

Anyways, this isn't to bash C -- it's fast, fast, fast, after all, and a lingua franca of code. But I'm going to be really happy when I only see these calls from the Java side of the bridge.


This week's Spotlight is on the Java Tools Projects Directory, which "seeks to provide an easy way to discover the tools that belong to the Java Tools Community, providing the ability to search for tools by description keywords or related topics. Tools are also classified under various categories depending on status, topic, etc., and include a link through which you can check the RSS feeds of projects directly with your browser or other RSS client."


In today's Weblogs.
Kirill Grouchnikov wonders Porting small library from Java 5.0 to Java 1.4 - could it be any harder?: Last evening I set out to port one of my (rather small) libraries from Java 5.0 to Java 1.4. Twenty four hours later - a lot of frustration, a lot of uncontrolled eyebrow pluckings, and a day well spent.

Jody Garnett has a Mad Metadata Plan: "The use of Extensible-Interface pattern for an origional take on the metadata problem plaguing the spatial world (see EOGEO for background). Thanks to those at OSG'05 for the inspiration. Now if only someone will pay me to solve this problem."

A reply to Greg Murray in Simon Brown's I have Servlets: "In Got Servlets?, Greg is asking what we'd like to see in the next major revision of the Java Servlets specification. In no particular order, here are my initial thoughts."


In Also in
Java Today
,
Many web applications allow the user to upload a file from their local storage via a browser interface, but this common task isn't supported by default in JavaServer Faces. Fortunately, several add-ons like Apache Commons File Upload and Apache MyFaces provide this functionality to JSF developers. In Upload Files with JSF and MyFaces, Andrei Cioroianu demonstrates this with a JSF-based application that accepts and manipulates an uploaded file.

In part five of an interview series with Artima's Bill Venners, Design Patterns co-author Erich Gamma talks about Eclipse's Culture of Shipping: "In software, having cool ideas is nice, but shipping them is what counts. For us it only counts if you have shipped the thing. That's really the mindset we have. And given that you focus on shipping, we never want to be in a mode of always being two years away from shipping. You need to have a short-term deliverable. You also plan, decide and act with this mindset. You are very risk- aware -- you know what you can do so you can still ship on time with quality."


In Projects and
Communities
,
Daniel Brookshier's blog entry New: 3D Math, Viet Nam eLearning, Vocabulary & Open Grade Book in Global Education & Learning Community highlights four new projects in the GELC, submitted from different parts of the world.

The Web Services and XML Community project GT2WMS is an implementation of the Open GIS Consortium's Web Map Service (WMS) specification, implemented using GeoTools version 2. This allows web services to provide geographic maps in response to simple HTTP requests.


In today's Forums,
cowwoc explains his needs Re: Install on demand: "I strongly believe that if my target audience consisted of dial-up users and I did *not* distributed a stripped-down JRE I would have absolutely no customer base, period. It's sorta like trying to get handheld users to install the full J2SE on their hardware, it's impossible. That's why Sun came along with J2ME. This is why they need to step up again for this new niche."

aviadbd has an idea for JDBC's future, or: DataSet relations?:
"What about creating a set of annotations to note one-to-many or many-to-many relations in the database? For example, I could say @Query("select id, name, age from students") [and] @Relation("Classes", "select name from classes c, class_student cs where student_id = {id}") Or something similar, where the first parameter of @Relation is the relation name, the second parameter is the selection statement. The parameters for the selection statement come from the parent DataSet - id, in this case, is the id value of the Student instance. Then, when using the DataSet instance, you could call the getChildRecords(String relationName) method to get all the classroom records."


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.

Re-appreciating Java style and conventions