Sunday, July 11, 2010

A Unix joke

Unix (well, Linux) is great. If it isn't obscure or obfuscated, it's just plain tricky.

I was just making a new user (for a system process) and I wanted to set some environment variables, so I did:

cp -a /etc/skel/.* .

...and I ended up with a copy of /etc! I was confounded, until a very observant colleague pointed out that ".*" will also match ".."!

From now on, I'm going to be doing a "ls -l" with my path names before I do a "rm -rf"!! Also, never do "rm -rf .*" to remove all hidden files.

Sunday, May 9, 2010

Java and Object.

When is an object not an object?

When it's a Java primitive data type.

One of the nice things about Smalltalk is that everything is an Object. Every object in a Smalltalk system understands "printString" or "copy". But in Java, integers and booleans, two of the most commonly used objects (which they aren't...) have to be handled completely differently.

Neither integers nor booleans have any methods whatsoever. You can't do "1.toString()". You can't do "1.compareTo(2)". I find this annoying.

Java tries to remedy this by making Object wrappers for Integer, String, Boolean and so forth. Then they hacked the language to automatically convert between the primitive and the wrapper. The wrappers, however, aren't transparent and are a leaky abstraction.

Take, for example, SQL ResultSets. I find myself doing:

q.setString(1, "hello");
q.setFloat(2, 1.25);
and then:
q.setInteger(3, 45);

But there is no "setInteger" method on a PreparedStatement. It is "setInt", probably because it is passed an "int" rather than an "Integer" as a parameter.

Tuesday, May 4, 2010

HTML Checkboxes.

From the HTML 4.01 specification:
checkboxes
Checkboxes (and radio buttons) are on/off switches that may be toggled by the user. A switch is "on" when the control element's checked attribute is set. When a form is submitted, only "on" checkbox controls can become successful.
I kid you not. If you "uncheck" a checkbox, it will not be submitted to your web application. Your application would need to know what checkboxes were are on the page. If your application generated those checkboxes from a source that it can't reproduce (or doesn't want to, considering how much effort that is), your application can't determine which checkboxes had their values changed from checked to unchecked.

There are two alternatives I know of: use drop-down lists, or make your own checkboxes with JavaScript and images.

Monday, May 3, 2010

Installing Eclipse

Eclipse: oh yes, the great productivity tool of Java programmers world-wide. It's big, it's slow, and if you install the wrong plug-in, it'll become unstable and you have to reinstall it.

A couple of weeks ago, I was fed up with my installation of Eclipse. It wasn't working; every few minutes, it would pop up an error. If I dismissed that error (which was some internal error in Eclipse), it would pop up again a few minutes later. That, and since I upgraded to Ubuntu 9.04, the GTK widgets all broke.

So I reinstalled. Sure, reinstalling works fine after you've downloaded 224 friggen' megabytes. Eclipse is just a glorified text editor; how the heck does it get that big?

After the download, it didn't have the two main features I needed: Subversion connectivity, and a JSP editor. But that's okay. Eclipse has a fantastic feature: you can go to "Help" and then "Install New Software". If you enjoy spraying acid on your raw wounds, you'll enjoy trying to use this, the world's most retarded installation tool.

So you open up this dialog. It says "There is no site selected". Okay - I can handle this. I pull down the lists of sites and... I... er... what the heck are all these URLs? I want a JSP page editor. So I Google. I take an educated guess... I think I want the Web Tools Platform, but I have no idea which component provides the JSP page editor. Furthermore, when I do try to install something, it gives a meaningless error about a missing dependency:


Cannot complete the install because one or more required items could not be found.
Software being installed: Eclipse Web Developer Tools 3.1.1.v200908120400-7R77FStEVw2z07WtDz-OZrhL5C-3 (org.eclipse.wst.web_ui.feature.feature.group 3.1.1.v200908120400-7R77FStEVw2z07WtDz-OZrhL5C-3)
Missing requirement: org.eclipse.wst.server.discovery 1.0.1.v20100210 requires 'bundle org.eclipse.equinox.p2.engine [1.0.100,2.0.0)' but it could not be found
Cannot satisfy dependency:
From: WST Server UI 3.1.1.v20090727b-7B3DPAtJZRZxULQRALIM4256 (org.eclipse.wst.server_ui.feature.feature.group 3.1.1.v20090727b-7B3DPAtJZRZxULQRALIM4256)
To: org.eclipse.wst.server.discovery [1.0.1.v20100210]
Cannot satisfy dependency:
From: Eclipse Web Developer Tools 3.1.1.v200908120400-7R77FStEVw2z07WtDz-OZrhL5C-3 (org.eclipse.wst.web_ui.feature.feature.group 3.1.1.v200908120400-7R77FStEVw2z07WtDz-OZrhL5C-3)
To: org.eclipse.wst.server_ui.feature.feature.group [3.1.1.v20090727b-7B3DPAtJZRZxULQRALIM4256]


So what the heck am I meant to install to make this POS install? What's more, I don't even know which version of Eclipse I'm using (Ganymede? Equinox?) because there isn't anywhere in Eclipse that I can find this information.

Eclipse is the crappiest POS I've ever had the discomfort of using. It is a bloated 224MB pig that doesn't even have a basic JSP page editor or Subversion connector out of the box. Surely these are two very commonly used components?