Case insensitivity on HFS+

As most of you (I have limited readership on my blog and I'm pretty sure I know all of you) know, I've moved away from Linux to the Mac world a couple of months ago. I have an ancient PowerMac G4 for my home desktop and I use a MacBook Pro at work. Of course, I still use Linux for most development; Linux laptop at home and a server at work, so I haven't found the need to do any hardcore dev work on OS X till date.

This weekend, I decided to try my hand at porting Java-GNOME 4.x to OS X. I'm blogging that effort in a different post, but to cut to the chase, I was burned by case insensitivity on HFS+ for the most part of the weekend. It turns out, that despite being a UNIX, by default, OS X chooses a case-preserving but case-insensitive configuration for its filesystem. While you can choose a case-sensitive configuration (You'll have to select at format time!), you're likely to break third party non-Apple apps such as Adobe Photoshop.

Consider the following piece of code:





public class Test {
public interface CLICKED {
public void perform();
}

public interface Clicked {
public void perform();
}

public static void main(String[] args) {

Clicked myClicked = new Clicked() {
public void perform() {
System.out.println("Inside interface Clicked");
}
};

CLICKED myCLICKED = new CLICKED() {
public void perform() {
System.out.println("Inside interface CLICKED");
}
};

myClicked.perform();
myCLICKED.perform()
}
}





I'm sure you'll agree that this is a reasonable piece of Java, by most standards. We create two Interfaces and define two objects by implementing their methods. Now, we invoke "javac" and get this piece to compile. We typically expect a class file for each Outer class and a qualified class file for each Inner interface/class as Outer$Inner.class and so forth No sweat:

[pendyals@fermi:~/test/Test] $ javac Test.java
[pendyals@fermi:~/test/Test] $ ls
Test$1.class Test$CLICKED.class Test.class Test.java
[pendyals@fermi:~/test/Test] $

But what's this! We only have Test$CLICKED.class! Evidently we're missing a Test$Clicked.class! Where could it be? How about we look in the Test$CLICKED.class?


[pendyals@fermi:~/test/Test] $ javap -c Test\$CLICKED
Compiled from "Test.java"
public interface Test$Clicked{
public abstract void perform();
}


Evidently, the only interface compiled in, is called Clicked and not CLICKED. As you'd have guessed by now, attempting to run this class will result in a Exception:



[pendyals@fermi:~/test/Test] $ java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test$CLICKED (wrong name: Test$Clicked)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)

...


If you haven't guessed what happened: Javac created a Test$CLICKED.class file and put in the byte code for the CLICKED interface. Then, after compiling the byte code for the Clicked interface, it wanted to write into its corresponding file. Before writing, it checks to see if the file exists and if it does, just overwrites the file. HFS+ of course, dutifully returned a handle to "Test$CLICKED.class" when asked for "Test$Clicked.class" and this caused javac to silently overwrite it.

As is painfully evident, the case-insensitive nature of HFS+ has repercussions far beyond naming files correctly. Since languages like Java require you to name files with class names, an incorrectly designed application could fail silently and not alert you of the fact that a class file has been rewritten.

While the "typical" UNIX response would be to dismiss OS X and HFS+'s behavior as absurd or "immature" (yes I've heard that one), it would seem to me that a prudent design shouldn't require case-sensitivity in any form. I use the word "prudent" in a tongue-in-cheek sort of way, because there's no requirement for Java apps to run on OS X or Windows if the app designer didn't want it to.

Fingers burnt. Lesson learnt.

Bird brained



On my way to the Twin lakes Java (an amazing Coffee shop at Twin Lakes, MI), I was overflown by a rather satisfied looking Bald Eagle. Satisfied, since he'd just finished off what looked like a rather large carcass of a rather unlucky hare. I screeched the car to a halt, jumped out and took a few pictures of him as he circled (!?) and flew past. Mighty pleased with myself for having bagged a good picture of a Bald Eagle, I looked through the pictures to realize to my horror, that I'd been shooting with the ISO set to "HI1". In Nikon's terminology, for the D60, "HI1" == 3200 and also "Avoid using". So there _was_ a reason I had to shoot at 1/4000 and F11 to get the correct exposure.

