Objective-J – huh?

September 5, 2008

As an old Objective-C fan, I was surprised and amused to read about Objective-J, an object-oriented enhancement to javascript including the old OpenStep (well, GNUstep) API’s.  It’s for a similar purpose as GWT, I suppose.

Cappuccino is built on top of standard web technologies like JavaScript, and it implements most of the familiar APIs from GNUstep and Apple’s Cocoa frameworks.


Not sure what to think of this, but hey, Objective-C was cool so why not Objective-J?


Google Chrome makes GWT apps Zoom!

September 5, 2008

When I first heard about Google Chrome my reaction was “Huh?  Another browser to support?”  However, now that the browser has been released I’ve realized why they bothered.  It’s simply the fastest and best looking browser for Windows right now.  I love the look of it, but even more so I love the speed of it!

I am the developer and user of online accounting software for small businesses written using the Google Web Toolkit (GWT).  When I tried our software in Chrome out of curiousity I was astounded to see how fast it was – first, it loads regular web pages as fast or faster than Opera, my old favorite browser.  Second, it loads and runs my accounting application much faster than I’ve ever seen before!

I was quite intrigued by this so I went and actually read the comic Google released about Chrome to find out more.  Apparently they contracted a company to write a new javascript JIT engine to run javascript, which they’ve apparently done a great job of!  And, it’s open source.

Hopefully Safari, Firefox, Opera, and (if we’re really lucky) Internet Explorer will take advantage of their Javascript engine so we can all enjoy faster Web 2.0 DHTML applications.

SSH config file to the rescue

August 31, 2008

I’ve recently switched my hosting from single self-managed dedicated server at 1and1 to a managed virtual private data center on “the cloud” with ENKI consulting.  The benefits of the grid computing technology they are using are numerous, including improved security, automatic redundant failover, and great mangement and monitoring tools.

As part the improved security, each component of the system (webserver, database) runs in its own virtual machine, and only has the bare minimum access to files and other services that it needs.  When setting these up, I have to ssh to each component individually.  Access is provided to the seperate components by having a different ssh port on one externally available IP address.

Typing in “ssh -p 7543 dobes@543.32.54.32” with varying port numbers, usernames, and IP addresses can be a pain.  Today I found out that you can specify aliases in your ssh configuration that set up connection options, hostnames, and IP addresses.

Simply edit ~/.ssh/config and put sections like:

Host glassfish-live

HostName 543.32.54.32

Port 7543

User dobes

Compression on

IndentityFile  ~/.ssh/id_rsa_live

Each time ssh finds “Host” it treats the settings that follow as specific to that host, and “HostName” tells it the “real” host to connect to.  These aliases are a great shortcut and I was so pleased to discover them I couldn’t wait to share them.

Hope you make good use of this one …

GWT: Using source-path to create your own JRE emulation classes

August 15, 2008

I recently ran into an issue where a class I share between GWT and server-side java code would really, really benefit from being able to accept or return a Calendar object.  However, GWT doesn’t come with a Calendar class, so the appeared to be impossible.  Or, is it?

After some digging around in the documentation I discovered that GWT provides a directive in their module XML called “super-path”.  By adding something like:

<super-path path=”gwtonly”/>

To my *.gwt.xml file, I can tell GWT to load my own emulation classes when compiling javascript; when running in hosted mode, it will use the Java implementation of these classes.

