Congratulations to Safari

Safari has just become the first released browers to pass the Acid 2 test. Acid 2 is a complex HTML, CSS and PNG layout that was created to test the standards compliance of browsers for some of the latest Web Standards. The word is that Opera will not be far behind and other KHTML/WebKit based browsers like Konqueror will soon pass as well. (WebKit is a Mac OS X framework for displayign HTML based on the Open Source KHTML project originally produced by the KDE team. Web Kit and KHTML, after a rocky start, share a lot of code and patches.)

This kind of standards support is great news for the Web and web developers. Standards support allows for developers to create sites more easily (and thus more cheaply). Standards based Web development can reduce the amount ot HTML, reducing the size of pages, which makes downloads faster, and lowers the bills on web hosting for the site owners. Hopefully it will be followed by wider support when IE 7 is released. Firefox/Mozilla already have really good standards support and they will certainly catch up to Safari very soon.

What’s Next for the Java Language?

With Java 5 having been out for a while now, I started to think about what might be next for the Java language. I’m not thinking about what might change with JEE (nee J2EE), or the extensions or libraries or anything like that. I’m thinking about the core language itself. There were not a lot of changes between Java 1.1 and Java 1.4. The assert keyword was added and there were a number of additions to the core libraries such as NIO, but again, I wanted to think about the language itself and not the libraries so much.

What’s New in Java 5

Java 5 saw a lot of changes many of which, at least on appearances, seem to be a response to the .NET platform and the C# language. A little bit of healthy competition spurred on some advancements in the language. To start, I wanted to think a little about these recent changes because there are some really great language enhancements in Java 1.5.

Type safe Enums

Type safe Enums have added a full-class citizen of the Enum Pattern to the Java language. This is in many ways a better implementation than the C# version in that they are full classes that can have methods and data that belong to them as well. As is often the case with Enum types there are a number of associated helper methods that pertain to the Enum and the class itself is the most logical place for it to live.


Generics offer compile time checking that allows you to create type safe but generic classes. The most often used example of this is type safe collections classes.


Varargs allows a method creator to accept a variable number of arguments to a method. This means the the user of the method does not have to manually create an array of arguments (it lets the compiler do the work for you). This is a handy extension.


Annotations allow for an easy way to add metadata to classes, methods, etc. This is great for tools and frameworks such as unit testing and extensions like aspect-oriented programming.

‘Enhanced’ for loop (read foreach loops)

The new for loop provides an easy way to iterate over a collection without having to manually test exit conditions or do type casting.


The automatic conversion of Objects to primitive scalar types and vice-versa.

(Most of the features are backwards compatible with previous JVM versions once they are compiled, but they are also areas where there is potential for non-backwards compatible optimizations in the future.)

What’s Next for Java 6?

I won’t claim all of these are likely or for that matter even good ideas. This is my attempt to brainstorm some possibilities for discussion purposes.

Full Closures

Java has support for a form of closure using anonymous classes, but Full Closure support is not there. Full Closures are similar to pointers to functions in some ways. It allows libraries to allow for the customization of behavior by passing a closure as an argument to a method call. A common example of this is a filter passed to a method that iterates over a collection to return a sub-collection. Full Closures also allow the sharing of variables both in a code block and out of the code block (so changes in one area effect the other). With anonymous classes in Java, the variables passed into the method have to be final to that method. Full Closures have been re-popularized by languages like Ruby and Python and of course older languages like Lisp.

Functions as First-Class Citizens

Full Closures often are implemented as functions. This might require the idea of having functions as first-class objects. This is not as crazy as it sounds, this is done in other programming languages such as JavaScript. Of course with functions as first-class objects it also opens up the possibilities of dynamically adding methods to an object or class, like JavaScript or delegation features like many other languages including C#.


Subroutines are a special case of a Coroutine that have only a single entry and exit point. Coroutines on the other hand have multiple potential entry points. A Coroutine will “remember” where it last left the routine and will begin just after that point when the routine is again invoked. This is a very helpful way to build things like state machines without having to do a bunch of if-then conditionals in a method. See the yield statement in Python as an example.

Allowing the Separation of Object Allocation and Initialization

The new keyword in languages like Java and C# perform two functions:

  1. Allocate memory on the heap for the object to live.
  2. Initialize the object

A constructor only allows you to control the initialization of the object, not the allocation aspects of that object. The allocation is a low-level routine that is done for you. Some languages like Objective C separate these constructs [[Object alloc] init]. Allowing some control over the allocation would allow for built-in support for things like Factory patterns and even for things like distributed objects by instantiating an instance on a remote system and returning a Proxy to that object.
(I think this one probably falls into the ABSOLUTE least likely to happen, but it’s cool to think about.)

Deterministic Disposal

Java has the finalize() method which is called prior to garbage collection of an object. Garbage collection is not deterministic in that you can not know when a specific object will be GCed. The finalize() method is therefore only useful for special cases regarding memory cleanup.

