Home | August 2003 >>

MacIntoshes, Java, Linux, ...

Mac OS X is a hot topic in Java developer circles. Many people bought G4 based Mac OS X machines in the past year. And they all are eagerly awaiting the release of the G5 based Next Big ThingTM from Apple.

Go to java.net or Artima.com or javablogs.com, and you will see the question being asked again and again: should I buy one?

I'm not in the market for a new computer right now. But if I am, I would seriously consider a Mac. Here are my compiled list of pros and cons:

Pros:

  • James Gosling uses one.
  • James Duncan Davidson uses one.
  • Dave Thomas uses one.
  • Brian Gilstrap has one.
  • Brad Shuler has one.
  • Brian Coyner has one.
  • It's Unix with a good GUI.
  • The G5 is more powerful than the Pentium 4.
  • Mac OS X has superb applications with wonderful UIs.
  • Swing is accelerated on Mac OS X.
  • I'm familiar with the Mac---I used a Mac in 1985.
  • I've been using Linux/x86 for too long. It's time for something different.

Cons:

  • It's going to be a whole new platform. And it has a one button mouse.
  • It's more expensive.
  • It has less applications. Whatever there are, Apple is trying to kill them off.

This reminds me of my switching to Linux almost a decade ago. I did not go through any of these analyses. I simply downloaded the floppies, all seventy-two of them, and started the installation. Never mind that it was hard. Never mind that my hardware didn't fully function under it. Never mind the three days of surfing the Net to figure out how to make my proprietary interface Sony 2X CD to work. I was so glad when I got the login prompt!

I was running away from Windows 3.1 then. I'm not running away from anything now. The choice between Linux and Max OS X is a genuine one, at least for me.

Having genuine choices is always a good thing!

Tags :

Cygwin, Libxml/libxslt, Secret Workhorses, ...

I don't know why, but the IT press has not been eager to report on certain Free Software packages.

Granted, gone are the days when the IT press won't even acknowledge the existance of GCC in their compiler comparisons. However, there are still powerful software packages that elude mention by the press.

Cygwin is a wonderful distribution of a POSIX library for Windows and a whole lot of free software based on it. Among them the GCC compiler (C, C++, Objective-C, Fortran 77), the GNU tools (bash, awk, sed, bison, etc.), scripting languages (Perl, Python, Ruby, Guile), Typesetting systems (TeX, groff, DocBook), Editors (vim, Emacs, pico), Network servers (telnet, ftp, ssh), XFree86 server and clients, PostgreSQL server, a Windows SDK (creating DLLs), Internet software (Pine, lynx, wget, curl), and a lot more. I know a lot of people who use Cygwin in their daily work. But you can't find a book on Cygwin, not even O'Reilly has a title about it.

Two packages I take particular delight in using that comes with Cygwin are the libxml and libxslt libraries. These libraries are originally developed for the GNOME project, but have since been ported to many platforms, including the Cygwin platform. They offer the command line tool xmllint that parses and validates XML files agains DTDs, and xsltproc that applies XSLT stylesheets to XML files. Being native executables, they don't suffer from the startup delays typical for Java based parsers and transformers. They are also faster and consumes less memory. But you can't find a book on libxml and libxslt, not even O'Reilly has a title about them.

Why?

Tags :

Things we don't understand

Over the years, I have observed a curious phenomenon in my programmer friends circles. We are attracted to things that we don't understand. And we ignore things that's already at our disposal.

Take Struts, for example. I heard it from smart people. Struts is MVC, they say. Struts is Model-2, they say. Struts is Open Source, they say. Struts In Action's a cool book, they say. Struts is patterns, they say. Struts decouples, they say. Struts is flexible, they say.

I don't know what got into me, but I caved in to my curiosity. I bought two Struts books. I downloaded the Struts binary distribution. I checked out Struts CVS. I cvsup everyday. I built Struts from CVS. All fine and dandy.

Then, then, ... then I fell into XML hell. For days, I sit there trying to figure out which XML file I have to edit to tie all of my decoupled components together.

And then, then, ... then I fell into the Jar hell. There's struts.jar. There's commons-lang.jar. And there's jakarta-oro.jar, etc., etc. You are supposed to put them into your WEB-INF/lib directory of your war file. Don't put it in your container's lib directory. Great, now my trivial HelloWorld servlet is 4MB big.

