Skip to main content

You Might Think

Posted by editor on January 29, 2007 at 7:22 AM PST

Debunking widely-held programming beliefs

Light a candle or curse the darkness? The internet seems highly optimized for the latter, with the further spread of ignorance always just a single Digg away. Java programmers have long been on the bad end of some of the most popular misbeliefs: "Java is slow" and "Swing is ugly" have an entrenched truthiness that's well suited to mindless repetition in forums and blogs.

Of course, does the truth matter? Because if it does, then a lot of us believe some fundamentally wrong things.

Take recursion. It's widely assumed to be inefficient to keep piling states onto the stack to permit subsequent calls back into a method / function / procedure, whatever. There's something of an attitude that recursion is fine for academics, but real-world development requires less formal, less attractive approaches. In other words, recursion is assumed to be slow: fine for Professor Genius and his LISP project, impractical for you and me. We need to unravel our recursion into iterative method calls.

But what if it's not true? What if recursion is faster? The article Quantifying Recursion on the Java Platform, featured in the Java Today section, offers five algorithms (two recursive and three iterative) and assesses their relative performance. The results? "Most surprising is that recursive performance blows iterative performance out of the water. The fast recursive solution is roughly 3 times faster than the fast iterative one."

While we're all in a debunking mood, Artima blogger Arash Barirani reconsiders one of OO's most cherished beliefs in Software Reusability: Myth Or Reality? "Every Java project is designed for reusability. Yet when time comes to do a new project in the same domain we always opt for building from scratch. Is software reusability, especially in the J2EE realm, just a myth?"

Also in Java Today,

John O'Conner's new tutorial on SDN teaches you how to Improve Application Performance With SwingWorker in Java SE 6: "This article describes how to avoid slow, sluggish, or unresponsive UIs by using the SwingWorker class to create and manage worker threads in a demo application called Image Search. This application demonstrates how to correctly use the SwingWorker application programming interface (API) by interacting with the popular Flickr web site to search and download images. "

You might have seen the story in Slashdot, and Cay