Notes to self

Not gold alone brought us hither

Aug 5, 2011

Programmer’s work computer

Whatever you do for a living, you are skilled at using a toolset in order to get your job done. A surgeon uses surgical tools to perform surgery and these tools are provided by her employer. Think of any profession or job, the norm is: you bring your skills to work, but the tools to get the work done are provided by your employer.

This is also true for software development industry. If you are a programmer, your computer is chosen, procured and given to you by your employer. You probably have some choice in that you get to pick between a desktop computer or a laptop, but not much beyond that. Corporations make this choice for you purely based on cost. Whatever costs least in the medium to long run wins. Some factors are ignored in this cost analysis because they are hard to quantify: lost productivity due to sloppy performance of computer, lower employee morale due to frustrations arising from unreliability of their computer, etc.

Why not let the programmer buy a computer for himself? Give him an annual budget and ask him to stay within that budget. If he wants to buy an average desktop and a laptop, its his choice. If he wants to buy a desktop with two LCDs, again his choice. Whatever he wants to buy within that budget, its up to him. Computers are not expensive enough for employers to bother about any more. Free that aspect of the programmer’s experience at work, and he will thank for you for doing that.

Imposing tools on employees may make sense in industries where the toolsets are standardized to the extent that there is hardly any room for individuality and personal preference. This is certainly not the case in programming / software development industry and hence it does not make any sense to buy computers in bulk and shove one down the throat of every programmer in your organization.

Jul 30, 2011

Dashboard in OS X

Before OS X Lion, Dashboard was a nice thing to have. Just hit the shortcut key (usually F4) to bring up Dashboard to quickly take a peek at one or many widgets running there, and hit the key again to hide it. You are back to whatever you were doing before — does not matter which of the many desktops you were on.

Come Lion, creating a new desktop for a full screen application is as easy as hitting the full screen button (on top right corner of any window). And, side sweep gesture with three or four fingers on the trackpad moves you between multiple desktops. The only drawback with this new ease of navigation is… when I want to go back to the first desktop (to launch a new program or to use any of the open apps on that desktop), I invariably sweep past the first desktop, landing on Dashboard. This is annoying because I expect scrolling to stop once I reach the first desktop because thats my “home desktop” for all practical purposes.

There’s a way out since I can live without Dashboard. Ran these two commands on terminal to disable it:

defaults write mcx-disabled -boolean YES
killall Dock

Jumping between desktops is now fun again.

Jul 28, 2011

Uncommon switch-case construct causes java 7 compiler to crash

Java language specification 3.0 defines a switch block as:

The body of a switch statement is known as a switch block. Any statement immediately contained by the switch block may be labeled with one or more case or default labels. These labels are said to be associated with the switch statement, as are the values of the constant expressions in the case labels.

One of the valid forms of constant expression is: Parenthesized expressions whose contained expression is a constant expression, and examples are:

case (3):


case (1 + 2):

Java 7 introduces support for strings in switch (part of project coin). Using the form of constant expression listed above, with strings in switch, causes javac to crash with a NullPointerException. This is a bug in java 7 compiler and I have reported this in Java bug database.

Here’s a test program to reproduce the issue:

public class Test {
    public static void main(String args[]) {
        switch(args[0]) {
            case("hello"): // causes javac to crash

Running javac results in:

An exception has occurred in the compiler (1.7.0).
Please file a bug at the Java Developer Connection
(  after checking
the Bug Parade for duplicates. Include your program
and the following diagnostic in your report.  Thank you.

Leaving out the opening or closing parenthesis does give a valid compilation error, indicating that parenthesis is valid with string literals in a constant expression.

The build I am using is release candidate and will most likely ship with this bug:

C:\>java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)

I have not tried this on a system other than my Windows 7 laptop, but this bug does not seem to be platform specific. In any case, here is some detail about my system:

PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 23 Stepping 6, GenuineIntel
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files

The bug id is 7071246, but is not visible to the public yet. In an email, Oracle says this will be visible only after it is reviewed and does not pose a security concern.

Though using parenthesis in case labels is very uncommon, if one does use it in the form explained above, it is impossible to tell from the error message what or where the issue is. An issue if you are compiling a code base with hundreds or thousands of java classes.

[Update = “the bug is now posted on the java bug database in the public domain]”

Jul 17, 2011

Tricks for engineering your own happiness

Scott Adams’ tricks for engineering your own happiness. Condensed from a blog post.

Food - When you feel agitated, try eating some carbs.

Exercise - Think of exercise as the difference between a good day and a bad day. That is reason enough to exercise.

Goals - Have at least one project brewing at all times that has a non-zero chance of changing the planet, or making a billion dollars, or both. That is a good feeling to wake up to.

Meaning - First, achieve personal success. Once you reach a more comfortable level, be useful to others in order to find meaning and feel right in your own skin.

Positivity - Have an ongoing positive dialog with yourself. Do not incorporate negativity even in your humor. Saying positive things puts your mind into a positive state and attracts positive relationships and positive outcomes.

A Little Bit of Danger - Make it a habit to try new things, even if those things scare you a bit.

Learn - Feed your brain. The more active your brain is, the more alive you will feel.

Feel Success - Make it a habit to often do things you do well. It doesn’t matter what that is but doing one thing well gives your ego armor to handle the little things that don’t go quite so well.

Relationships - Follow the other tips for happiness to attract the sort of relationships you want.

Happiness can be engineered, and luck is a product of good design.

Read the original blog post