And then, then, ... then I fell into the Debug hell. I typed in my URL, and out come a 7 page stacktrace, the same chuck repeated again and again under the guise of "Caused By" or "Root Cause", and cut off right where it gets interesting with "... 42 more lines".

I learned yesterday in a conversation that I'm not alone in my opinion about Struts. I even heard people say that the servlet container itself is already an MVC framework for writing web applications.

Why didn't I look there? After all, I've had a servlet container running on my system since the Jakarta project was announced, what, five years ago. Maybe because it's already there.

Tags :

DRY, SPOT, at what cost, ...

I've heard a lot about the DRY principle: Don't Repeat Yourself, lately. It is also called the SPOT rule.

This really is easier said than done. And violations of this principle can be found everywhere.

A case in point: In Java, any public class Foo must be defined in a file named Foo.java. This is a source of irritation for Java beginners. (Another source is the match up of package declarations with directory structures. Although not required, failing to do so causes problems with the javac compiler in finding the source for a class.)

However the cost of reducing this duplication is too high: either change the language, or use a preprocessor. Imagine writing code like this:

public class __BASENAME__ {
  // ...
}

So we learned to tolerate this ducplication.

Slides, DocBook, PowerPoint Free, ...

Eleven days ago, I gave a presentation at the St. Louis Java Users Group. The topic was JBoss. And here's how I began: "In true Open Source fashion, I'm presenting today's talk on a laptop running Red Hat Linux 9.0 with the Mozilla web browser. The presentation is generated from an XML file based on the DocBook Slides DTD and trandformed to XHTML using Saxon and the DocBook Slides XSL stylesheets."

Here, for the curious, are the tools I used to author the presentation:

  • Emacs - A powerful text editor.
  • PSGML - A major mode for Emacs for editing SGML and XML files.
  • DocBook Slides - An XML DTD and a set of XSLT stylesheets for generating HTML based slides and XSL-FO files.
  • DocBook XSL stylesheets - Used by DocBook Slides.
  • Saxon - A Java based XSLT transformation processor with powerful extensions.
  • TeX - Donald Knuth's typesetting system, generates dvi, PostScript, and PDF files.
  • PassiveTeX - An XSL-FO to TeX translator.
  • xmltex - An XML parser written in TeX. Used by PassiveTeX during the XSL-FO to TeX translation.

The toolchain may sound complicated, but the mojority of the tools are already included with Red Hat Linux 9.0. I already installed Saxon and PSGML for other purposes. The only thing I have to install is the DocBook Slides.

DocBook contains 400 tags. For the presentation I used only 30 tags. Not too bad. Code samples are included verbatim in CDATA sections.

Because in DocBook it is easier to write paragraphs than make bullet lists, the slides are more conversational, and I imagine will be more useful for people who missed the presentation.

The HTML format also allowed me to link to various plain text files rather than having to include them in. This made me more active (and less boring) during the presentation.

All in all, I had a positive experience. I would do it this way the next time.

Oh, did I mention I did not use PowerPoint?

A Pebble, A Blog, Ripples, ...

Major achievement of today: I setup my Weblog using Simon Brown's Pebble.

Pebble is billed as personal blog software. That's exactly what I'm using it for, a personal blog on this site.

The setup is an easy process. I already has a JBoss environment setup. So I just deployed the pebbel-1.1.war into JBoss's deploy directory. I have to explode the war file into a directory since I want to customize it.

The JBoss specific customizations include:

  • Creating a JBoss specific deployment descriptor in WEB-INF called jboss-web.xml, setting up context-root as blog and the security-domain as java:/jaas/blog.
  • Setting up a JBoss security domain called blog. This one uses the UsersRolesLoginModule.
  • The admin/index.jsp has to be rewritten to work with JBoss. Instead of a Redirect, we use jsp:forward now.

The style customization is primarily me throwing away font-family and font-size styles. I don't want to control the font family or font size of my web pages. I also imposed my color style so that my weblog page looks just like my other pages.

A pebble is thrown into my weblog pound. We'll see the ripples of it reaching to all different directions...

Tags :