Wednesday, August 1, 2007

Hello World: A New Requirement

I am proud to say that this blog gets hits from all over the world. (Hello Finland, France, Brazil!)

These hits help me with the Big Picture, as does the calendar of Paris on my desk: it is a big world out there. Many people, many cultures, many languages.

Which led me to this thought: it bothers me that "Hello World" is always in English.

I think the venerable first program should always be internationalized, because:

  • It helps keep the Big Picture in mind. I18n is one of the universal issues of computing
  • In addition to showing language syntax, it shows the i18n features. "What do you mean the language doesn't have Unicode support?"
  • In an education environment, it teaches i18n to children from the start while reminding them that there's more than English. It also teaches issues of font, Unicode, etc.
Admittedly, the New Hello World is not minimalist any more and not necessarily pretty. But it would truly be able to say "hello!" to the world.

Here's a version in Groovy. It presumes that there is an i18nized labels.properties file in the current directory.

For example: labels_fr_ca.properties would contain

msg=Salut Monde!

Idea: why not leave "Hello World", in a different language, as a comment? Be sure to specify language, country, and variant codes as appropriate. (This is Java-centric: see here for details)

If you leave a comment, and email me at codetojoy through gmail, I'll send you a sticker!

The Groovy version:
// Requires labels_[Locale].properties
// with definition of key called 'msg'
//
// Locale = the various ways of specifying locale in Java
Locale locale

boolean hasLanguage = ( args.length >= 1 && args[0].length() > 0 )
boolean hasCountry = ( args.length >= 2 && args[1].length() > 0 )
boolean hasVariant = ( args.length >= 3 && args[2].length() > 0 )

if( hasLanguage && hasCountry && hasVariant ) {
locale = new Locale(args[0], args[1], args[2])
} else if ( hasLanguage && hasCountry ) {
locale = new Locale(args[0], args[1])
} else if ( hasLanguage ) {
locale = new Locale(args[0])
} else {
locale = Locale.getDefault()
}

ResourceBundle labels = ResourceBundle.getBundle("labels", locale)

println labels.getString("msg")

Sunday, July 29, 2007

5 Lessons From Triathlon

I'm in my 3rd year as an intermediate level triathlete, and have noticed that there are some parallels to software development. Some of these aren't new but I find the similarities to be interesting. (Many of these are true for all kinds of hobbies.)

Machines are brutally honest

Whether its developing code, or running a 10K, the stopwatch and unit tests show no mercy. Emotion and passion have their place, but the cold hard facts are, well, cold and hard.

Give the problem to your subconscious solver

I am constantly amazed at the power of taking a break or coming back to a problem after a night's rest. The subconscious mind is a powerful thing. This is true for many hobbies (anything that distracts us), but I think especially for endurance sports. It is easy to let go of a problem if you are going 18 mph (29 kph) on a bicycle.

Interestingly, of the 3 sports, the swim is often the most pensive for me. After 45 minutes in the pool, all of the world's problems seem solved. Many of these blog posts originated in the pool.

Learn tricks from the community

I have a blog post on the importance of talking to fellow IDE users about the tool: you can learn a ton of new things.

Similarly, in triathlon, there are a zillions tricks that people use to reduce time, especially in transition. One example: some hardcore types will clip their bike shoes into the bike prior to the race. After the run segment, they ditch their running shoes and hop onto the bike at a run (barefoot), and wiggle their feet into the bike shoes at 8+ mph. This is entirely analogous all of those wonderful keyboard shortcuts in Idea, Eclipse, etc.

Variety is fun

If I don't want to swim, I can bike. If it's raining, I'll run on the treadmill. Options! And yet I am still doing something. That's cool.

The point here is so obvious that I can't bring myself to write it. How about: Swim, Bike, Run sure seems isomorphic to Scala, Beanshell, Ruby *wink*. (Though I recommend Groovy over Beanshell).

Challenge is growth

Not all triathlons are the famed, insane "Ironman": the distances vary all over the map. I signed up for a triathlon in September: it is a distance that I honestly don't know if I can do. We'll see, but it has certainly given me motivation to train more.

