November 30, 2005

Comment placement

> I once read that a good comment will appear on every conditional branch or loop

But be sure to put them outside the loop, so people won't have to read them over and over.

That gave me a good chuckle. Found on Slashdot

Link

November 19, 2005

Fear at the starting line

I see so many people standing at the starting line (figuratively speaking), too overcome with fear of what the race might be like to cross it. They plug their ears and hum loudly so they won't hear the starting gun.

Often, they make the assumption that they're the only ones feeling that way. Nothing could be farther from the truth. We all feel it.

The Occupational Adventure: Fear at the starting line

Link

The Way We Were

All forums start off good, enjoy a "honeymoon period" in which they continue to be good, and then steadily decline… from the point of view of each individual observer.
The Fishbowl: Charles' Rules of Online Forums

I see similar phenomenon all over with schools, companies, governments, societies, etc, a widespread perception that everything was better in the past and that things are sliding toward malaise. I think it comes from how forgetful we all are.

Link

November 17, 2005

Facts About Chuck Norris

Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean.
Random Chuck Norris Fact: Top Thirty Facts

Link

November 15, 2005

Getting things working

I've noticed an ebb and flow pattern in my coding style, a messy phase followed by a clean up phase.

The messy phase is when I'm just trying to get new things working smoothly. I'm trying lots of things, mangling the existing code to play with the new, seeing what works well, what's elegant and what's crufty. And as I do, the quality and organization of the code goes to complete shit, all while the design is hopefully improving.

The clean-up phase happens once I feel satisified the hacks are minimal and the design is solid. During clean-up I start making sure all the variable, method and class names are decent, all the bits of code are in the right files and all the files have good names.

Then I sit and take some pride in my nice clean project. Ahhh, so nice!

And the next day I start to mess it up again with the next round of features. Circle of life and all that crap.

Link

November 12, 2005

Antlr rocks

I'm in the middle of creating a formula language for CouchDb, I'm calling it Fabric (backcronym suggestions welcome). Its not going to be an exact clone of Notes Formula Language, but its going to be close.

Since I've already written a production formula engine, it should be a cake-walk, right? Well, when I rewrote the Notes formula engine, I didn't have to worry about a compiler, the engine ran off of a compiled byte code. Because the byte code is meant to be exclusively machine readable its much easier to deal with programmatically.

So for my new engine I have to write something I've never written before, a compiler. There are two ways to go about it, write it by hand, or use a parser-generator. Since this language has a pretty simple syntax, writing a compiler by hand would be pretty straightforward and the most optimizible. But I figured a good parser-generator should create fast code and the whole process of learning to use a parser-generator would be more useful in the long run.

After a little research and poking around, I decided on Antlr (its website was the pertiest). After a few days of my head reeling from trying to wrap my head around it, I thought I had made a bad choice, this tool was too complex to be useful. So I'd get frustrated and angry (words make Hulk mad! SMASH!!) and desperately consider abandoning it for another tool. But the other tools didn't seem any better (just different and usually less documented overall), so I'd come whimpering back to Antlr.

After a while of extremely slow going and lots of frustration, I've started to figure out the Antlr world view and now I'm finally making significant progress (I think it takes a while for my brain to rewire itself sufficiently). And I now see Antlr is far more powerful than I first thought, it provides all sorts of easy ways to analyze and transform abstract syntax trees, and the lexing/parsing code it generates is impressively optimized.

But while the logical design of the Antlr grammar machine is impressive, the syntax it uses isn't what I'd call elegant. Here's a little snippet of the rule syntax:

decl : ( TYPE ID )+
{ ## = #(#[DECL,"decl"], ##); }
;

And this isn't even close to how bad a single rule can look. The syntax is ugly at first, but it's an effective syntax and one that's beginning to grow on me.

Now that I understand the tool better, I'm starting to see new possibilities for its use. Obviously it's great for creating compilers and interpreters, but it's also useful for incorporating existing languages into your applications. For example, if I want to incorporate user-authored Javascript into an application, but I need to limit what those scripts can do, I can use Anltr and its free grammars to analyze the code and validate exactly which language features are being used. Not that I need to do that right now, but I see the possibility in the future.

Anyway, I'm pretty happy with Antlr at this point and soon I'll be writing about Fabric and its design philosophy.

Link

November 9, 2005

"Hi Aunt Mole!"

That commercial cracks me up every time I see it. I don't even know what it's for, I'm too busy laughing to notice.

Link

November 4, 2005

"Always bet on Landry"

John Landry has started a new blog, Dog's Breakfast. John's a former CTO of Lotus and has built quite a few companies of his own. This guy know the business.

And he's not some stuffed shirt, he's a hardcore geek, and I mean that in the best possible way. When I met him for the first time, he was actually familiar with my work on Notes Formula Language. And he pointed out I made it Turing complete. Very cool. How many big time executives even know what that means?

Not only that, at a design review meeting he quite quickly pointed the weaknesses of the architecture we were developing, the same stuff we had been dancing around for months. Very sharp guy.

And a sly guy too. A few years ago at a holiday party we did a Yankee Gift Swap. The rules of the Yankee Swap are simple. You bring a gift, you pull a number out of a hat to determine the picking order. The rule is, you can take anyone else's gift who picked before you, or you can pick an unopened gift. If you take someone elses gift, they have to pick an unopened one. The game is strongly rigged for the player who gets to choose last, since they can see all the gifts (except one unopened one) and no one can take their gift away.

Being the paragon of intellectualism and creativity that I am, I brought a Clapper. You better believe it was the gift to have, changing hands many times during the course of the game. Having the Clapper is like living in a futuristic wonder world.

Landry had last pick, getting his choice of any gift. Naturally he chose the Clapper, and a palpable feeling of envy welled up in the room as he paraded about with the greatest technological achievement know to man. The rich get richer. And more Clappers.

The following year at the same party, we did the same Yankee Swap. I didn't bring the Clapper this time (I'm not made of money you know), but someone else did. It looked suspiciously like the one I brought the previous year. Hmmmmm. And who had the last pick in the Yankee Swap? Why one Mr. John Landry. Hmmmmm. And he chose [drumroll] the Clapper. Hmmmmm.

Now getting last pick in a Yankee swap 2 years in a row, that seemed a little unlikely. I asked the person in charge of the number hat (who I generally believed to be trustworthy, I miss you Jen!) was there anything, eh, amiss in the number selection process? No, nothing she knows of. I used my most intense I-know-somethings-going-on glare to see if she'd crack. Nothing, she appeared to be telling the truth. Or perhaps not intimidated by me. Hmmmmm.

Still, I was convinced it was fixed, I just didn't know how. I pursued further, discreetly asking about if anyone saw anything suspicious earlier, like a Ninja milling about the hat or a device that makes fake Yankee swap numbers? Nothing. Hmmmmm.

Finally as the party was winding down, defeated, I asked Landry directly how did he get the last pick two years in a row?

He'd smiled wryly and said "Always bet on Landry."

Link

Blue Ball Machine

Blue Ball Machine

Trust me, you want to see this.

At first it's like lifting up a rock and finding an ant nest, it seems chaotic as it appears things are moving in a random, disorganized way. But if you focus on just one ant at a time, you'll start to see the larger organization and beauty.

So just focus on one ball at a time and follow it around, it's almost hypnotic.

Link

November 1, 2005

Win32 Cheat Sheet

Win32 cheat sheet

Link