Skip to main content

Speculations for 2010, Part 2: The Multicore Challenge - Is It Still Relevant?

Posted by editor on December 31, 2009 at 9:45 AM PST

Ever since Mark Reinhold's announcement at DEVOXX that Java 7 will include closures, I've found myself thinking a lot about where we are headed with respect to desktop computers, how Java fits into that, how the cloud fits in, etc. It makes sense that the future will include many-core processors, which will be available even in budget-priced systems. What will we do with all those processor cores? Well, that depends on the nature of the software we'll be running on our systems.

In Mark Reinhold's Closures for Java post, which was written soon after the DEVOXX announcement, he said that it is because of the emergence of multicore processors that closures are needed in Java. Why? Because:

Working with parallel arrays in Java, unfortunately, requires lots of boilerplate code to solve even simple problems. Closures
can eliminate
that boilerplate

I was initially somewhat confused by these statements, because I thought Java had everything it needed for efficient use of multiple cores in its threading libraries. The results of our (unscientific) November poll Is Java's parallel programming support sufficient to meet 'the Multicore Challenge'? suggest that quite a lot of developers (34%) believe the same thing. 18% thought that with the addition of closures, Java will have adequate parallel programming support.

In my recent interview with Adam Bien, I asked:

Do you agree that adding closures to Java is needed to enable Java to meet "the Multicore Challenge"?

Adam's response:

I'm not sure about that. You can run perfectly scalable code right now with plain Java. Closures could make it more convenient - but it isn't impossible to write multicore code without them.

But -- another question is: are we moving away from desktop applications anyway? Look at the purchase of Playfish by Electronic Arts:

The acquisition of Playfish falls in line with EA's desire to be more than just a developer for traditional gaming platforms, like consoles and the PC. The company said in a statement that the acquisition "strengthens its focus on the transition to digital and social gaming."

It's not "we want to diversify into social gaming"; rather, it's taken for granted that social gaming is replacing digital gaming. And where does social gaming actually take place? In the cloud, not on your multicore desktop.

So, then, is the Multicore Challenge becoming a moot point as people migrate ever greater shares of their computer-based activity into the cloud? My little HP Mini 1120NR netbook does a fine job with FaceBook, Twitter, and BlogBridge; it's great at conferences; I can even set up the home page and write my blogs on it (though I prefer my larger desktop screen for that work). Sometimes I even turn off my quad-core desktop (500 Watt power supply) and use the Mini for periods of hours, to save on my electric bill (also, in the winter, to minimize the chance for the quad-core to overheat, which happens on occasion when the corn stove we use to heat this end of the house is running).

Then, too, there's the iPhone, Google's Android platform, etc. Larry Ellison even hinted at the creation of an Oracle/Sun phone at JavaOne. At minimum, Oracle/Sun would be very active in developing software for mobile devices. While I remember Ellison saying these things, I'll point you to a Wall Street Journal article for reference. Talking about mobile devices, Ellison said:

"I don't see why some of those devices shouldn't come from Sun-Oracle."

And he also said:

"I think you'll see us get very aggressive with Java and developing Java apps for things like telephones and netbooks."

So, then, might the desktop computer itself be kind of on the way out? Probably not, but if the great majority of apps people want to run actually perform their processing on remote server farms, with the local activity being simply a user interface that sends out requests and receives and displays responses, how much of a need will there be for heavy-duty multithreaded applications that run locally? And, thinking about Java, doesn't Java EE 6 provide everything we need on the server farm end?

Just some thoughts...

Happy New Year to all who observe the Gregorian calendar!

In Java Today, Kirill Grouchnikov presents Pushing Pixels: the best of 2009:

The year is coming to an end, and it’s time to review what has happened on this blog over the last twelve months. I’ll start the top ten most read posts, and then list my own favorites. Let’s start with the top ten most read posts published in 2009 as measured by Google Analytics ...

Jim Weaver writes about Achieving mutual symbiosis between Web pages and JavaFX apps:

As illustrated in the movie Finding Nemo, clownfish and sea anemones have a mutual symbiotic relationship.  The latter Wikipedia article states that "The territorial [clown] fish protects the anemone from anemone-eating fish, and in turn the stinging tentacles of the anemone protect the clownfish from its predators. A special mucus on the clownfish protects it from the stinging tentacles". Of course, as also demonstrated in Nemo, mutualism breaks down when uninvited barracudas join the party ;-) ...

Geerjan Wielenga has discovered a Music Creator on the NetBeans Platform :

Yet another NetBeans Platform application is... the music creator, which is a MIDI synthesizer with keyboard and danceboard integration. "The requirement for this project was to use a dancing board as an input device for our program. Instead of creating a program where people can dance on, we decided to do the opposite. By pressing the buttons on the dance board or keyboard you can create sounds. You are able to record those sounds. After making a couple of recordings you can arrange them on the recording tracks and play them as if they were one song." ...

In today's Weblogs, Felipe Gaucho presents True Abstraction Revisited: Composite UI Components in JSF 2.0:

I got some difficulties following the tutorial about creating components with JSF 2.0, mainly due to some obsolete instructions and Maven dependencies of the more than 1 year old original articles of Ed Burns. I wrote down upgrades instructions in a hope to help other newbies to create composite UI with JSF 2.0. Nevertheless, you should read the original text because I won't explain the concepts behind creating Composite User Interfaces and neither rephrase Ed Burns. I will just give you en updated version of the same project, with the same xhtml code. I am using Eclipse on the Karmic Koala Ubuntu 9.10 but the below instructions should work everywhere :) ...

