Java, Gtk and Mono

via Rarebit Fiend

New software.

This site is now running Tomcat 5 and MySQL 4. The site seems quite a bit faster, which is of course a good thing. Now that I'm running on MySQL 4, both at home and on this site, I would like to add referential integrity to the Roller database. To that end, I've been reading up on MySQL and playing around with DBDesigner4, an ERWin-like database modeling tool recommended by Scott Switzer on the Roller dev-list. DBDesigner4 is an impressive piece of software with a very slick user interface and, best of all, DBDesigner4 is free -- licensed under GPL.

Last week, I bought a copy of Dragon Naturally Speaking Prefered for Windows (about $150 including microphone headset). I'm using it to dictate this weblog entry and it is working very well. It took only about 10 minutes to train Dragon to understand my mumbly and lispy voice. Dragon works well, but to use it effectively you must think before speaking and you must speak very clearly. This is really not a problem because just about everybody, and especially mumbly me, needs practice thinking before speaking and speaking clearly.

I'm getting a new desktop machine at work and I'm trying to decide which Linux distribution to use. I'm going to use the machine for development work using Eclipse, Tomcat, and PostgreSQL. The guys down the hall like Gentoo, but the consensus among RTPBloggers is that Debian is a better choice -- much more mature, stable, and widely-supported. I'm assuming that Eclipse is stable on both Gentoo and Debian, please correct me if I'm wrong.

Rave beta

eWeek: Sun to Release Project Rave Beta

JSP Control Flow engine.

It's time for another installment in my ongoing series of articles on continuations in Java Web application development. In a previous installment I explained how I was able to rip the continuation-based Cocoon Control Flow engine free of Cocoon and make it work in a standalone unit test environment. For this installment, I have implemented a simple web application that uses that Control Flow engine for all application logic and uses JSP for presentation.

On the Cocoon web site, the Cocoon Control Flow tutorial uses the good-old Tomcat JSP number guess example to illustrate how the Cocoon Control Flow engine works, so I have done the same thing for my JSP Control Flow engine. There are five parts in my implementation of number guess: the numberguess.js JavaScript program that executes on the server side, a FlowServlet that starts and continues the JavaScript program, the Control Flow engine which runs the JavaScript program, the guess.jsp page which asks the user to guess, and the success.jsp page which informs the user of a successful guess.

I'm not going to go into any more detail on the FlowServlet or the Control Flow engine implementation at this time. The code is not yet packaged for release, but you can get it in the form of an Eclipse project here: JSPFlow-v1.zip (it's 2.4MB because it includes the way-too-many jars necessary for running MockRunner). I'll discuss FlowServlet implementation later, for now let's take a look at the JavaScript code for number guess.

function main(tray) {

  var random =  Math.round( Math.random() * 9 ) + 1;
  var hint = "No hint for you!"
  var guesses = 0;

  while (true) {

    // send guess page to user and wait for response
    forwardAndWait(tray, "guess.jsp", 
       { "random" : random, "hint" : hint, "guesses" : guesses} );

    // process user's guess
    var guess = parseInt( webapp.request.getParameter("guess") );
    guesses++;
    if (guess) {
      if (guess > random) {
        hint = "Nope, lower!"
      } 
      else if (guess < random) {
        hint = "Nope, higher!"
      } 
      else {
        // correct guess
        break;
      }
    }
  }

  // send success page to user
  forwardAndWait(tray, "sucess.jsp", 
     {"random" : random, "guess" : guess, "guesses" : guesses} );
}

As you can see, the code for my version of number guess is almost exactly the same as the code for the Cocoon version. There's no substantial difference. Now, let's take a look at guess.jsp. There are a couple of differences, but nothing major. Instead of the Cocoon ${thing} syntax, you see JSP syntax. Instead of making the continuation ID part of the POST URL as Cocoon Control Flow does, I've put the continuation ID in a hidden field.

<html>
<head>
  <title>JSPFlow number guessing game</title>
</head>
<body>
  <h1>Guess the Number Between 1 and 10</h1>
  <h2><%= request.getAttribute("hint") %></h2>
  <h3>You've guessed <%= request.getAttribute("guesses")%> times.</h3>
  <form method="post" action="/jspflow/FlowServlet">
    <input type="hidden" name="contid" value='<%=request.getAttribute("contid")%>' />
    <input type="text" name="guess"/>
    <input type="submit"/>
  </form>
</body>
</html>

Finally, let's take a look at the success.jsp. Again there is no substantial difference.

<html>
<head>
  <title>JSFlow number guessing game</title>
</head>
<body>
  <h1>Success!</h1>
  <h2>The number was: <%= request.getAttribute("random") %></h2>
  <h3>It took you <%= request.getAttribute("guesses")%> tries.</h3>
  <p><a href="/jspflow/FlowServlet">Play again</a></p>
</body>
</html>

Number guess is simple and not a very realistic. The input data is strings, all application logic is written in JavaScript, and the output data is also strings. In a real world application, we would probably want to call out to application logic written in Java and we would probably want to put some more complex objects into request scope for display on the JSP page. Despite that, I'm going to move on. I'll implement a more complex example once I've figured out how to make Control Flow work with Struts. In my next installment, I'll implement number guess again - this time using Struts and Control Flow.


