|
|
|||||||||||||||||||||||||||||||||||||||||||||
Cay Horstmann's Blog
Java One Day 4Posted by cayhorstmann on May 09, 2008 at 06:51 PM | Permalink | Comments (3)Day 4 of Java One is over. Even without huge announcements or great surprises, it was a great conference. Here are my impressions from the cool stuff keynote and my takeaway what it all means. The Cool Stuff KeynoteMy mind wanders during most keynotes, but I always enjoy James Gosling's cool stuff keynote on the last day of Java One. No marketing, just one amazing Java-powered piece of hardware or software after another. Here is what caught my attention:
ConcurrencyUnfortunately, I managed to miss two good talks by Brian Goetz, which does not stop me from pontificating about concurrency, of which I know very little. Check out the excellent slides for TS-5515 and TS-6206. TS-5515 is about the fork-join framework that lets you parallelize certain tasks (such as searching or combining array elements) with a fairly reasonable syntax (which, BTW, would look quite a bit more reasonable with closures). The reason I am getting concerned about this issue is neatly summarized in the overview slide of TS-6206:
Last year, Brian had suggested that I check out actors and software transactional memory. I managed to learn a bit about actors, by the expedient device of assigning my students lab work with Scala actors. Actors share no state...except when I am a knucklehead. The Scala actors are closures and—Josh Bloch will love this one—more than once I accidentally captured a variable from an enclosing scope in an actor. Ok, they don't share state, and they communicate by sending messages. So, you break up your task into actors, each of them does a bit of work, and then they send a message to some other actor that combines the results. How does it know when it is done? You send some other message with a total count. It takes a bit to get used to it. I then solved the task with Java locks—tedious as usual, and the
nagging feeling that I overlooked something, as usual. Finally, I used
In the presentation, Brian writes: STM (Software Transactional Memory) is a not-yet-here technology that takes locking decisions out of the users hands.
I'll suppose my students will learn more about that next year :-) Web Services...Not!When SOAP web services first appeared, I thought simple...object...who wouldn't want them? Well, when I was bombarded with JAX-this and WS-that, when all I wanted to do was get some stuff from a server, I felt like those people in the “future Java features” BOF. I knew I wanted something...just not that. I looked at the TS-5425 slides to see whether REST would save me, and I am cautiously baffled. So...here is my test to see when web services have truly arrived... Today, being a packrat, I downloaded all the presentation PDFs. I manually logged in to the schedule builder, queried for all sessions, did View Source, saved the source to a file, and ran for f in `grep -o "/[^/]*.pdf out.html` ; do echo wget --user contentbuilder --password doc789 http://www35.cplan.com/cb_export/$f ; done
In the meantime, if anyone has a pointer to some tool that records browser activity over multiple pages and gives me Java code to replay it (for HTTPUnit or something similar), I'd be very grateful. I have to do HTML scraping all the time with the IT systems at my university. Nobody there is telling me “just call this web service”. What Does It All Mean?Another Java One is over. I had a great time meeting a lot of interesting people, I learned a lot, and I think it is an excellent conference even when there are no huge announcements or great surprises. Here is my personal take-away.
Java One Day 3Posted by cayhorstmann on May 08, 2008 at 10:57 PM | Permalink | Comments (3)My day 3 at Java One ranged from the Nimbus UI and the future of JSF to interesting discussions about closures and Scala. Details below. NimbusThe presentation on the Nimbus look and feel
was packed. Nimbus is a pretty L&F, and it will be the standard for Java
FX. Everything is vector-drawn, so it will scale nicely to high-resolution
displays. (Check out this nifty sampler.) I would like to tweak the
colors a bit, perhaps make the
JSF 2.0 (JSR-314)The JavaServer Faces 2.0 presentation was also packed. Ed Burns and Roger Kitain listed some of the pain points (which I amplify a bit):
JSF 2.0 will be based on facelets, which should really help with error messages. There were demos of a page description language and the ability to author components using Groovy (see also this blog), and also some AJAX stuff that went over my head. There was no information about how configuration will look like. Hopefully, we'll get a Seam-like navigation option and annotations for managed beans. Or better, Web beans. I asked Ed about the strategy for Seam-like Web beans, but it all seems still very much in the planning stage. It is all supposed to be done by Java One 2009, so hopefully things will get moving soon :-) Blue-Collar Types
max(x, y) { return x < y ? x : y }
But I don't want to catch everything at compile time if the cost is too
high. For example, C++ checks for I find that Java arrays (with covariance and the array store exception) are a reasonable compromise. A number of people who feel strongly about this gasped when I expressed that sentiment, admonishing me that this is unsound. Well, life is unsound. Every language makes tradeoffs between compile time and run time checking.
I think with generics, we may have tried to check too much at compile-time.
Consider this
blog by Alex Buckley where he explains why we can't have a generic
ClosuresMartin Odersky and I chatted about the wildcard syntax and the history of
generics. He said that the Sun folks approached the introduction of generics
very cautiously because they did not want to repeat the disaster of inner
classes! At the time, inner classes were perceived to be a short-sighted
reaction to C# delegates, with ugly syntax and initially underspecified
semantics. Indeed, it took many years for the generics proposal to mature.
Wildcards were literally tossed in at the last minute. (The Now, of course, we have people urging caution with closures so that we don't repeat the disaster of generics. Alex Buckley told me that he asked in the “future language features” BOF how many people wanted closures. Lots of people, more than half the room, raised their hands. How many wanted BGGA? Maybe 6. CICE? Maybe 6. FCM? Maybe 5. I ran into Josh Bloch, and he walked me through a presentation about some nasty aspects of BGGA closures. Among them:
Josh doesn't think that there is much in terms of the “etc.” Is a handful of control structures worth the considerable hassle? He makes a strong case that the hassle is considerable. I still prefer closures over inner classes, and I am holding out some hope that a clearer syntax will emerge. Scala
Clearly, Scala is not a blue-collar language, and I cannot see every Java programmer flocking to it. But I would like to get more experience working with a project that mixes Scala and Java. Preferably with IDE support. There is an Eclipse plugin that is “getting better”, and just recently Caoyuan Deng has made amazing progress with a Netbeans plugin. Adam Bien relates this story:
Java One Day 2Posted by cayhorstmann on May 07, 2008 at 11:30 PM | Permalink | Comments (3)Here is my report from day 2 of Java One. I continue to feel diffident about RIA and Java FX Script, the theme of this year's Java One, so I decided to make my own themes: Ease of development, and transparency. Swing App Framework (JSR-296)
To customize and internationalize components, set their infofield1.font=Arial-PLAIN-12 infofield1.icon=dynamite-stick.png For actions, define a method, tag it with the submit.Action.accelerator=control S This is something I have been waiting for for a looong time—it surely has been reinvented a million times (at least twice by me). Now it will finally be a part of standard Java. The framework has many nice touches: support for background tasks, pesky Mac OS X issues, and saving of session state. If you write Swing apps, check it out! (Also check out beans binding.) JPA 2.0 (JSR-317)JPA is one of my favorite “ease of development” technologies.
I design my object model in Java, toss in a few
Web Beans (JSR-299)
Gavin is an opinionated and charismatic speaker, but he was opionated and charismatic about a general-purpose plumbing mechanism that, once it becomes part of Java EE 6, will make Seam-like components possible. It was quite interesting if you are into meta-annotations, and the design looked very clean. But I still don't know whether I will get Seam-like ease of development when EE6 ships. JCP RoundtableThrough the power of my press pass, I got into a “JCP Roundtable Discussion on Open Source and Open Standards”. The table was actually not round, just your usual long table with speakers Patrick Curran (the JCP Chairman), Alex Buckley, Stephen Colebourne, Rod Johnson, and other luminaries. Some things I learned:
All of this may be rather arcane for most users of Java, but as a book author, I feel the pain caused by a lack of transparency. And, ultimately, so do you. There are some JSRs that are best left unmentioned (such as JSR-127) that would surely have produced better specs if they had received more broad-based input. Java Champions BOFThe Java Champions are a motley assortment of (Java luminaries|whiners and
complainers), including yours truly. Consider the case of Java FX. I am rooting for Sun and FX. You can't win if you don't fight, and I give Sun a lot of credit for fighting. I don't see what good it does to develop behind closed doors, and only show a preview to a select few who sign up and get chosen. That may work if you really know what you are doing (e.g. the iPhone but not the Newton). But there is a reason that open source projects succeed with a transparent development process where everything is out for anyone to see. Let people whine and complain early and often, and you get great feedback what you need to fix, before it is too late. Java One Day 1Posted by cayhorstmann on May 06, 2008 at 11:35 PM | Permalink | Comments (6)Here is my braindump from Information Overload Central, AKA Java One 2008. Java FX ScriptThe day started with, you guessed it, another keynote. I just can't stay focused during them, so FWIW, here is what I got out of it.
A few months ago, I had asked Bob Brewin at Sun about the situation about audio and video codecs in Java and FX. He hemmed and hawed and mumbled something about how Ogg Vorbis wasn't really going to work out. The good news is that Sun now licensed the same codecs that are used in Flash, and there will be decent multimedia support going forward. It is just extremely annoying that codecs are so patent-encumbered, and it is yet more evidence that patents hinder, and not promote, the progress of science and the useful arts. At the press cocktail hour, James Gosling was kind enough to give me some inside dope on JFX development. One of my graduate students, Sadiya Hameed, is working on reimplementing Java FX Script as a DSL. Whenever she showed me some code that she found in the wild, I thought “Whoa! That's a lot ofmath.” (Which, BTW, one of the keynote speakers said today as well.) As it turns out, a lot of the math is apparently auto-generated when a set ofAdobe Illustrator files is transcoded into Java FX Script. The work flow is that the creative folks work in the tools that they like (and not so much in Java FX Script), and that the programmers work in the tools that they like (maybe Java FX Script for the front end, and definitely Java on the backend). Gosling also said that some of the tools were still pretty rough, which is why the keynote didn't show them off. That all made perfect sense. They should let him give the keynote next year. EJB 3.1I am a definite fan of JPA and EJB3, so I was keen on learning what is new in EJB 3.1. Fortunately, much of it centered on my pet topic, ease of development.
It surprises me how many people still don't realize that EJB3 was a game-changer. Last year, it was still ok to complain about EJB bloat. This year, not so much. Defective JavaBill Pugh gave an amusing talk about “WTF code”. He is the inventor of the nifty Findbugstool and regularly trolls for dysfunctional code (in unsavory places such as this one) to add more bug-finding rules. Here are some of the beauties that he presented:
Java Language EvolutionAn interesting presentation about what to expect in Java 7 and beyond. Rules:
Principles:
Likely to be in Java SE 7:
Definitely won't be in Java ever:
Too bad I didn't have a chance to ask about that in the BOF. I had been a reviewer for the tools and languages track, and Sharat Chander, the track chair, took out all of the reviewers for a great dinner. Potentially little known facts: (1) Competition for slots at Java One is intense. We had over 300 proposals for maybe 20 slots. (2) Most of the reviewers—at least in our track—are not from Sun. Java One Day 0Posted by cayhorstmann on May 05, 2008 at 10:18 PM | Permalink | Comments (2)Last year, Java One Day 0 was Netbeans Day, in a cozy hotel. This year, the Java One week started much more grandly, with Community One, at the Moscone Center. There were tracks for a number of open source communities, including NetBeans, GlassFish, MySQL, OpenSolaris. Frankly, I preferred the cozy hotel, but I can see that it is savvy marketing by Sun to have a large-scale free community event. Ian Murdoch (the ian in Debian) gave the
keynote speech. My mind wanders in keynotes, and here were some of its
destinations.
Charles Nutter gave an interesting overview of languages that run on the JVM. There were the usual suspects: Groovy, Jython, JRuby, Rhino, Scala, and some more exotic ones. (Note to self: Check out Clojure and see if it makes software transactional memory easier to understand.) Charles' advice: The era of doing everything in a single language is over. Be a polyglot. Sadly, the Netbeans talks were far from riveting. Instead, I walked off to the exhibit area and had a chat with Winston Prakash and a very friendly fellow from the Prague office about the JSF visual designer. The Netbeans 6.1 editor isn't bad, provided you don't use absolute positioning and ignore the useless backing bean that it insists on generating. But it could be so much better. An improved visual editor is being planned, but apparently JSR 276 is going nowhere. That's too bad. Wouldn't it be nice if you could use your favorite JSF library (ICEfaces, RichFaces, ADF Faces/Trinidad, Woodstock) in your favorite IDE, with visual builder support? It has taken far longer than I expected for these components to appear, but now that they are there, I want to drag and drop them, and not be stuck with the drab standard components. (Check out this blog by my graduate student Ashlesha Patil...) There was a very nice presentation on EclipseLink. It looks like a great JPA provider, blazing the trail to JPA 2.0 and offering amazing configurability. But it surely takes the prize for the most confusingly named product of the day. Recall that Toplink WateredDown, erm, Essentials, is the JPA provider in GlassFish. The original Toplink is now open-sourced with the Eclipse foundation, hence the name. Where can you find it? In Glassfish 3, which you can install into NetBeans (!). The Eclipse IDE has not yet caught up.
My favorite event was a fun presentation about using robots in computer science education. These aren't your usual Lego robots. They have several processors on board for “cockroach reflexes”, and they can be equipped with a Java-powered SunSpot for its brains. The presenters demoed a nifty development environment based on Greenfoot. You can prototype your robot in the safety of your laptop, and then download the program into the SunSpot to control the actual hardware. There is a maze-solving contest going on at Java One. If you have any brain cycles left for coding at Java One, give it a try! On Blue-Collar LanguagesPosted by cayhorstmann on May 04, 2008 at 09:16 PM | Permalink | Comments (3)I ran across this tech tip on using wildcards in Java generics. Pretty basic stuff, I thought. But I was amazed by the comments:
For the first time, I really understood what it means to be a blue-collar language. In a blue-collar language, the rules are always simple and straightforward. If something doesn't work, there is a clear error message, either at compile-time or at run-time. Overall, Java did a great job with that. Consider covariance of arrays. Joe Bluecollar can convert a
Java generics? Not so simple. Check out this blog. Even a concurrency rocket scientist can be baffled by generics.
I am teaching a graduate course in programming languages at San Jose State. One of the topics is generics in Java and Scala. I thought my students would enjoy a topic of current interest, but they are not happy. Variance and wildcards seem to belong to that category of mind-benders that most people find impossibly challenging, similar to the pumping lemma or 2D array types in C. (When teaching C, I used to patiently explain, with many examples, why the
type of an array declared as What is it about these topics that makes otherwise perfectly capable programmers stop thinking and start guessing randomly? Maybe we all use intuition more often, and formal reasoning less often, than we think? A language that wants to capture the hearts and minds of the blue-collar programmer needs to work very hard to have rules that are always simple and straightforward. In Java, arrays are simple and straightforward. Wildcards are not. I now appreciate how challenging it is to develop a blue-collar language, and how much thought must have gone into the design of Java. I don't mean to say that everything in the language has to be easy as pie—we all know easy languages that lack power and expressiveness. But the rocket science stuff ought not to be in everyone's face. In Java, the rocket scientists can use annotations, reflection, and byte code engineering, to deliver constructs that the blue-collar programmer finds intuitive to use. The problem with Java generics is that they are too weak. For example, it is not possible to implement a covariant array with an array store exception (because of erasure). Instead, the wildcards leak out and give the blue-collar programmer a headache. What does that mean for closures? How leak-proof is the rocket science stuff? With BGGA, for the most part, I think it is pretty good, particularly when it comes to control invocations. Of course, you'd never know from looking at all the blogs that show complex syntax for writing closures. Well, using reflection, dynamic proxies, and annotation processors is no picnic either. What counts is whether the resulting artifacts are “always simple and straightforward”. Is Computer Science the New Latin?Posted by cayhorstmann on April 05, 2008 at 10:02 AM | Permalink | Comments (11)
Has computer science become as unpopular as Latin for American teenagers? That would have serious consequences for our industry. As it happens, I just finished serving on the Development Committee for the AP Computer Science courses, so I have a little more inside information. The number of computer science majors has dropped substantially after the dot-com bust (see the graph below). At the same time, U.S. employment in the IT sector is solidly up, outsourcing nonwithstanding, and there is widespread concern about a looming skills shortage.
Why don't students major in CS? Nobody knows for sure. The Dilbert image of working long hours in cubicles, only to have your job outsourced, surely doesn't help. We do know that most students have made up their mind by the time they reach college, so the way to their hearts and minds is in secondary school. That's where the AP program comes in. In the past, there were two courses, AP CS A and AB. The A course covers college-level CS1, the AB course covers college-level CS1+CS2.
AP CS must have a single curriculum, so they go with the middle-of-the-road approach: Programming and data structures in Java. That doesn't make them popular with the (intrepid experimenters|lunatic fringe)—see this article. Some of that criticism is below the belt. You can't judge the quality of a course by the weakest question on the final exam. But not all is well with AP CS. There needs to be more room for excitement and fun, not just teaching to the test. Enrollments in the course have declined somewhat less than at the college level. Here are recent numbers of test-takers, courtesy of Dave Reed, the Chief Reader who administers the CS exams: YEAR A AB --------------------- 1998 6,478 4,057 1999 12,218 6,619 2000 13,646 6,876 2001 15,827 7,595 2002 15,660 7,799 2003 14,674 7,071 2004 14,337 6,077 2005 13,924 5,097 2006 14,662 4,939 2007 15,049 5,064 Compared to other AP subjects, the CS numbers are not very impressive. In 2007, Physics had over 60,000 test-takers, and US history over 250,000. Latin had about 5,000. The College Board decided to cut their losses. Without bothering to ask any CS people, they eliminated the AB exam, leaving AP CS as a one-semester course. (As the VP in charge, Trevor Packer, emailed me: “We do not see this as a decision dependent upon disciplinary input.”) This is rather unfortunate since the kids taking AB are the ones most motivated to go into computer science.
Feel of Java RevisitedPosted by cayhorstmann on March 01, 2008 at 06:20 PM | Permalink | Comments (12)
I teach a graduate class in programming languages at San Jose State University. Instead of covering denotational semantics or logic programming, I decided to cover what is hot in dzone (closures, metaobject protocols, etc.) and smuggle in the theory under the radar. My class has been learning about the various closure proposals for Java, and we played with the BGGA and CICE implementations in the labs. (If you want to play along, go here for a guest login. Sorry, no FCM yet. The implementation came after I designed the lab.)
Aaron Houston, the tireless champion of the Java Champions, got my class tickets for the event, with reserved seating, free T-shirts and a Sun Spot kit for the CS club. Thanks Aaron!!! We all had an amazing time.
Much to my disappointment, the presentation did not engage in mudslinging about competing closures proposals :-) Instead, James revisited his personal journey to Java. It was very interesting to see how his experience with prior scripting languages and compiler projects shaped his thinking. When Java was created, the “blue collar” language was C. Used by Real Programmers who were manly enough to spend weeks tracking down obscure memory corruption errors. Garbage collectors were used by quiche eaters. James explained his goal of combining a familiar syntax with the features that are required for security and reliability. He also recounted his many years of experience with virtual machines, from industrial and academic projects. It became apparent how Java—the happy marriage of blue collar and quiche eater programming—was no accident but the result of a careful design process. Of course, closures came up in the Q&A. James said that he personally loves closures and would like to use them in Java if and when they become a part of it. (There had been some speculation in the blogoshpere whether closures fail the “blue collar test”, which James refuted in this blog.) I asked about the decision process that governs the evolution of the Java language. In response, James grumbled a bit about issues with the JCP process. James made it clear that he considers generics a great win, despite some of the ugly corner cases. Kirk Pepperdine asked about Java FX and whether it was competitive with Flex and Silverlight. James gamely said that it will be an interesting battle. There was some discussion about the successor of Java, and James said that the JVM is more important than Java itself. This all left me thinking about closures and blue collar programmers. 15 years ago, only the super-rich had a plasma TV, and only eggheads used a garbage collector. Now, flat screen TVs are everywhere, and I can't think of a recent programming language that doesn't have garbage collection. Time marches on, and what was once a luxury becomes commonplace in blue collar households. Consider this example from my homework assignment. Instead of this mess of code, use BGGA closures to put work on a background thread or the event dispatch thread like this. Scanner in = new Scanner(new FileInputStream(file));
onBackgroundThread()
{
int lineNumber = 0;
while (in.hasNextLine())
{
String line = in.nextLine();
lineNumber++;
onEDT()
{
statusLine.setText("" + lineNumber);
textArea.append(line);
textArea.append("\n");
}
}
onEDT()
{
openButton.setEnabled(true);
}
}
Note how much clearer the code has become. Put time-consuming work on the background thread, and put the UI update on the EDT. Java FX needs special keywords for this. With closures, you just define a couple of utility functions. It is so easy that one of my students wrote:
It doesn't get more blue collar than that :-) |
May 2008
Search this blog:CategoriesCommunityCommunity: Global Education and Learning Community Community: Java Tools Community: Java User Groups Community: JavaDesktop Community: JDK J2EE J2SE Linux Programming Archives
May 2008 Recent Entries | ||||||||||||||||||||||||||||||||||||||||||||
|
|