Cay Horstmann writes about JSF 2.0 and Tomcat:

As I happily wrote about new features of JSF 2.0, my coauthor David Geary kept asking me how to run the examples in Tomcat 6. I kept putting it off—hunting down all those JAR files and web.xml fragments is just too much like eating soup with a fork. I finally got around to doing the research and thought that others might benefit from the (unhappy) results, if only to realize that this may be the time for switching to GlassFish...

John Ferguson Smart presents Automated deployment with Cargo and Maven - a short primer:

Cargo is a versatile library that lets you manage, and deploy applications to, a variety of application servers. In this article, we look at how to use Cargo with Maven. If you are starting from scratch, you can use an Archetype to create a Cargo-enabled web application...

In the Forums, emiddio-verizon wonders how to keep generated jsp java files for debugging after deployment on gfv2.1: "i cannot find any class for java files for the deployed jsp pages for a web app in domains/domain1 -- anywhere; they used to appear in some earlier Sun App Servers in domain1/generated/j2ee-modules/jsp. how can i config the deployment to keep ..."

snovak7 is having migrating from v2.1 to v3 issues: "I tried my existing application to deploy on a glassfish v3, but have problems. Issue is in implementation of ServletContextListener I implemented, it uses getResourceAsStream, which works in v2.1, but not in v3, I just get NullPointerException 's. Example ..."

genericprodigy is Creating a Metro-based Secure Token Service: "I'm well aware of how to create a Secure Token Service (STS) using NetBeans, but what I am trying to accomplish is an IDE-independent method using Maven as the underlying project manager. I use NetBeans on a regular basis, and Eclipse on occasion, but I need to provide a method of creating a STS..."

Our current Spotlight is the Annual Developer Quiz put together by Janice Heiss: "For this quiz, SDN staff author Janice J. Heiss surveyed past interviews with leading Java developers in search of questions that might challenge, inform, entertain, amuse, and provoke you. The questions aspire to reflect both the intellectual curiosity and spirit of fun to be found in the Java community. We hope you enjoy taking this quiz... Test your knowledge of Java technology and computing..."

Our current Poll asks "What was the most significant Java/JVM news/event in 2009?" Voting will run through Thursday or Friday (depending on where you live).

We have a new Feature Article by JFXStudio Holiday Challenge winner Jeff Friesen, Reading Newsfeeds in JavaFX with FeedRead, in which Jeff demonstrates how to apply JavaFX's RSS and Atom newsfeed capabilities to create a snazzy little JavaFX app that can run stand-alone or in a browser. We're also still featuring my recent Interview with Java Champion Adam Bien: Java EE 8, Closures, and More.

The latest Java Mobility Podcast is Java Mobile Podcast 92: MIDP 3.0 in Depth: Tutorials and Demonstrations: Excerpts from the JavaOne 2009 MIDP 3.0 In Depth: Tutorials and Demonstrations session with Roger Riggs, Lakshmi Dontamsetti and Stan Kao.

Current and upcoming Java Events:

Registered users can submit event listings for the Events Page using our 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 it will be archived along with other past issues in the Archive.

-- Kevin Farnham

O'Reilly Media


Why closures for parallelism?

Closures make parallel programming easier because it forces the software developer to do things without intermediate or mutable state (or as John said, functional programming). The more you can keep state localized to a function being applied across a sequence, the easier the job becomes. This is why map-reduce is so successful.

For Java, however, they're not entirely necessary -- like many other language extensions, they are merely syntactic sugar.

People probably don't remember much from the "bad old days" of MPP systems from the early 90's and late 80's. Way back then, Lisp and its closures were the primary programming language of the Connection Machine (as well as others). Consequently, some support for functional programming and immutable state (maybe not to the degree of Haskell) is overall a good thing to exploit multicore.


parallel programming on desktop only?

Maybe I'm missing something, but you're thinking parallel programming (multicore) is relevant only for the desktop? Wouldn't we expect even greater parallelism on the server? 32-, 64-, 256-way servers, massive parallelism? Or are we just assuming that our environment will always be Glassfish/JBoss/Websphere and those platforms will handle the parallelism with something like a processor per servlet? Aren't there other benefits to closures besides removing boilerplate for parallel code? Easier functional programming, for instance? John.

parallel programming on servers already exists

The reason I ignored servers is that I think we already do have quite effective capability to develop software that runs on hundreds or thousands of nodes, and on multiprocessor systems, running enterprise-level applications (where the processing can be readily divided into tiers), with Java EE. 

I think the term "Multicore Challenge" has most often been used in reference to desktop systems: single processor computers can't get faster because Moore's Law is breaking down, so the only way to make desktop computers more powerful is to add more processor cores -- but to take advantage of the multiple cores, applications must be multithreaded. Hence, it's a crisis for companies that develop desktop software, a "challenge."

Closures would be another tool in the developer toolbox, and would make certain tasks simpler to accomplish. How they're implemented will determine how useful they will be in solving specific problems. Mark Reinhold, however, explicitly stated that the reason closures are needed is because of the Multicore Challenge. This statement has had me thinking and wondering ever since he made it.

Why couple multi-core and desktops?

The shift to multi-core will catch up with cell-phone-sized machines soon enough, maybe three to eight years out. I suppose you could just keep fleeing to smaller few-core machines for a while, assuming the JVM stays under you.