Archive for the 'Reviews' Category

Cool CBT

After enough time in technology, one tends to become pretty jaded about vendor claims. I’ve seen enough miracle solutions before, most them involving code generation to “eliminate the developer.” It has gotten to the point that if I even hear a vendor mention SOA, I whip out a can of Bear Mace and let them have it.

So it came as a great personal surprise when I actually saw a vendor demo for something both cool and practical. I sit on the .NET Center of Excellence for our oversized company, and part of the role is listening to vendors show off their latest and greatest. Our last demo was from a company called InnerWorkings and I had honestly never heard of them before the demo.

InnerWorkings has an incredibly awesome computer-based training (CBT) system for learning .NET. It goes beyond book reading and is heavily based around coding exercises which are even scored by the system. It has a Visual Studio plugin for working with the vast library of learning material and links to O’Reilly’s Safari Books for reference.

I had never seen a CBT product before this which I would actually considered to be effective. This looked good enough that I would almost be willing to invest my own dollars. If you need to bring a development team up to speed on .NET programming, or a specific area on the bleeding edge, I highly recommend taking a look at InnerWorkings.

New Kid on the Block

On this cloudy Dallas Saturday morning, the ExtJS team announced the availability of Ext Core (beta). Ext Core is the core DOM selection, manipulation and events library of ExtJS which has been extracted out into a separate library released under a more liberal license. They smartly released this under the very permissive MIT license, in contrast to the cancerous GPL used for the full ExtJS.

What makes this interesting is it positions Ext Core as a direct competitor to the popular JQuery library. I really like both ExtJS and JQuery, so I decided to run a quick comparison of the two libraries to see if Ext Core is up to the task of replacing JQuery in my developer toolbox. Since there is so much overlap between the two, it makes no sense to use both.

Round 1 – Size

Library size of the two is pretty close. The minified version of JQuery runs about 56K, while the minified version of Ext Core weighs in at 75K. The 19K difference might matter for an iPhone application, but even then, I would consider it negligible. Both are pretty small libraries, so we’ll call Round 1 a tie and move on to feature comparison.

Round 2 – Load Event

How each of these libraries works the document ready event is more a matter of style. The JQuery convention is to use the dollar sign ($) for for operations, although you can fall back to using the full name (jQuery). Setting up a ready event in JQuery looks like this:

$(document).ready(function() {
    // do cool stuff
});

Ext Core uses the static Ext class for the same functionality. Like the jQuery object, the Ext object is the heart of Ext Core. Setting up the ready listener in Ext Core looks like this:

Ext.onReady(function() {
    // do cool stuff
});

One big difference is the onReady method can take an additional parameter specifying the scope in which the onReady method should execute. This is not a big deal in most cases, but shows Ext Core’s attention to support object oriented JavaScript. Since I’ve never actually needed to specify the scope, I’ll call this round a tie too.

Round 3 – Selectors

This is the heart of both libraries, and a full comparison could fill a dozen pages. The short story is they both support basically the same set of CSS3 selectors along with some custom enhancements. From looking at the documentation, I couldn’t find any typical use cases that either couldn’t handle. Like the document ready example above, it just comes down to a matter of convention. For example, here is the code from each to add a class to a set of nodes:

// JQuery
$('td.age').addClass('someclass');
 
// Ext Core
Ext.select('td.age').addClass('someclass');

One major style difference between the two is that Ext Core has a tighter focus in handing elements with ids, since that is critical to the full ExtJS library. For example, Ext Core has the get() method to directly grab an element by ID, along with a memory-friendly fly() method. The fly() method does not create a new element wrapper in memory, and instead reuses a single global element object. This can save a lot of memory when you just need to do quick manipulations of single objects.

// Add a class to the element with ID of 'header'
Ext.fly('header').addClass('someclass');

For the memory saving fly operation, I’ll give the advantage to Ext Core, although they are essentially equal in their DOM selection abilities.

Round 4 – Events