A colleague recently pointed out a similar phenomenon for learning comp sci: volunteer to write an article, teach a class, or give a JUG presentation. If you don't know the subject well enough, then all the better: because you're gonna have to. It's a frightening X weeks of preparation but exhilarating.

And it's a great feeling to hear the applause at the finish line.

Friday, July 27, 2007

Stuff That Happened: Blog Bankruptcy




CtJ Editorial
Artistic License, MO
July 2007


Eric Burke is alive and well. Sources tell the CtJ newsdesk that he is tanned and well-rested.

However, his blog Stuff That Happens has a recent post that the site will be no more. Call it Blog Bankruptcy.

The move has raised eyebrows throughout the tech blog community. The site was a successful, interesting mix of strong technical insight, moderately humorous asides, and the occasional pointed rant. With its medley of content, the blog was an archetype for a new generation of "post-modern" tech blogs, as exemplified by Code to Joy.

For many, though, the announcement is the final denouement of a steady slide of the blog persona. After years of success, and a remarkable peak of innovation with the now-famous "I *heart* POJOs" post, the blog began to descend into the abyss. Consider the final weeks:

  • A contest inviting people to send stuff to his open-sourced snail mail address
  • A contest inviting guest writers to debate a topic -- any topic
  • Ambiguous use of the term craptastic
  • A mini-series on screencasting, with a conclusion that involves an unusual penchant for working with bamboo floors and the quote "I'm quitting computers"
Sad, but true. A seemingly desperate blogger who, like a slumping baseball player, swings for the fences on the first pitch. The persona evolved into a theme of a maniacal despot of a tiny island nation, giving deranged orders to puzzled generals and lieutenants.

A Ruse?

Is it a ploy? Some kind of grand scheme in the vein of American comedian/performance artist Andy Kaufman ?

Will "Stuff" return -- perhaps as a new blog? Can someone who writes such passionate rants actually walk away from the pulpit? The author is strong in Swing, concurrency, and other aspects of Java -- can he suffer the slings and bugs of outrageous JDK libraries and not tell the world?

Who knows.... But a tip of the hat to venerable Stuff That Happens, and an invitation for its readers to join the orchestra at Code to Joy. Come along, it'll be joyous!

Monday, July 23, 2007

Tuesday, July 17, 2007

isPrime in One Line of Groovy

This line of code is inspired by this post on primality in Perl.

$ groovy -e "println new BigInteger(args[0]).isProbablePrime(99)" 19
$ true <--- i.e. 19 is prime

I suspect that this will be considered cheating: (a) it evaluates "probable" primes and (b) it isn't in the spirit of the game. But still neat, n'est-ce-pas?

Final Score

JVM Tunnelers 1 Cryptic Scripts 0

Monday, July 16, 2007

My Next Book Purchase



I'm excited about this new book from O'Reilly.

I generally enjoy books on "philosophy of computing" but check out the authors in this one: Brian Kernighan, Jon Bentley, Tim Bray, Elliotte Rusty Harold, and so on.

Wow. And the kicker: author royalties go to Amnesty International.

Sign me up.

My only wish is that O'Reilly and Amazon, instead of offering "get a 2nd book for 30% off", would offer "buy 5 hours per week to read your new purchase!"

I'm telling you: the bookseller that first sells time will make millions.

Thursday, July 12, 2007

Easter's Corollary to The Miller Principle

First, check out the sublime, brilliantly phrased Miller Principle. I humbly submit the following...

Easter's Corollary: Everyone scans.

Scanning is like Reading Lite: all of the eye movement, without that cognitive aftertaste. With the hectic pace of today's society, and the e-torrents of text, scanning is a great way to almost upload information into our consciousness.

The act of scanning is addictive, as people feel justified in commenting on something they nearly read.

Office synonyms for "scan" include "peruse", "check out", and "take a peek".

Example usage: "I wanted to choose a web framework for the new portal project for Finance, so I scanned the Readme file of Acme WebSoft. Looks pretty solid to me."