Here’s an example source tree structure for this:

  • myapp/
  • myapp/MyApp.gwt.xml
  • myapp/client/*.java
  • myapp/gwtonly/java/lang/Calendar.java
  • myapp/gwtonly/java/lang/GregorianCalendar.java

In my Calendar and GregorianCalendar I just define exactly the methods and constants that I need for the code to *compile*.  Note that I’m not planning to actually use these classes;  I could, but the implementation is so minimal it would cause confusion for future programmers who wouldn’t understand why the calendar class behaved so weirdly in client-side code.

However, now I discovered that I have errors in my code when I compile.  Huh?  In eclipse it’s happy but in GWT it says something like “package declaration should be java.lang, but it should be myapp.gwtonly.java.lang”.  Oh, I see, it’s really using that package as a source folder, not as a package.  So, I fix it by changing the “package” declaration at the top to “java.lang”.  Guess who is unhappy now?  eclipse!  The two compilers can’t see eye-to-eye any more.

There is a solution – eclipse has a feature called “exclusion filters”.  I open the “Java Build Path” panel for the project, find the source folder that has all of this in it, and add an “exclude” filter for myapp/gwtonly/.  Now eclipse just ignores those files; I’ve lost a lot of eclipse java features as a result, but at least it works.

All this is part of my work on simple online accounting software, if you’re a consultant, entrepreneur, virtual assistant, bookkeeper, or freelancer go check it out.

Are Dynamic Languages More Powerful? I don’t think so

March 2, 2008

Let’s say that power means “the amount of work done per unit of time.”

It could be said that development is made up of these types of work (and much more):

  • Design
  • Prototyping
  • Learning the Language
  • Writing New Code
  • Understanding Old Code
  • Refactoring
  • Debugging New Code
  • Debugging Old Code
  • Reading Other People’s Code
  • Debugging Other People’s Code
  • Making Use of Libraries
  • Making Libraries
  • Refactoring Libraries
  • Updating to Refactored Libraries

JavaScript, Python, and dynamic languages in general do well in some of these areas but not others

For example, “Writing New Code” seems to be the area of focus for advocates of dynamic languages, who see a big power gain there, and possibly in “Learning the Language”.

It seems to me, however, that Java is just as powerful as dynamic languages in the other categories, and much more powerful if you use an IDE with support for completion and refactoring.

That is to say, I can get a hell of a lot more refactoring done per unit of time in Java using Eclipse than I’ve seen in any other language.

This post was inspired this other blog post that compares using GWT to Javascript: http://blogs.pathf.com/agileajax/2007/05/angry_at_gwt.html

Fix Toplink Essentials and OpenJPA by switching to Hibernate?

November 30, 2007

My journey through the land of Java Persistence API implementations continues. Originally, I used TopLink, because that’s what came with Glassfish, and someone told me I should use Glassfish and I believed them.

However, TopLink’s error messages run the full gamut from useless to confusing to misleading. For example, if an Entity class is a subclass of a class defined in a jar that’s not in the same war, you get a ClassNotFoundException that doesn’t tell you what class it was looking for, what class it was trying to load, or anything else of use, really. This is only one example, debugging toplink errors is all about screwing around until it starts working again.

Then I tried OpenJPA, as mentioned in my previous post. Unfortunately, OpenJPA doesn’t support all the features I’m using, like a collection that’s a Map where the key is an Entity class and a field in the target object. Or something – I didn’t delve far enough into this to figure it out, but changing that to a list and doing my own linear search seemed to fix THAT issue, but it was only the first thing that OpenJPA choked on. OpenJPA’s error messages were much better than TopLink’s, but it was lacking in features.

Now I’m trying Hibernate. However, hibernate wouldn’t let me put FetchType.EAGER onto collections inside my entities. Apparently for the Hibernate folks, FetchType.EAGER means it must be done in the same SELECT query, so fetching multiple collections returns a number of rows equaling the product of the number of rows in all those collections. I guess they forgot that you can actually do multiple queries in rapid succession and then pick up the results seperately. That would be too user-friendly for a JPA implementation, and violate the secret code of JPA implementors (that secret code being: if you haven’t worked on the source code for our implementation for at least a month, screw you!). Hibernate certainly doesn’t earn a gold star in error reporting – for the getters lacking annotations it just gave me a column name (no class name) so I had to go searching around since many of my classes have same-named columns. For the FetchType.EAGER problem, it didn’t give me a class name, column name, or even a suggested solution! Luckily google indexes their forums and I did manage to sort these issues out with a bunch of searching online and in the source code.

So …. the question mark remains on the end of the subject because I can’t really say whether Hibernate is going to be an improvement over TopLink Essentials and OpenJPA or not. Maybe after this I’ll be qualified to launch some kind of “Best of the worst: a JPA implementation comparison” website where I can compare JPA implementations for people’s benefit. Or maybe I have better things to do …

CSS DIV sizes and floats

November 18, 2007

Just some things I found out recently about CSS and DIV box sized that really confused the hell out of me until I did:
1. DIV floats always shrink to the size of their contents (like tables do)

2. Float DIVs have a size of zero as far as a non-float DIV is concerned; however, a floating DIV does include both floating and non-floating inner DIVs in its size calculations.

3. If your DIVs are being treated as zero-size, or just zero-height, then keep a sharp eye out for floats! Alternatively, if your floating DIV is enlarging a parent box that you didn’t expect it to, maybe that box is floating.

Here’s a red DIV with a 2px red border that has a floating DIV inside it with a blue border; notice how the red border doesn’t expand to include the inner div:


Here’s a red DIV with a 2px red border that has a floating DIV inside it with a blue border, which has a floating div inside it with a purple border. Notice how the blue border expands to wrap the purple border:

Float in a Float