Roller 0.9.8.2 bug fix release is available.

Roller 0.9.8.2 is the fastest and most stable version of Roller yet. It has been battle tested for over five months on JRoller.com.

Roller 0.9.8.2 includes a number bug fixes related to (somewhat embarrassing, I must say) database consistency problems and some additional database indexes for performance. See the change notes for the specifics. Download Roller 0.9.8.2 on SourceForge.

Don't miss the SourceBeat blogs.

Even if you don't buy into one of the "live" SourceBeat books, you can still subscribe to the excellent (and Roller-based) SourceBeat blogs. You can subscribe to the whole lot of them with one URL:

http://sourcebeat.com/roller/rss.

Win events to RSS

via James Robertson

Open source Java - NOT

via rc3.org

A welcome break in June - JavaOne and NFJS!

This deadline stuff is getting old. I've got another one tomorrow and I'm toiling away again tonight. On the bright side, today I registered for both the JavaOne conference and the No Fluff, Just Stuff Research Triangle Software Symposium.


Another JSTL quick ref

via java.blogs

Defending ugly old JSP.

Russell Beattie complains about the ugliness of JSP, even with the improvements of JSP 2.0. I have to agree. JSP is ugly. JSP also does very poorly in the separate-logic-from-presentation department, scoring an entanglement index of five - and JSTL does not help at all. JSP is butt ugly, but in JSP's defense:

  • It is possible for JSP source code to be valid XHTML. Russell could have done this in his mock-up example by setting a variable and then using the ${var} syntax instead of using "an embedded x:out tag within the href attribute". In theory, by validating your JSP source code as XML and by pre-compiling the JSP at build-time you can weed out a lot of potential errors.

  • Other popular web template languages are just as bad. Velocity, FreeMarker, and Tapestry's template language all have entanglement indexes of five as well.

  • The option of embedding Java code in JSP makes JSP very powerful. Like C++, JSP gives you enough fire-power to blow your entire leg off with one pull of the trigger.

  • Compiling down to Java byte code makes JSP very fast.

  • JSP is an accepted Java standard, it's built-in, it's well understood, and it's easy to find experienced JSP developers.

That last point seems important to me. Perhaps it is not justified and I'm just a Sun lemming, but I'm a little wary of Java web frameworks that attempt to completely side-step JSP.

This just in.

Deadlines still suck - so get the coffee brewing, it's gonna be a late night.

ECMA Standard C# - a clever trap set by Microsoft.

Havic Pennington: Microsoft has set a clever trap by standardizing the core of the CLI and C# language with ECMA, while keeping proprietary the class libraries such as ASP.NET and XAML. There's the appearance of an open managed runtime, but it's an incomplete platform, and no momentum or standards body exists to drive it to completion in an open manner. Many interesting class libraries are clearly encumbered by Microsoft IP and nobody concerned about legal liability will want to ship them. The core may also be encumbered, though that remains uncertain.

Aside from IP issues, Microsoft controls the .NET platform. They will always be ahead, and it will always be tuned for Windows. This is the wrong direction for free software, if we want to win the war, and not only some battles.

That's from an interesting article by Havoc Pennington of the GNOME project, who is currently considering a move from C/C++ to Java or C#. Found via JRoller blogger Emil Eifrem

Why am I doing this Control Flow stuff?

Maybe I should explain why I'm wasting valuable late-night Roller development time with this continuations stuff. I'm experimenting with Control Flow because I'm frustrated with Struts (and other web-MVC frameworks) lack of support for building complex web applications where user-interactions extend over multiple pages. I'm tired of little ad-hoc tricks like session attibute here, request parameter there, breadcrumb stacks, and hidden fields that developers must remember to place on each page. There has got to be a better way and a continuations-based approach seems like it may be that better way. Ken McLeod explains the appeal of a continuations-based approach quite nicely:

Ken MacLeod: Continuation-based web frameworks let you write complex, modeless, interactive web applications in a top-down, linear fashion as simple as writing command-line based applications that prompt for input.

That sounds great, but I don't really want to switch to a new framework to take advantage of a continuations approach. I've got an investment in Struts and JSP and what I would really like to do is to learn from the continuations-based frameworks and, if possible, apply that knowledge to my existing webapps. What I would like to learn is:

  • Should you write entire webapps as "top-down, linear" programs, or should you just use a continuations-based approach for portions of webapps, perhaps only the parts that involve multi-page user-interactions. Charles Miller points out an important reason why you might not want to take the entire-app approach: webapps must be able to provide meaningful and bookmarkable URLs (cool URLs) and some continuations-based frameworks make this difficult.
  • Does it make sense to use Control Flow in the context of a plain-old web-MVC based framework (e.g. Struts, Webwork). How would you do this? Does the Control Flow script kick in before an Action is run, as part of the Front Controller, or after the Action completes?
  • Does it make sense to use Control Flow in the context of a next-generation web-MVC based framework with events and server-side UI components (e.g. JSF, Tapestry)? How would you do this? How should the Control Flow engine fit into the component request/response lifecycle?

There you have it. Please, leave a comment if you have any insight into any of the above questions.

« Previous page | Main | Next page »