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.io.File;
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);
jarFile.entries().each(myEntryChecker);
}
}
}

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