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."

Sunday, July 8, 2007

Seven Wonders of Programming Languages

As is widely known, there has been a massive effort to vote for the New Seven Wonders of the World, an update to the classic list of antiquity.

A fun thought experiment is to list the 7 Wonders of Programming Languages.

Imagine someone is new to our planet, civilization, or computer science. You want to show them the definitive list of programming languages: 7 wonders. What do you pick?

Making a list is easy. Trimming a list is difficult, and that's the problem with Seven Wonders.

Especially when you consider all of the available languages. For a wonderful evolutionary map, see this photo from Wired.

My list is below. Roughly speaking, my criteria are:

  • Proven track record and legacy. Sorry, Groovy, much too soon.
  • Success either in terms of influence or outright usage. However, sheer popularity is not enough.
  • Consideration for brilliance and innovation.
  • Admittedly, there is some blurring of the line between pure syntax and the platform/libraries.
Here is my (biased) list, in approximate chronological order.

1. Fortran

Assembly is older, the Turing machine is much older, but Fortran takes the prize as the grand-daddy of computing. It is arguably the "Proto-Indo-European" of procedural languages. Indeed, it was ugly, was not as influential as, say Algol, and had major problems, but it has a strong argument for being "first".

2. Lisp

For decades, university profs have whipped out this functional language when they want to mess up students. After an initiation to the Algol-based languages, there is no preparation for a mind-trip without for loops or if statements. Massively influential in its space (i.e. non-procedural computing).

3. Smalltalk

Though Smalltalk never seemed to break out of its cult-following, it pretty much nailed OOP right on the head in terms of execution. Smalltalkers are rabid fans and the general community spawned a stunning array of ideas, from OO concepts to library design and development methodologies.

4. C

Does this language need an explanation? Though the syntax is still a bit smelly, even after all these years, this is the definitive iron workhorse, the Lou Gehrig of languages.

5. Python

Python is on the list for 3 reasons. One, it is an educator's dream. It is easy to learn and so friendly that the interactive window harkens back to a simpler time of computing. Second, it is extremely effective for handling the "currency of computing" -- strings. Finally, it is an excellent example of a language that "stays out of the way" even when projects scale in size (i.e. it can be used for newbie programming or high-end applications).

6. Java

Some may sniff that Java has been a hype machine for 10 years. Wrong. The hype has been huge at times, but I think Java is actually under-rated. With a strong lineage to C++ and Smalltalk, Java got a lot of things right. Reflect on the JVM, packages, naming of classes/files, Unicode support, reflection... the list goes on. One day, historians will say that the pervasiveness of Cobol "was like Java, only smaller in scale".

7. JavaScript

A tough call for the last spot. One can try to defend the theoretical side of JavaScript -- I once heard in a conference that the author was influenced heavily by Lisp. One can try to point out elegant examples of its use. But the truth is that it is inseparable from its platform and rides that tidal wave into this spot. Just as C gave us definitive access to the filesystem and sockets, JavaScript gives us the DOM, and Ajax. When you have connections like Google Maps, well, you get red-carpet treatement.

There's the list.... let the flames begin!

What's your list?

ps. Honourable mentions to C++, Visual Basic, Cobol, Perl, and APL.

Closures in Action: searching jars

A recent blog post talks about the problem of searching jars for class names. I have done something similar in Java, and ported the solution to Groovy.

The code is listed below. Some tidbits:

  • My uncommented Java program was 87 lines. The commented Groovy program is under 50.
  • The program is not fast but is straight-forward. It recursively searches a directory for jars, and searches each jar for a given string (e.g. "org/apache/log4j/Logger").
  • It uses 2 closures. This is a modest example of the power of generic algorithms (e.g. eachFile()) and closures.
  • If you aren't familiar with closures, Groovy is a fantastic way to "test drive" them before deciding on your stance about including them in Java.
// Usage:
// groovy Which [searchDir] [target]
// e.g. groovy Which c:\tomcat org/apache/log4j/Logger

import java.util.jar.JarFile;