Like the selectors above, there are basically style differences between the two libraries in how they handle basic event use cases. JQuery adds some methods to the jQuery object for registering common events. For example, here is the code to add a click event to a button for each, including the JQuery shortcut:

// JQuery with bind()
$('#myButton').bind('click', function() { alert('Clicked');});
// JQuery with shortcut
$('#myButton').click(function() { alert('Clicked');});
// Ext Core
Ext.fly('myButton').on('click', function() { alert('Clicked');};

JQuery brings some some additional enhancements to the game in the form of “live” events. This provides a way of attaching an event to all current, and future, instances of the selector. JQuery also supports event namespaces, where events can be fired in a hierarchy. Both are powerful concepts, but I’ve never had to use either.

The secret sauce for Ext Core is in extended configuration. With Ext Core events, you can also configure the scope (a common Ext Core theme), along with configuring the event propagation, extra parameters, and a delay. Here is a sample of a click event configured with ‘this’ scoped to the onClick event itself, to only fire once (single), with a delay of 100ms and an additional parameter (forumId) to be passed to the event handler:

el.on('click', this.onClick, this, {
    single: true,
    delay: 100,
    forumId: 4
});

So again, I’m going to call this round a tie. Both libraries handle simple event binding very easily. If you need the live events, the nod goes to JQuery. If you need the extra configuration options, Ext Core is your best bet.

Round 5 – DOM Manipulation

Once again, the two libraries provide a near complete overlap of basic DOM manipulation functionality. Each can easily create, move, add and insert DOM elements.

JQuery aims for convenience. For example, one feature of JQuery I really appreciate are simple methods to clear the content of a DOM element and set the text. For example, given:

<div id='message'>First Message</div>

With JQuery, it is simple to update the text:

$('#message').text('New Message');

The text() method removes all the child nodes of the matching elements and appends a text node containing the specified text. The text() method without a parameter will retrieve the text for a matching element. For Ext Core, you have to drop down to the DOM to set the new text value:

Ext.fly('secret').dom.innerHTML = 'New Message';

The Ext.Element class does not provide simple methods for setting the text or removing all the children of an element, which I find to be an annoying inconsistency.

On the plus side, Ext Core provides a lot more methods for manipulating the DOM. One of the cool ones is the radioClass() method. This method will add a class or classes to an element and remove that same class (or classes) from all the siblings. For example, here is a simple table with a row having the ’selected’ class:

<table class="data">
    <thead>
        <tr><th>Name</th><th>Age</th></tr>
    </thead>
    <tr>
        <td>Bill</td><td class="age">20</td>
    </tr>
    <tr class="selected">
        <td>Alice</td><td class="age">21</td>
    </tr>
    <tr>
        <td>Jeff</td><td class="age">22</td>
    </tr>
    <tr>
        <td>Susan</td><td class="age">23</td>
    </tr>
</table>

This one line of Ext Core code will remove the ’selected’ class from the current TR element and add it to the first row in the table:

Ext.select('table tr:first').radioClass('selected');

So for this round, I’ll give the advantage to JQuery for the more consistent API, especially around manipulating the text nodes of an element. This is something pretty simple for Ext Core to address, which they really should. Ext Core does, however, offer more powerful DOM manipulation options.

Round 6 – Effects

I’m not a big effects junkie, so I won’t have a lot to say about this. Both Ext Core and JQuery provide a very similar set of effects for elements (hide/show, fade, slideIn/Out, etc…). Ext Core provide a more powerful API for creating custom effects, while JQuery addresses this with its rather extensive set of plug-ins. I’m calling this one a tie.

Round 7 – AJAX

Ext Core and JQuery both make AJAX simple, but again, we’ll see that JQuery adds more simplified methods while Ext Core offers more powerful configuration. Here is a sample of an AJAX call that returns JSON data:

// URL returns a JSON object like this: {name: 'Tim'}
 
// JQuery 
$.getJSON('http://myurl', function(data) {alert(data.name);});
// Ext Core
Ext.AJAX.request({
    url: 'http://myurl', 
    success: function(response) {
        var data = Ext.decode(response.responseText);
        alert(data.name);
    }
});

JQuery provides the simplified getJSON() method where the parameter to the callback has already been decoded into a JSON object. For Ext Core, the callback receives the XHR response object and you have to decode the text to JSON.

The Ext Core request() method demonstrates a typical ExtJS convention of using a JavaScript configuration object as a parameter instead of using multiple parameters.

Both libraries provide strong AJAX support, so we’ll go with a tie for this round too.

Round 8 – Documentation

There is no contest in the documentation department. While the JQuery documentation has improved, the Ext Core documentation blows it away. From the excellent manual to the high-quality API documentation, Ext Core sets the standard for what all documentation should look like.

Round 9 – Intangibles

For JQuery, the biggest intangibles are its plugins and support from Microsoft. JQuery is intentionally designed to provide a simple core set of functionality and to be easy to extend. There are hundreds of plugins people have written for JQuery in the Plugin Repository. As with all things open source, some are very good and some are kinda crappy, but you can be pretty certain to find a plugin that covers about anything you might be trying to do that is not covered by the core JQuery API.

Microsoft support is also a biggie. They have decided to include JQuery as a base JavaScript library in their web tools going forward. This means you won’t need to get special blessings to use JQuery in large corporate environments — it will be part of the core Microsoft bundle, with support and all.

Ext Core, being brand new, is lacking in both community and support. Ext LLC, the company behind ExtJS and Ext Core is a small software shop trying to get by in a tough economy. While their products are cutting edge, I’m expecting them to be bought out by a larger company before too long. I keep trying to talk my Spring Source contacts into buying them, but I have a feeling they’ll be bought by Adobe.

So from an intangibles perspective, JQuery is the winner. It is guaranteed to have longer legs under it, at least until we see where Ext LLC ends up.

Conclusion

Both Ext Core and JQuery are solid, complete base JavaScript libraries. JQuery leans towards simplicity while Ext Core offers enhanced configuration. The choice of which to use will come down to where you are now.

  • If you use JQuery, and don’t anticipate using ExtJS, stay where you are. You’ve got a winner.
  • If you use ExtJS and have used JQuery as a light weight option for when you didn’t need the widget library, Ext Core is now your library of choice.
  • If you are in search of a JavaScript library, the choice is tougher. Unless there is a particular JQuery plugin you want to use, I recommend going with Ext Core. It starts laying the groundwork for using ExtJS, which you’ll want to do as you get in to building RIAs.
  • If you’re a corporate Microsoft shop, you probably don’t have a choice. JQuery is now something you can slip by the infosec police without making waves.

Ext Core is definitely a winner. In the past, I have used JQuery for projects that need simple DOM manipulation and ExtJS for when I need the widgets, layouts, etc… Now that I have Ext Core, I don’t see using JQuery anymore for the simple cases. I can standardize on using the same API paradigm between Ext Core and ExtJS.

Follow-up #1: Beyond the Core
Follow-up #2: Slick Speed

On the Cloud

Unless you’re a geek from another planet, you’ve been hearing the buzz about cloud computing for the past year. Amazon has been one of the major thought leaders in this space with their EC2. Combined with their other web services, Amazon provides about the most complete cloud implementation. There is only one problem…. price.

A small EC2 instance would run about $73 a month. Yes, you can go cheaper if you turn it off, but how many people actively turn off their websites? It can get cheaper if you reserve capacity, but the $325 up front cost is a bit too steep for me.

I’ve been looking at cloud solutions for a development playground for a while. After taking a look around, I quickly discovered that quality hosting of Java applications is pretty difficult to find, especially given my requirements. I want a host that is running Java 6, Tomcat 6, MySQL 5 and allows me to do what I want with the instance. Shared hosting is obviously not the solution, so I looked at “Virtural Private Servers (VPS)” as an option.

Even VPS has been a pricey option. GoDaddy wants around $45/month for a virtual Linux server with 512MB of RAM. I tried one for a bit, but it wasn’t cost effective for a playground environment. I had about given up hope until I stumbled upon Mosso.

Mosso is Rackspace’s new entry into the cloud computing space. They are trying to get a foothold against Amazon in a pretty simple way, trash them on price. For an equivalent size cloud server, Mosso costs about the same as Amazon. But unlike Amazon, Mosso scales down to smaller instances. For about $22/month, you can get a Linux cloud server with 512MB of RAM that you can do what you want with.

I signed up for one of Mosso’s cloud server accounts last week to use for Java. 512MB of RAM is plenty for what i want to do. You can pick what Linux distro and version you want to use, and I was pleasantly surprised to see they had the latest and greatest (Ubuntu 8.10/Fedora Core 10). They are obviously targeting this at alpha-geeks.

One big difference with Amazon is that Mosso does not offer Windows. They provide you with a very naked (read secure) base Linux install to start with. You have to be competent with Linux (ssh, bash, shell commands) to even have a chance with Mosso. I’m pretty comfortable with Linux, but there are still some things I had to consult some friends on. In the end, I setup exactly what I wanted: Ubuntu 8.10, JDK 1.6.0_13, Tomcat 6.0.18 and MySQL 5. I’m using the instance to run some Java sample applications I’m working on and will use it as the backend for a Facebook application I’m going to play with.

The only downside I’ve found with Mosso is that it is pretty immature compared to Amazon, especially in the area of documentation. You can see the Rackspace guys are working on it, but there are still a lot of holes. I was pretty frustrated setting up iptables for a firewall because the documentation says “look at this sample” but there was no sample attached. Fortunately, Google and a friend saved me. The documentation for setting up email has the same holes.

Once I got past the documentation issues, Mosso has proven to be a winner. This is going to put a lot of pricing pressure on Amazon and the others in this space. You’d have to be an idiot to pay GoDaddy twice as much for the same thing. I’m willing to bet you’ll see about everyone hit $20/month for a usable cloud server before too long. Amazon will definitely have to drop their price.

On a side note, here is a good sample of an iptables rules file you can use with Ubuntu on a Mosso cloud server. Just be sure to change 10001 to whatever port you want to use for SSH:

*filter
 
# Allow loopback adapter
-A INPUT -i lo -p all -j ACCEPT
-A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT
 
#  Accepts all established inbound connections
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
 
#  Allows all outbound traffic
-A OUTPUT -j ACCEPT
 
# Allow SSH (very important - set to right port)
-A INPUT -p tcp -m tcp --dport 10001 -j ACCEPT 
 
# Allow 80 and 443 (web traffic)
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT 
 
# Allow ping
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
 
# Reject all other inbound - default deny unless explicitly allowed policy
-A INPUT -p all -j DROP
-A FORWARD -p all -j DROP
 
COMMIT

New Laptop

I finally got my new work laptop yesterday. For the past month and a half I had been using my personal Dell Latitude D620 for daily development. It is a good little workhorse but is getting a bit dated in the CPU department and I’ve never been particularly fond of the screen, which I always found a bit too dim.

Now say hello to my little friend (and the D620’s big brother), the Latitude E6500. I got it with the 15″ LED-back lit screen, which I can’t recommend highly enough. This screen blows away anything else I’ve seen and is on par with the new screens on the macbook pros. Toss in a dual-core 2.8ghz CPU and 4GB of RAM, and you’ve got the perfect software development laptop.

I got my E6500 with Windows Vista. I know there are plenty of Luddites who still stick with XP because they think it is “faster”, but Vista just rocks. I’m using it for Java development and have installed IntelliJ, MySQL 5.1, Apache HTTPD. All work flawlessly and IntelliJ is beautiful in Aero.

Speaking of a developer laptop, since I just had to do this, I’ll share my “Java on Windows” essential tools list:

  1. Java 6 JDK
  2. IntelliJ IDEA 8
  3. MySQL 5.1
  4. Subversion 1.5
  5. Tortoise SVN
  6. WinSCP
  7. Putty
  8. UltraEdit
  9. SnagIt
  10. WinZip Pro
  11. DbVisualizer
  12. Firefox 3 with Web Developer, Firebug, ColorZilla and Tamper Data add-ons
  13. Chrome
  14. Tomcat 6

This is my must-have kit for Java development tools. Yes, some are not free, but they are well worth it. Note that I don’t get into all the libraries. Of course I’m using Spring, JUnit, MySQL Connector/J, etc… This just covers core tools.

Core Tools + E6500 = Happy Java Coder

Catching the 8

The latest version of my favorite Java IDE, IntelliJ IDEA 8, was released today. I’ve been using IDEA since version 2.0 and have consistenly upgraded my personal license every new release. This time is no different. IDEA has been my favorite IDE for the simple fact it is the ultimate coders tool. No other IDE I have ever used has been so good at helping me with the things I need while staying out the of way the rest of the time. There is not a better Java development environment on the planet.

Yes, I’m sure I’ve offended the Eclipse mafia. I have used Eclipse, on serveral occassions. But I go back to IDEA every time. It is hard to describe the difference in feel between the two. Eclipse is like a swiss army knife — it does a little bit of everything, but none of it particularly well. IntelliJ IDEA is like a Spyderco knife, the perfect cutting instrument. Eclipse is the Visual Basic to IntelliJ IDEA’s emacs.

So what’s new with IntelliJ IDEA 8? The coolest thing I’ve used so far is the built-in JavaScript debugger. You no longer have to depend on Firebug to debug JavaScript files in a project, you can simply set breakpoints in the JavaScript and run the page. For the full list of the new features, check out this page. I’ll be doing a more in-depth review of IDEA 8, using it with a Spring MVC web project.

If you haven’t tried IntelliJ IDEA, and you’re a Java developer, I strongly encourage you to check it out. Personal licenses are only $249 and they are well worth it. Eclipse may be free, but you get what you pay for.

Day at the Opera

Last weeks big news was the release of Firefox 3.0. But a quieter event happened the Tuesday prior — Opera 9.5 was released. I’m a regular user of Firefox, although Firebug is starting to piss me off. I haven’t used Opera since they experimented with an ad-based model serveral years ago. It was always fast, but felt clunky.

Opera 9.5 is a huge improvement and I was very impressed. The look-and-feel is different from prior versions and was not so wierd as to be uncomfortable. Rendering speed was very fast and JavaScript also is very fast, which was my main interest. They also incorporated a JavaScript development tool similiar to Firebug that is called Dragonfly. Beyond being a clever play on words, Dragonfly provides an integrated, supported tool to handle what I was using Firebug for.

So I suggest taking a look at it. I’ll probably end up using Firefox 3 more often, as I’m a creature of habit, but the folks at Opera Software have done a great job and it is always nice to have another standards-compliant browser to test with.

Drinking from the Fire Hose

I’m about half way through Douglas Crockford’s new book JavaScript: The Good Parts. Crockford is a JavaScript architect and Jedi working at Yahoo!. He also maintains the JSON format and is on the ECMAScript committee. This book is his effort to shine a new light on JavaScript as a serious language in its own right.

The book is a concise 150-ish pages and it is information dense. In fact, it is mind-melting dense. Crockford says up front that it could take serveral readings to really grasp all the concepts and I would absolutely agree. I’ve been playing a lot recently with JavaScript, and thought I was starting to get the hang of it, but this book is like jumping from C++ for Dummies to Modern C++ Design. It leaves my head spinning, but is fascinating at the same time.

This book gets a big thumbs up and I would highly recommend anyone interested in what JavaScript is really about check it out. There are very few truly good books on JavaScript. This book, along with David Flanagan’s JavaScript: The Definitive Guide are the best out there and should be the starting points for anyone who decides to make the effort to really understand JavaScript, the real language behind Web 2.0.