Feeling pretty silly, I returned and plonked down on the couch with the Rubik's cube in hand. Deciding that I had to get through the silly cube in better than my usual 1:20-1:40 minutes, I started trying to learn all 41 algorithms of the Fridrich method. Then, I came across one of the most useful webpages I've seen in recent times: http://www.freewebs.com/sirshazaam/f2l.htm
The guy has most painstakingly listed out every one of the algorithms for the F2L and has pictures of the cube, for each of them as well. Brilliant.

Having had enough, I attempted hitting the sack at about 6:45 AM, when I heard what sounded like a Warbler. Deciding that I couldn't sleep any more, I picked up the device of photographic expression and walked out. After stalking the fella for more than 20 minutes, I finally caught sight of this brown feathered chappy, chirping away in a brown tree. Perfect. Getting a clear line of sight of the guy was a tough job.






Having shot what I thought was an okay-ish picture and double-checking to make sure the ISO was not an obscene value, I walked around for a little bit, coming across another magnificent sight. Somehow, just somehow, I get the feeling that today's going pretty well for a start.

The gear




Pictured, is my new D60 along with a bargain Soligor 90-230mm F4.5 manual, I got off eBay, for $20.
The other glass (not in the picture), is a humble Nikkor AF-S 18-55 DX VR.

The Soligor has been my lens of choice, ever since I began understanding the concept of exposure better. Shooting without any metering whatsoever and with a manual focus is a little daunting at first (especially so, for someone new to D-SLRs), but certainly not a major hurdle.

The remote control on the right, is a Phillips universal remote, that I've programmed to use as a remote trigger for the D60.

Web widgets

So, the intarwebs is filled with these "Take the pink ponies quiz and see your score now!!!" tests. I normally avoid these abominations. The Political Compass however, is one of my favorites. The Political Compass's theory is, that the traditional Left-Right line, in itself is insufficient. Political orientation, really is a two dimensional plot, with the other axis being the Authoritarian-Libertarian line. Intrigued? Try them out at politicalcompass.org.

Also, I score as

Economic Left/Right: -1.50
Social Libertarian/Authoritarian: -5.79 . To see it on a graph, click here

Also, in order to ascertain bragging rights (Slackbot, this is for you):

80 words

Typingtest

Deer chase!


Deer chase!
Originally uploaded by Srichand Pendyala
I was driving up to Copper Harbor on a bright beautiful Saturday, when this Whitetailed deer running alongside the road, passed me from the left, crossed over onto the right lane and then sprinted along the road for a good half a minute.

Not wanting to confuse the Deer any further, I kept a good distance away from it, but stayed right behind it, while a friend dug my camera out of the bag. During those few seconds, my speedometer read approx 35 miles an hour and the Deer was almost always a constant distance from me.

Finally when I got my camera, I flipped the wheel to "P" mode, let the camera choose everything, zoomed to 55mm and fired off a burst of shots, trying to capture the chappy, while the sunlight was still on him.

Having had enough excitement and thrill for the day (its white tail up, indicating fear and alarm), the Deer decided that discretion was the better part of valor and vanished into the woods in a blitz.

Removing quizzes from your Facebook feed

Here's how you remove annoying Quiz updates from your Facebook feed:

If you haven't already, install the Greasemonkey add on for Firefox (https://addons.mozilla.org/en-US/firefox/addon/748), then install the Greasemonkey script to remove the Quiz updates

You can find the Greasemonkey script at http://userscripts.org/scripts/source/44459.user.js

Louise Attaque


I recently re-discovered Louise Attaque, a French Folk rock band. I first heard them live at the Alliance Française de Bangalore sometime in 2005.

Not surprisingly, that was also the first time I'd heard rock in a different European language (I'm fairly accustomed to English!). Although I barely understood a word, I didn't feel lost or out of place. They say music doesn't have a language; perhaps they're right.

Regardless of the genre you listen to, I highly recommend giving Louise Attaque a listen. They've got catchy tunes, with interesting guitar, harmonica, violin and accordion pieces. I don't understand French, but I've been told that their lyrics are pretty interesting too.

The French are a friendly people (see note [1] below for an exception), particularly so at the Alliance Française of Bangalore. If you're in the area and you feel the parisian touch, you might want to stop by.

[1] Overheard at the Aéroport Paris-Charles de Gaulle : "Why do you presume I speak English?"