// Closure: if jarEntry's name matches target, print fileName
// NOTE: fileName value comes from enclosing scope
myEntryChecker = {
jarEntry ->
int index = jarEntry.getName().indexOf(target);

if( index != -1 ) {
println "found match in " + fileName;

// Closure: if file is a jar, apply myEntryChecker
myFileChecker = {
file ->
if( file.isFile() && file.canRead() ) {
fileName = file.getName();

if( fileName.indexOf(".jar") != -1 ) {
JarFile jarFile = new JarFile(file);

// static void main(String args[])
// todo: sanity check arguments
def fileName
searchDir = args[0]
target = args[1]
println "\nsearching: " + searchDir
println "target: " + target + "\n"

new File(searchDir).eachFileRecurse(myFileChecker)

println "\ndone. "

Friday, July 6, 2007

Titles on Rails: 5 Reasons Why We Click

We are swamped in messages that lure us into certain behaviour. From advertising to the layout of grocery stores (ever notice that the two staples -- milk and bread -- are at separate ends of the store?), there are a variety of techniques and tricks that play on our psychology.

These aren't immoral, necessarily, but it is interesting to be aware of them.

Here are some things I've noticed about the title of posts on tech blogs: "the tricks for clicks", as it were.

1. Itemize

People are naturally drawn to lists, and geeks in particular. Tech bloggers owe a debt to Scott Myers, whose book, Effective C++, made lists very cool and, well, effective. Just a collection of info-morsels, each hand-tailored for today's collective attention span.

2. We Love Numbers

This just in: geeks love math and numbers! Plus, when we see "10 things about x", we subconsciously try and generate things in our head, and then compare the list to the post. Plus, some numbers have a certain charm: 7 and 10 are big winners.

3. Buzzwords

If there is a buzzword in the post, then all the better. Like bears to honey. We should all rename our companies' current projects to use 'Rails' even if they aren't a web technology. e.g. "Trilogy Internal Payroll System (TIPS)" becomes "TIPS on Rails".

4. Brevity Rocks

5. Passion is attractive

This isn't just the scourge of trolling. A good title will imply strong affinity or distaste for a concept: there's no middle ground. The truth is, passion by itself is often attractive enough for us to click, even if we disagree with the sentiment. We are drawn to confidence.

Those are some reasons I've noticed for my clicks...

and you?

Raising the Blog Bar

With the wildly successful 'Win a Sticker' contest, CodeToJoy has been enjoying its place at the fore of tech blog innovation. A mix of tech insight and entertainment has pleased readers from all over the world.

However, there's no rest for the witty. In the last week, we've seen these events:

  • Weiqi Gao, with his Friday quiz, introduced an entry from a correspondent. Zounds! Team work, no less. Weiqi is leveraging his readership by out-sourcing ideas to his esteemed readers.
  • Eric Burke has pushed the boundaries of the tech vernacular by introducing us to obscure terms like "Yak Shaving" and (wait for it) "Craptastic". Like a jazz improv singer riffing on the English language: a scatological scat.
  • DES introduces a wee lil' pebble, the wiiStone, before the partnership was official!
And now this:
  • Eric Burke has open-sourced his address. Although it may be a scam to procure more USB microphones, it seems like a genuine attempt to raise the bar of blogs with a new contest.
It won't be easy to stay ahead of all of these developments, but CodeToJoy is committed to excellence. You are on notice, gentlemen!

Wednesday, July 4, 2007

Sticker Winners!

Here are the winning entries for the first 'Win A Sticker' contest.

Mike V in St Louis, USA wrote a jaiku (a "Java haiku", a term for which he claims ownership):

Simple in nature, No API required, Gets simple jobs done.

Matthew T in St Louis, USA provided a mini-simulator for a "POJO stick".

Kishore R in Hyderabad, India offered, "POJOs are freedom! A POX on your house, XML!"

Torbjorn E in Oslo, Norway wrote in: "Anything but POJOs on my MOBO? Are you loco?"

Neal Gafter, author of Java Puzzlers and ambassador in the Java community, sent in (*):

POJOs have some mojo, but I *heart* closures.

Congratulations to the winners!

(*) Did not actually send in such entries -- but if they contact me at codetojoy @t gmail, I'll send them a sticker anyway.

ps. Several people have asked: yes, indeed, Eric received a sticker for coining the original phrase.

Beyond Multi-Core Processors: the Brain

Here is a must-read Wired article on Luis von Ahn and his computing techniques.

To "captcha" your attention, he coined the term CAPTCHA
for those warped words that are used to authenicate humans on websites.

But as the article points out, he really stands computing on its head with a novel angle, by looking at things in reverse: rather than using computers to help people, he invents ways that humans help computers. Particularly through games. Check out the site Games with a Purpose

Example 1:

Two English-speaking players are shown a sentence in a foreign language that neither of them speak. A list of possible English meanings appears below each word. Players try to agree upon a set of English words that forms the most coherent sentence. Translates foreign text into English without requiring anyone fluent in both languages.

This guy's creativity and talent is simply off the charts. As with any person, my mental CPU is beyond any computer but this guy's CPU is certainly beyond mine. Wow.

ps. If I have not yet convinced you to take the time and read the article, here's a quote that might pique your curiosity:

In December 2005, von Ahn demo'd his game at Google. After the presentation, Sergey Brin and Larry Page approached him. "They stayed for the whole speech, which apparently they never do, and then came up and said, ‘Hey, let's commercialize this,'" von Ahn recalls.
pps. My main takeaway from this is the genius of looking at things in a different way. e.g. Humans didn't learn to fly until we stopped trying to fly like birds. This is Inversion of Cognition of the highest order.

Monday, July 2, 2007

Introducing the iStone ($299)

CtJ Newswire
Parody City, CA
July 3, 2007

Widely known for software posts, CodeToJoy shocked industry insiders today by unveiling a new tech gadget: the iStone.

Made from exquisitely-polished, solid obsidian, the iStone is a viable alternative to other popular mobile units. It weighs in at a mere 4 ounces, and is state-of-the-fashion, at 4 x 2 inches in size. With a retail price of $299, the device enjoys a significant price advantage over its primary competitor.

"Admittedly, both reception and connectivity will be issues for early adopters," said one industry pundit. "However, CodeToJoy does not lock you into a particular carrier. What's more, the activation delay may not be significantly longer than with its main rival."

Throughout North America, and around the world, forums and blogs were abuzz with news. A typical posting described the allure of the latest tech status symbol:

"Dude... hit the bars with the iStone and you are a rock star! :-P And still have money left over to buy drinks! I *heart* iStone."

However, there is also controversy surrounding the announcement. Skeptics in the tech world wonder if it will be an open platform for 3rd party developers. The Java community, in particular, is furious at early reports that the iStone may not run Java applications.

At last report, orders for the device were strong, with lines forming at many retail outlets. Online auction sites quote starting bids as high as $498.