Disposal (ala C# IDisposable interface) on the other hand can be used to cleanup any resource because the dispose() method is called when an object goes out of scope. This can be used to cleanup non-memory resources like IO or SQL connections, rollback uncommitted transaction, whatever you want.

Some Things I Hope They Leave Out

C#-esque Properties

Properties are a shortcut for creating accessors and mutators (getters and setters) in C#. Properties are really compiled into methods behind the scenes. Why does this matter? Because implementation sometimes matters and can have side effects. Direct access to an object variable is not the same as accessing an object through a method. Going through a method the object is accessed through a copy of a pointer (pass by reference vs pass by value issues). While this is not a common issue you would run into, if you ever did figuring out these interactions could be much more difficult.

x.Arg = new Object():
Object y = x.Arg;
x.Arg = new Object();

If x.Arg is a direct variable access, then Arg and y will be the same value in the end because they point to the same memory location. If they are methods, then they will be two different objects. Weird huh?

What Else?

There’s a constant battle between extending the language with useful functionality and keeping the implementation clean and true to a coherent design philosophy.

What am I missing? What can or should be added to Java that would improve the language, but not destroy it’s nature?

FastSOA Discussion

Frank Cohen (founder of PushToTest, who I helped for a while on TestMaker) has been blogging about a system he’s calling FastSOA. It’s an attempt to help build a more scalable SOA architecture by avoiding the some high cost operations like marshalling XML data into native objects. As I understand it, it’s basically a proxy that takes incoming SOAP requests and tries to optimize the SOAP response by avoiding (as much as possible) the costs of marshalling to objects by going directly to datasources and only going to application servers if absolutely required (by business rules for complex data manipulation). I responded to his initial post with some comments off the cuff and he posted them on his blog, so I thought I’d link to it:

There’s a response from William Martinez Pomares, an engineer working with him, and a bit of a follow on from me. It might be a good read, because I didn’t understand the whole thing at first, but I think I might get it better now.

Looks like Frank is also writing a book on FastSOA, check it out:

VS.NET Developers Should Use ReSharper

Visual Studio is known for its WYSIWYG, drag-and-drop user interface creation. But when it comes to actually writing code, it’s fairly anemic. Sure it has code completion (Intellisense ™) and syntax highlighting and a few things like that, but it doesn’t offer support for more advanced functionality that many people, especially those from the Java world, have come to know and love.

Features such as:

  1. refactoring support
  2. finding usages of classes, methods, and variables
  3. code generation for things like property getters and setters
  4. real-time error highlighting

As you probably figured out by the title, there is hope! The makers of IntelliJ (a Java IDE) have a plugin for Visual Studio.NET 2003 called ReSharper. I highly recommend it if you are doing anything serious in .NET. It is a huge productivity booster and really helps with refactoring tasks and things of that nature. You will be thrilled if you are using any sort of Agile processes that require you to do regular refactoring.

While Visual Studio.NET 2005 has addressed some of these issues, I think the ReSharper tool adds a lot of functionality that is very useful. 2005 is also not out of beta yet, so if you are working on production code, most likely you’ll be using 2003 for a while. I highly recommend that you try it out!

(I don’t work for Jetbrains and never have, I am just a huge fan of ReSharper and want to spread the love.)

Server Side Include (SSI) Templating

Templating for web pages is a method to separate form from content. Just like HTML and CSS separate form from content, a templating system allows you to further separate the common structure of a page from the “Stuff” that people want to read. Is there a best way to do templating? I don’t know, but here’s a way that I think is good:

Often times when people do templating they include a common header, a common footer and possibly navigation in each of their source HTML files. Over time the size of the site grows and the number of pages becomes large. If you ever want to change the layout of the site, you often find that there are changes that you have to make in each file because the layout has creeped into each one.

By thinking about Templating in a slightly different way, you can turn the problem on it’s head and never worry about it again. Rather than having 4 files:

  1. page.html
  2. header.html
  3. footer.html
  4. nav.html

(page.html includes header.html, footer.html and nav.html)

You can have 3 files:

  1. page.html
  2. page.body.html
  3. template.html

In this scheme page.html is a level of indirection that looks like:

What you see with the above code is that the main included file is the template.shtml page. The other 2 directives are setting parameters that will be used in the template to load the proper body content and set the title. You can create more variables like this if you need to.

page.body.html will have just the main content of the page.

Blah, blah, I'm the content of the page.

template.html will then have the entire markup of the site except for the body. It can have includes if need be, but its main purpose is to contain the structure of the site including common elements like headers, footers, navigation, etc. The template.html page will include the value from the body variable set in the page.html (as described above) and include it in the proper place:

Common Title | <--#echo var="page.title" -->


This lets you focus on the content when you want to worry about content and focus on layout when you want to worry about that.