Saturday, April 5, 2008

Code to Joy: a User's Guide

The recent jJava post was written intentionally for April Fools, but wasn't really intended to fool people per se. There are several parodies on here, and jJava may well re-appear.

I've come to realize that first-timers (and possibly loyal readers) may not understand where some posts are coming from. This post is an aside from the usual work, and is a reference: a user's guide, of sorts.

Inspiration

A major influence on this blog is the comic strip Calvin and Hobbes. Though Dilbert is pure genius and The Far Side is wonderful, C&H is the best. The writing is exquisite and the ideas are often profound.

However, what I love most about C&H are the various themes: the snowmen, Spaceman Spiff, and especially the big Sunday, colour editions drawn as a different, adult comic (e.g. where Calvin is a T-Rex).

The point is: if you read a book of C&H, you never really know what might appear on the next page. But when you encounter a familiar theme, the experience is doubly wonderful.

Themes

This blog certainly does not compare to the brilliant C&H. Nor does it even have comics: that's Eric's bag.

The influence of C&H is that I hope repeat readers will have a similar experience: not knowing what will come next (serious vs satire), and recognizing familiar themes. (Weiqi Gao's Friday Quiz is a great example.)

That said, here are some emerging themes (beyond the usual geek stuff):

Newswire

Anything from the CtJ Newswire is going to be a parody: look closely at the city in the header. I'm not trying to fool you. Hopefully, even though the post isn't serious, it will still share some kind of insight.

Stickers

I get bored in bars and I get bored writing standard blog-fare: the sticker posts are pure rebellion -- and fun (especially on vacations). Almost all subjects are strangers.

True, most subjects are female (hey, I'm a single, straight guy in a bar), but I try my best to keep things equal. The intent is solely to combine geek stuff and nightlife. Photoshop is never used.

The CodeToJoy Nation

Any mention of HQ, "our hero", or general ego-centrism is simply to spice up the text.

The CodeToJoy Nation is an ongoing attempt to 'franchaise' readers of the blog and enhance the sense of community.

Outrage

I rarely blog in anger. This is a rant-free zone. I rant enough in real life and there is enough grousing on the Web, n'est-ce-pas?

Any 'outrage' is going to be mock outrage. Usually, it is a theatrical spoof of envy/vanity (a la Daffy Duck) that a friend (usually Eric, Weiqi, or Alex) is getting more hits on a given day.

For example, I'm still trying to figure out how Weiqi gets correspondents. What a scam!

The Upshot

HTH ! Thanks for visiting.

Oh, by the way: rediscover Calvin and Hobbes.

When we are only bounded by our imaginations, it's a Magical World.

Tuesday, April 1, 2008

Open-Source group announces jJava


CodeToJoy Newswire
April 2008
Satire Valley, CA

An open-source project surprised industry insiders today by announcing an implementation of the Java programming language on the JVM.

The language, dubbed jJava, reflects the current trend for using the JVM as a systems platform for various languages.

Wearing t-shirts featuring the jJava logo (a pair of Jacks), team members displayed the obligatory HelloWorld program to a group of interested developers:


Consequently, the team discussed some key advantages of the nascent language:

Flat Learning Curve

The jJava platform is an easy-entry point for busy Java programmers who simply don't have time to learn a new syntax. The team provided a comparative analysis with other languages on the JVM:


Leverage JVM libraries

As with other JVM tunnelers, the developer has access to the venerable Java libraries including IO, Reg Ex, collections, and concurrency.

Static Typing, Compilation

Though dynamic languages and type-inference are gaining mindshare, many developers prefer the tried-and-true comfort of a compiled language with static types. This plays to jJava's strengths.

Modern Features... Closures?

jJava contains annotations, generics, and state-of-the-art concurrency constructs. Closures are not yet supported in the language, but may be arriving soon, depending on the outcome of a spirited debate within the community of the parent, reference language.

Tooling

On this point, the team-spokesperson adopted a hushed tone, in order to underscore the passion and importance of their point: jJava enjoys a tremendous advantage in tooling. Because jJava is Java on the JVM, all modern IDEs, build tools, and code-coverage software will work with jJava.

Performance

When asked about performance, the team exchanged knowing glances and beamed. Insisting that the results were as-yet unofficial, the team crowed that improvements to the JVM in Java 6 may result in jJava being faster than Java.

Said one jJava developer, "We were really surprised by this. It is quite counter-intuitive, but the numbers look terrific."

Release Date

The team conceded that jJava is not yet available for public consumption, but is coming soon.

Off-the-record, a tech lead hinted that the team is hoping to complete a web framework, as a companion download to the language itself.

Monday, March 31, 2008

Opening Day: the original Greenfield App

Opening Day is a minor holiday in many baseball cities, including St Louis.

It is the original Greenfield application: a fresh start, where hope springs eternal. No legacy baggage. No vendor or framework lock-in.

A true story: many years ago, I had taken a vacation day to go to see the Cardinals play their home opener. Due to an IT crisis, I was called in that morning for an emergency meeting for a valued, troubled customer.

After 1.5 hours, we had our plan. Upon leaving, someone pointed out that I was technically on vacation. I told the group that I didn't mind -- if they would do one favour.

I asked them to sing "Take Me Out to The Ball Game".

And in a dark conference room that had rarely, if ever, enjoyed the sound of music, they slowly, grudgingly started to sing. By the end of the first verse, they were into it, and beginning to smile. At the end, they were belting out the tune like school-children.

Here's to a new season....

Friday, March 28, 2008

Lorem Ipsum in Scala (or 'how Weiqi Gao took my Friday night')

"Gah!!!!", our hero grits his teeth and slams a hand on the keyboard, " Darn you, Weiqi Gao....".

It is late on a Friday night. Our hero has decided to give the dreaded Friday Scala Quiz a shot. Even though the challenge was clearly in jest, the temptation is just too great. Why not try? However, there is just one problem: despite attending several presentations on the language, he has only recently downloaded Scala, and tried only a simple HelloWorld program.

"What was that syntactic sugar for a method call?", he muses aloud, pouring another shot of gin into a tumbler filled with Red Bull. Whirling to the desk, he rifles through some notes from one of the presentations -- aha!

" obj.method(param) can be written as obj method param ! ", he cackles gleefully.

Hours later, with his head in his hands, he stares at the enigmatic error message from the sentient being that is the Scala type-inference engine. It mocks him. Miles away, Weiqi looks up from an abstract algebra textbook and smiles.

Some time later, the problem space is reduced considerably. The goal is now: a working Scala program that has the following, simple Latin phrase:

Lorem ipsum dolor sit amet , consectetur adipisicing elit. Ut enim
It contains some key ingredients: the comma, the period, and capitals. True, it does not contain an ending period, the word "do", or many of the other words.

Time passes.... Much is learned, or at least inferred, about Scala -- far more so than a "Hello World 2" program. And finally.... a modest success:

object Lorem {
def ipsum(x: Any) = this
def sit(x: Any) = println("Darn you, Weiqi!")
}

class Consectetur {
def adipisicing(x: Any) = this
def enim() = "It is late on a Friday"
}

class Elit {
def Ut() = this
}

object Runner {
def main(args: Array[String]) {
var dolor, sit, amet = null
var consectetur = new Consectetur()
var elit = new Elit()

println( Lorem ipsum dolor sit amet ,
consectetur adipisicing elit. Ut enim )
}
}
The intrepid developer smiles at the output:

Darn you, Weiqi!
((),It is late on a Friday)
Quietly, he turns to the window and watches the clouds pass across a moon-filled sky. An evening well-spent.

ps. This is a good exercise for a newcomer to Scala. Though the next logical step is much more interesting: write a Scala program that accepts the Latin text as input and generates a Scala program that can use the phrase as a pseudo DSL.

Your Parents are making me buy a Mac

I've needed a new computer for awhile, and I've been long debating some issues. One is laptop versus desktop, but the primary issue is To Mac or Not To Mac.

There have been plenty of reasons to consider going with Apple:

  • For years, the NFJS gang of hoodlums have been touting the Macbook Pro. I can't tell you how many impromptu, unpaid testimonials I've seen in the middle of a presentation.
  • OCI has a sizable, passionate group of Mac folks. I've heard a rumour that they want to change the local traffic light near OCI HQ to be horizontal and Aqua: like the OS X window buttons (not really).
  • If Charlie Rose can take one for the team when falling, so as to protect his Macbook Air, then surely I can learn to use one mouse button.
  • The brick-and-mortar Apple Store is a temple for materialism: I am absolutely sucked in by the products, the ambience, and gorgeous lighting. Against the backdrop of bland Banana Republics, Foot Lockers, and food courts, The Store stands out like a beacon in the mist: an oasis of cheerful, productive humanity in an otherwise bleak and desolate existence. During a visit, I believe that I will be successful, cool, happy -- nay, complete -- if only I surrender to the inevitable and swipe that credit card.
Powerful stuff. But the real deal-maker is the following:

  • I have heard N developers vow, after independent episodes of installing a new computer for their parents, that they want to have nothing to do with Vista.

That's my tipping point: N is sufficiently large. I'm seeking asylum from Vista, without even having tried it. (Send me the hate mail. Until I get the Mac, I'm lonely.)

I can't bear the thought of more Windows problems. I have not done my homework on my current Windows problems (I've been meaning to really understand the Registry for years now) and the issues simply accrue.

I need brand-new problems (I'm sure OS X has some?) and a fresh start.

I'll report on The Purchase and how things are going. And I'll send your folks a thank-you.

M.

ps. Yes, Linux is an option. I do own SuSe here at CtJ HQ but I'm simply caught in an iTractorBeam.

Wednesday, March 26, 2008

Groovy 201: How to Win a Bar Bet on Copy-Paste

A Java program and a Groovy program walk into a bar.

The barkeeper says "Hey fellas.... One check or should I just copy-paste Java's and start removing semi-colons?"

Ha ha! How quaint. (Kinda) Funny, because with Groovy's syntax, you can just copy-paste Java programs into Groovy and start from there. Right?

Whoa Nelly

Well, almost. Some Groovy 101 articles will state this. Sometimes they say "you can copy-paste virtually any Java program..."

The 2%

If you are in a pub or bar, and someone makes the first claim, and you sense that they aren't simply being brief, you should have a ready retort.

You could win some cash, or a drink.

This is not a criticism of Groovy, but there are some differences (on the order of 2% or smaller), as enumerated here on the Groovy website.

The Pub Winner

Here is the example to keep in your head. Consider the following Java program:

public class Mirror {
private String image;

public Mirror(String image) { this.image = image; }

@Override
public boolean equals(Object rhs) {
Mirror rhsMirror = (Mirror) rhs;
return this.image.equals( rhsMirror.image );
}

// TODO: hashCode()

public static void main(String[] args) {
Mirror a = new Mirror("you");
Mirror b = new Mirror("you");

if( a == b ) {
System.out.println(" same object! ");
} else {
System.out.println(" different objects ");
}
}
}
As you know, in Java, this will print "different objects".

If you copy this file from Mirror.java to Mirror.groovy, it will run, even with annotations.

But the output will be different.

The Upshot

Groovy identity is different from Java identity. There is a good write-up on this philosophy on the Groovy site (again, here).

I don't judge, in this case. I simply give facts. Now, go out and win some bar bets.

Sunday, March 23, 2008

Does Beta Mean 'Escaped' ?



When talking to non-geeks, I'm hard-pressed to explain what a "Beta version" really means.

At some shops, Beta seems to mean "Time is up! Put it into production for a client."

At Google, it seems to have this ambient air of modesty that quietly implies to the competition: "we can crush you without fully trying".

I'm beginning to think it may mean "escaped". This is based on a quote from a colleague on a past gig:

Software isn't released: it escapes. -- Anon

A case in point (and a plug): a friend has developed a site called Online Task List. It's a fine, free site for tracking tasks: I use it for my weekend agenda and reminders; some of our team uses it at work as a "task messageboard".

Though past Beta now, he originally put a Beta version online. He considered the site closed, and quietly worked on it. Soon, he had users signing up. He was surprised at the speed with which people found it. Now, he has dozens upon dozens. One explanation, of course, might be that Google eventually indexed it and it was turning up for the trendy "online task" searches (a la the GtD book).

I prefer a more romantic theory: it saw an opening.... and escaped.