February 07, 2007

Jazz.net goes live

paris.jpg

If you'd like a peek at what I've been up to at work for the past eight months, head over to jazz.net, which just went live.

The details are still kinda sketchy, but expect more real soon now :)

In Technology and Software

Posted at 11:44 PM | Permanent link

January 18, 2007

Eclipse is a dead system

dead_fish.jpg

(DON'T PANIC! I probably don't mean what you think I mean.)

On a long enough timeline, the survival rate for everyone drops to zero.

Steve Yegge has a thought-provoking essay on living systems vs. dead systems, in essence: systems that can be modified at runtime vs. systems that you have to stop (kill) first to modify.

In this context Eclipse is a "dead system" (or "hardware" as Stevey says). And this makes me sad :(

In fact, it's saddened me for a while, though I've never framed the issue in these terms.

Even though Eclipse has a world-class extension system, we have to go through an onerous process of launching and relaunching Eclipse instances to make the slightest change to a plugin.

In contrast, a "living" system like Emacs doesn't have this problem. In Emacs we can evaluate s-expression, set variables, rewrite functions, and swap code on the fly without having to relaunch - which is why writing Emacs extensions is an order of magnitude easier (and more fun) than writing Eclipse extensions.

Stevey also draws a parallel between how long a system can stay running without reboot, and how long people will continue to use the system.

*shrug*

I think it has more to do with how close your system gets to hitting the best solutions to the problems people are trying to solve on any given day. But here's the thing: the problems of today aren't necessarily the problems of tomorrow, nor the problems of ten years from now.

The more malleable your system is, the better its chance of solving the problems of 2007, and 2008, and 2017, and 2027. And as it happens, systems that can be modified without a reboot are much easier to modify and far more malleable than systems that can't.

Eclipse has many advantages over Emacs (mostly in terms of gooeyness), but as ugly as Emacs looks on the outside, it's definitely the more malleable of the two. So, if I had to choose pick which one is more likely to be around in 100 years, my money would be on Emacs. And if history is any guide, that's probably not a bad bet.

UPDATE:

Hehe, as Bill points out in the comments, I do feel like kind of a bastard for writing this post (especially the inflammatory title). But my aim isn't to disparage Eclipse. I love Eclipse. It's a great platform, and it's very good at what it does.

And no... it's certainly not "dying" :)

My aim is to point out that there are other kinds of extensibility out there that we don't typically get with Eclipse... at least not right now, and it's the kind of extensibility I'd very much like to see.

And just for full disclosure, I work for the company that originally founded the Eclipse project. All views expressed here are my own and not those of my employer.

In Technology and Software

Posted at 06:05 PM | Permanent link

January 15, 2007

How to install bzr on Dreamhost

hot_dog_stand_05.jpg

Bazaar or bzr is a Python-based source code management system that I've noticed is becoming increasingly popular amongst small open-source projects.

Right now I'm not sure what advantages bzr might have over other SCM systems such as Subversion (I suspect it's more light-weight), but it's handy to have when you want to grab the source for a project like Planet Venus.

Here's how I installed bzr on my Dreamhost shell account.

(note: There's not anything special here. This is all pretty standard Unix tarball installation fair. In fact, there's little here that isn't already in the bzr installation guide. I'm providing this as a confidence cushion for other Dreamhost users.)

Fetch it

Downloads of bzr are available here: http://bazaar-vcs.org/Download

Fetch the tarball install into a directory of your choice:

~$ cd ~/incoming
~/incoming$ wget http://bazaar-vcs.org/releases/src/bzr-0.13.tar.gz

Unzip it

~/incoming$ tar -zxvf bzr-0.13.tar.gz

Install it

~/incoming$ cd bzr-0.13
~/incoming/bzr-0.13$ python2.4 setup.py install --home ~

No problem...

Adjust environmental variables

... except one hiccup when we try to run bzr:

$ bzr
bzr: ERROR: Couldn't import bzrlib and dependencies.
Please check bzrlib is on your PYTHONPATH.

Traceback (most recent call last):
  File "/home/joshstaiger/bin/bzr", line 62, in ?
    import bzrlib
ImportError: No module named bzrlib

Because we installed bzr in our home directory, the Python code behind bzr is living in a nonstandard location that Python can't see. We add this location to our Python library path by setting the PYTHONPATH environmental variable in our .bashrc.

Modify .bashrc as follows:

echo "export PYTHONPATH=/home/joshstaiger/lib/python" >> ~/.bashrc

(replace "joshstaiger" with your shell login name)

We'll also want the bzr manual to be in our MANPATH if it isn't already, so we can read about bzr in our spare time instead of picking up women:

echo 'export MANPATH=$MANPATH:/home/joshstaiger/man' >> ~/.bashrc

Source .bashrc (or relogin) to pick up our changes:

. ~/.bashrc

Run it

And we're set:
~$ bzr
Bazaar -- a free distributed version-control tool
http://bazaar-vcs.org/

Basic commands:

  bzr init           makes this directory a versioned branch
  bzr branch         make a copy of another branch

  bzr add            make files or directories versioned
  bzr ignore         ignore a file or pattern
  bzr mv             move or rename a versioned file

  bzr status         summarize changes in working copy
  bzr diff           show detailed diffs

  bzr merge          pull in changes from another branch
  bzr commit         save some or all changes

  bzr log            show history of changes
  bzr check          validate storage

  bzr help init      more help on e.g. init command
  bzr help commands  list all commands
  bzr help topics    list all help topics

In Technology and Software

Posted at 10:54 PM | Permanent link

January 12, 2007

The iPhone is NOT a platform

apple-store-times-square-02.jpg

Ok, I was wrong.

Looks like they will be fighting us every step of the way.

*shrug*

Steve just lost my willingness to give him $599 and put my balls in a vice grip with his carrier (which I otherwise would have done gladly, just to play in the new sandbox).

I will, however, continue to write webapps that incidentally work well on his phone, safe in the knowledge they'll no longer have to be crippled to be mobile.

In Technology and Software

Posted at 03:51 AM | Permanent link

January 09, 2007

The iPhone as a platform

apple-store-times-square-07.jpg

Tonight, every nerd I know is salivating over the iPhone.

Obviously people are orgasmic over the sexyness: the form-factor, the fluid touch-screen, the (for serious!) smart calling software, the media apps, and the internet connectivity.

But I think the real story here is we finally have a real platform for mobile application development, complete with real OS, real apis, and a real web browser capable of running real web applications - all delivered by a company that isn't going to fight us every step of the way.

And the sexyness ensures it's going to be very popular.

It almost sounds like the mobile platform we've been waiting for for the past ten years!

This is going to be big :)

In Technology and Software

Posted at 09:47 PM | Permanent link

December 29, 2006

Metaprogramming method closures in Ruby

night01.jpg

In my previous post, Of Closures, methods, procs, scope, and Ruby, I discussed how blocks and procs are closures in Ruby while methods are not.

To review, this won't work:

class MyClass
    @friend

    hello_string = "Hello"

    def initialize
        @friend = "Kitty"
    end

    def say_hello
        puts hello_string + " " + @friend  # Bzzt!  hello_string is not in scope
    end
end

my_object = MyClass.new

my_object.say_hello # Bzzt!

And neither will this (at the toplevel):

hello_string = "Hello, world!"

def say_hello
    puts hello_string  # Bzzt!  hello_string is not in scope
end

say_hello # Bzzt!

In response Kurt hypothesized we could get method closures in Ruby with a bit of metaprogramming.

And he's right.

As Bryce points out, Ruby's Module class has a private method nammed define_method that defines a new method given a symbol representing its name, and a block representing its body.

Because the second parameter is a block, and blocks can be closures, this gives us the key to defining method closures.

Within the context of a class definition:

class MyClass
    @friend
    hello_string = "Hello"

    def initialize
        @friend = "Kitty"
    end

    define_method(:say_hello) { puts hello_string + " " + @friend }
end

my_object = MyClass.new  

my_object.say_hello # Hello Kitty

Yay!

But suppose we want to define one-off methods from the top-level instead.

Because define_method is private, normally we wouldn't be able to call it outside a class definition, but we can get around this using the send hack.

Let's define a convenience method:

def lexdef(method_symbol, &block) 
    self.class.send :define_method, method_symbol, &block
end

And now we can define method closures from the toplevel:

hello_string = "Hello"

lexdef :say_hello do |friend|
    puts hello_string + " " + friend
end

say_hello "Kitty" # Hello Kitty

Voilà! An unobtrusive syntax for defining method closures!

I like it :)

As of Ruby 1.8, blocks don't yet support Ruby's first-class syntax for receiving block arguments. So this won't work:

hello_string = "Hello"

lexdef :say_hello do |friend, &formalize|   # Bzzt!  Syntax error
    puts hello_string + " " + yield(friend)
end

say_hello("Kitty") { |friend| "Ms. " + friend }

But word on the street is &block arguments to blocks will be supported in Ruby 1.9.

In Technology and Software

Posted at 06:34 PM | Permanent link

December 28, 2006

The Ruby send hack: how to gain access to an object's privates

lady_liberty01.jpg

I stumbled across an interesting Ruby hack that doesn't seem to be written down anywhere.

It turns out that private methods in Ruby aren't entirely private, and with a bit of indirection you can gain access to them as though they were public methods.

In Ruby 1.8 all we have to do is use the Object#send method.

To demonstrate:

class MyClass
    private
    def say_hello(name)
        puts "Let's go back to my place, #{name}."
    end
end

my_object = MyClass.new
So we get smacked if we try:
> my_object.say_hello
Nomethoderror: private method `say_hello' called for #<MyClass:0x820b4>
	from (irb):8
	from :0
but instead:
> my_object.send :say_hello, "world"
Let's go back to my place, world.

Touché!

Now, honestly, this strikes me as odd. Conceptually, I don't see why send should function differently from an ordinary method call with respect to access control.

The rubydoc for send says nothing of this, and there is some debate on the mailinglist as to whether Ruby 1.9's send will maintain this behavior.

But for now this can be very useful if you disagree with a class designer's method access choices.

In Technology and Software

Posted at 01:06 PM | Permanent link

December 26, 2006

Of closures, methods, procs, scope, and Ruby

giant-piano-06.jpg

One thing I hate about Ruby is that Ruby methods aren't closures.

For instance, this blows up:

hello_string = "Hello, world!\n"

def say_hello
    puts hello_string # bzzt! hello_string isn't in scope
end

say_hello # bzzt!

Which is a little odd because Ruby does support closures on procs:

hello_string = "Hello, world!\n"

say_hello = Proc.new do
    puts hello_string
end

say_hello.call # Hello, world!

It kinda sucks that every time I want to create a closure I'm forced to use the less succinct ".call" syntax.

So why can procs be closures while methods cannot?

After a bit of thinking I realized this comes down to a design tradeoff on whether or not we have to type "self" or "this" all over the place when writing methods as we do in Python and JavaScript.

In Ruby we don't have to do this, and Ruby accomplishes this by making procs and methods two different things with different scoping rules.

Proc bodies have a lexical scope like functions in Lisp and JavaScript, meaning that when Ruby encounters a free variable inside a proc body, its value is resolved within the context the proc was defined. This is what makes closures possible.

Methods are different, however. A method's context is the object to which they are bound. When Ruby encounters a free variable inside a method body, it assumes the variable refers to another method on the object, and this is what saves us from having to prefix same-object methods with "this" or "self".

To demonstrate:

irb(main):171:0> hello_string = "Hello, world!"
=> "Hello, world!"
irb(main):172:0> def say_hello
irb(main):173:1>     puts hello_string
irb(main):174:1> end
=> nil
irb(main):175:0> say_hello
NameError: undefined local variable or method `hello_string' for #
	from (irb):173:in `say_hello'
	from (irb):175
	from :0
irb(main):176:0> def hello_string
irb(main):177:1>     "Hello, world!"
irb(main):178:1> end
=> nil
irb(main):179:0> say_hello
Hello, world!
=> nil

Personally, I'm not sure I like this tradeoff.

Procs and methods are conceptually very similar. They are both composed of a list of arguments, a block of code, and a context in which the block is evaluated. I'm not sure they should be different things.

The way I see it, a method should just be a special case of proc that happens to have an implicit "self" parameter. In this case methods would inherit the proc scoping rules and therefore could be used as closures.

If this means we have to be verbose and type "self" to call other methods on the same object, I'm fine with that.

And in fact, this is how things work in JavaScript:

var helloString = "Hello";

var myObject = { 
    friend: "Kitty",
    sayHello: function() { 
        print(helloString + " " + this.friend);
    }
};

myObject.sayHello(); // Hello Kitty

Matz clearly recognizes that there are issues with Ruby's current scoping implementation, so maybe this is one of them.

But, hey, this kind of tradeoff may just be a Rubyish thing to do, and I probably dig closures more than most.

In Technology and Software

Posted at 05:54 PM | Permanent link

December 20, 2006

Real life search

I love how whenever I lose something in my house, my first instinct is:

Oh, no problem. I'll just do a search.

And a short instant later...

Goddammit!

In Technology and Software

Posted at 08:39 PM | Permanent link

December 18, 2006

Five things you didn't know about me

starfish_dance01.jpg

There's a massive game of tag going around the blogosphere. I've been tagged by Bill and Dave.

So here goes. Five things you didn't know about me:

  1. I all but gave up Computer Science in favor of law my junior year of college. I even convinced my friend Evan to do the same... except he actually did :)
  2. I've been to London, Paris, Amsterdam, and Zurich, but only set foot west of the Mississippi in May of this year.
  3. I scored higher on the language portion of the SAT than the math portion.
  4. I play piano.
  5. I've been skydiving... twice.

I tag Ryan, Jeff, Kurt, Vinnie, and Anton.

In Matters that are otherwise worthwhile, Technology and Software

Posted at 10:30 PM | Permanent link

December 15, 2006

On Variable Naming in Code

night

Much is made of the pain of typing long variable names (or function names or class names), but code is usually read more often than it's typed. And when I'm reading code (even if it's my own), I'm grateful for names that err on the side of descriptiveness.

This means:

  • navigationElement instead of navigation or nav
  • queryString instead of query, queryStr, string, or str
  • libraryLookupUrl instead of libraryLookup or url

The exceptions are common language idioms which any programmer could reasonably be expected to know (ie: cons in Lisp, def in Python, x as an index into array loops). These should be abbreviated as their meaning is more intrinsic and independent of the name.

In Technology and Software

Posted at 08:37 AM | Permanent link

December 13, 2006

When designing a user interface ...

... imagine that your program is all that stands between the user and hot, sweaty, tangled-bedsheets-fingertips-digging-into-the-back sex.

Words to live by :)

I love xkcd.

In Technology and Software

Posted at 05:56 AM | Permanent link

December 12, 2006

Surprise! It's not Java.

Bubble Tea

So Java SE 6 is out.

I think the most exciting thing about this release is Sun's inclusion of Rhino, Mozilla's JVM-based Javascript engine, out of the box.

This could mean that Sun finally recognizes there *might* be life after Java for the JVM. If so, this is very good news.

In Technology and Software

Posted at 09:01 PM | Permanent link

December 11, 2006

Wall Street to Craigslist: Bitchsezwhat!!?

skate_01.jpg

Wall Street is finding it a little hard to swallow that Craigslist is more interested in maximizing user value than revenue.

To be fair, it's much easier for a privately held company like Cragislist to do this kind of thing than a publicly held one.

I'm sure Craig Newmark and friends have the leverage to be opinionated about how they run Craigslist, whereas when you're dealing with millions of different shareholders with no long-term commitment to the company, it's a lot harder to find a common goal other than "make money as fast as possible".

As tech becomes less capital intensive, it makes me wonder if we'll see privately held companies like Craigslist wield more and more power because they can try innovative business models, they can think long term, and they don't have to march to Wall Street's drumbeat.

In Technology and Software

Posted at 07:54 PM | Permanent link

December 06, 2006

Spam

alcohol.jpg

The New York Times reports that spam has doubled over the past year and spammers are combating Paul Graham's plan for spam by hiding their hello kitty vibrator ads in bitmap images where the filter can't pick them out.

I've been using Gmail as my mail client for a while now. If there were a way to whitelist who can send me file attachments (ie: anyone in my addressbook) my Gmail spam would be near-zero.

As it is 5-10 attachment spams get through the filter per day.

If solving spam means sacrificing email attachments, I'm all for it. Then again, maybe not (NSFW!!).

In Technology and Software

Posted at 10:40 PM | Permanent link

A PBF comics RSS feed WITH IMAGES

PBF195-The_Pacific_Council.jpg

Feed: http://www.joshstaiger.org/services/pbf-rss/

Source: pbf-rss.rb

Writing this script reminded me of just how much I love Ruby.

I was tempted to write in Common Lisp - just for fun, but there's no Lisp equivalent of Ruby's open-uri module. And dammit if open-uri isn't really convenient.

In Technology and Software

Posted at 01:02 AM | Permanent link

November 17, 2006

Man

7:48:46 PM [anonymous-friend]: ok
7:48:48 PM [anonymous-friend]: man question
7:49:22 PM joshstaiger: no manual entry for question
7:49:27 PM joshstaiger: ok, that was bad

In General, Technology and Software

Posted at 11:21 PM | Permanent link

November 16, 2006

MIT making the switch?

Looks like MIT is considering a switch from Scheme to Python for its introductory CS course.

I always thought it was pretty cool that MIT started off their students in Scheme. Probably did wonders for separating those with a deep understanding of Computer Science from the code monkeys.

But hey, Python is a great teaching language, and it looks like Hal Abelson (SICP) is involved in this course as well. I'd be surprised if it's not very well done.

In Technology and Software

Posted at 11:47 PM | Permanent link

November 13, 2006

Doubletake

Wow, Rumsfeld gets fired and Java gets opensourced.

Am I dreaming?

Hell must be chilly these days.

In Matters that are otherwise worthwhile, Technology and Software

Posted at 09:43 AM | Permanent link

September 22, 2006

Advice for web application developers (circa 2006)

"why don't you take your skirt off and write some f***ing Javascript man?!"

-- Bill Higgins

(quoted with permission)

I love it :)

In Technology and Software

Posted at 08:30 AM | Permanent link

September 19, 2006

Who reads Knuth?

If I get one more email FROM THE DESK OF THE LOTTO CHANCELLOR I'm going to stick a fork in my eye and join Donald Knuth in signing off email altogether.

Hmm, Knuth... Knuth came up in conversation the other day!

Over IM I suggested to Bill we "knudge" a particular project in a particular direction.

"knudge? have you been excessively reading knuth?"

No... No, I haven't.

Which begs the question... Does anyone read Knuth? There's a consensus he's a great man, and I get warm fuzzies knowing he's a product of my alma mater. Yet, I personally can't think of anyone who's read his work.

I own volumes 1-3 of The Art of Computer Programming, and they look real impressive sitting on my bookshelf (just don't tell anyone they've never been opened). Same story for everyone I know.

I get the feeling Knuth's writings are becoming the "classical literature" of computer science - books everyone wants to have read, but nobody wants to read.

Then again, speaking as someone who's never read Knuth, I probably come off as a young, naive, arrogant bastard (as I do sometimes).

So I'm curious... I'd like to read Knuth. Have you read Knuth? What did you think? I could use some knudging.

Steve Jobs meets Donald Knuth

"It's a pleasure to meet you, Professor Knuth," Steve said. "I've read all of your books."

"You're full of shit," Knuth responded.

In Technology and Software

Posted at 08:05 AM | Permanent link

May 22, 2006

My trip to California

Yes, I'm alive :)

I've been meaning to write, but it's hard to find a spare moment. Images of ugly code and piano chords and Jazz and cats dance in my head.

This entry has been sitting in draft state for three weeks and is now belated, but what can ya do? I'm publishing it.

California was amazing.

Startup School

Startup School was great, as expected.

paul_graham.jpg

This time around with real founders such Joe Kraus (Excite/Jotspot), Mark Fletcher (Bloglines), Caterina Fake (Flickr), and Joshua Schachter (del.icio.us) speaking we got an excellent "view from the trenches". Lots of great tips.

I'll skip the details as they've been covered extensively elsewhere.

How did it compare to last fall? Favorably. In fact, I liked this year's conference better.

The speakers last fall were great, but the lineup included more finance, VC, journalist, economist, and inspirational types, giving the conference a somewhat "meta" feel. This time around there were more founders with more battle stories and I liked that.

A side effect of raving about a previous conference is that a large number of your friends find their way to the next one :) It was great to see Vinnie, Martin, Didier, Quinnie, Pratik, Rich, and Jason at the conference.

And as expected, I met many great people. That's what happens when you throw a bunch of young, smart, entrepreneurial types in a room together. Too many great conversations to mention, but if we talked, I really enjoyed it, so thank you!

Super Happy Dev House

After the conference I was really feeling the effects of jet-lag and wanted nothing more than to go home and collapse on the couch -- but that was not to be.

Vinnie mentioned he was going to a party later that night that he assured me I would really enjoy. The name of the party? Super Happy Dev House. Yeah... Super Happy Dev House.

So I had Jason drop me off at Vinnie's apartment in Palo Alto afterward and this gave me a chance to tour the famous Meetro World Headquarters (picture1, picture2).

That was fun :)

Afterwards Vinnie, Didier, Zak, and I headed out to the party.

So, the Super Happy Dev House. What is the Super Happy Dev House?

This is the Super Happy Dev House:

shdn04.jpg

shdn03.jpg

shdn02.jpg

shdn01.jpg

The Super Happy Dev House is a party just south of San Francisco hosted by David Weekly of PB Wiki fame. It's half hackfest, half party, and it's amazing. I've never seen anything like this. I had no idea that things like this existed.

About SuperHappyDevHouse (according to the SuperHappyDevHouse Wiki)

The party runs from 7pm in the evening until 7am the next day, and the idea is you bring your laptop and hack... or not. It's freeform. You can sit around and work on a project amongst other smart people doing the same, or you can walk around and get to know those smart people.

But whatever it is, it's cool. I met some amazing people including David Weekly, himself, Gabe Rivera of Memeorandum, some of the Technorati folks, and countless others.

Everyone is really smart. Everyone has an idea. And everyone wants to talk about it.

It's an incredible atmosphere, and it made me realize what's special about Silicon Valley... and why I need to move there... soon...

The Flat

We left the Super Happy Dev house 4am - ish and everyone was really tired. But the night wasn't over as it turns out.

During the drive home, at the last exit before we hit San Jose:

*scraping noise*
Vinnie: "What's that noise? I think we're dragging something."
Me: "Umm, no dude, I think your have a flat."

We blew a flat in the darkest stretch of Highway 280...

... and we had no flashlight ...

... so we had to use our cellphones as light ...

... Oh we have laptops! Laptops give off more light! ...

... Somebody take pictures of this, I need to blog about this! ...

tire_change05.jpg

tire_change02.jpg

tire_change01.jpg

I'm a nerd :)

Thanks to Zak, who had the most experience of the four of us with changing a tire.

"Old" Friends

After sleeping half the next day I called my "old" college friend Anders (college buddy presently working on PhD in Chemical Engineering at Stanford) to see if he and Vinay (other college buddy presently working on PhD in Electrical Engineering at Stanford) if they would like to meet for dinner. Why yes! So we met at a Mexican restaurant (with ridiculously cheap margaritas) just off campus.

Afterwards I got a tour of the Anders and Vinay pad. Foosball was played (apparently I'm past the prime of my foosball career, which is a bad thing), and much good conversation was had. It was great to catch up.

By the way for those who know him, Anders is still the same old Anders - he still doesn't sleep.

The next day Anders gave me a brief tour of Stanford, which is incredibly beautiful if you've never been.

stanford03.jpg

stanford02.jpg

stanford01.jpg

Then he dropped me off at the Caltrain station where I took the train into San Francisco for the rest of the day.

San Francisco

This was my first time in San Francisco, and I spent most of the day doing unashamedly touristy things - Pier 39, Fisherman's Wharf, Ghirardelli Square, Trollies, Golden Gate Bridge (which is *massive* in person).

There's not much to say, really, except I love this city and hope it won't be long before I return.

san_francisco038.jpg

san_francisco005.jpg

san_francisco019.jpg

san_francisco027.jpg

san_francisco037.jpg

san_francisco053.jpg

san_francisco067.jpg

san_francisco076.jpg

san_francisco094.jpg

san_francisco129.jpg

san_francisco113.jpg

Summary

Tons of other Photos in my California Photoset.

In short, I'm going to have to move west to the Bay Area, I don't see any way around it. So that's that.

In Matters that are otherwise worthwhile, Technology and Software

Posted at 10:30 PM | Permanent link

April 27, 2006

Startup School 2006

Tomorrow I'm catching a plane west for Startup School 2006 at Stanford University. If it's anywhere near as good as it was last fall at Harvard, should be a treat.

Looks like another impressive array of speakers. Looking forward to chatting with a few of them, along with the myriad of other young entrepreneurial types.

It will also be nice to see Vinnie, Martin, and Jason each of whom will be at the conference.

Going to be there? Or have I forgotten you live in the Bay Area? Gimme a call: 216-570-8595. I'll be in town until Tuesday evening.

In Technology and Software

Posted at 11:06 PM | Permanent link

April 01, 2006

Pretty Printing XML Attributes

Bill poses an interesting question on his blog.

Why is element-based XML easier for humans to read than attribute-based XML?

IE:

<person>
    <firstName>Bill</firstName>
    <lastName>Higgins</lastName>
    <emailAddress>bhiggins@us.ibm.com</emailAddress>
    <city>Durham</city>
    <state>NC</state>
</person>

is easier to read than:

<person firstName="Bill" lastName="Higgins" emailAddress="bhiggins@us.ibm.com" city="Durham" state="NC"/>

I think the answer is that we never learned good formating conventions for long lists of XML attributes. In such cases, most people are content to let the attributes run horizontally off the side of the page (sucks).

If we did the same thing with element-based XML, it would be hard to read as well:

<person><firstName>Bill</firstName><lastName>Higgins</lastName><emailAddress>bhiggins@us.ibm.com</emailAddress><city>Durham</city><state>NC</state></person>

I use the following convention for long attribute lists, which I've kind of borrowed from Lisp (all roads lead to Lisp):

<person firstName="Josh"
        lastName="Staiger"
        emailAddress="joshstaiger@gmail.com"
        city="Durham"
        state="NC" />

Much easier on the eyes, huh?

My algorithm goes something like this:

Write the first attribute on the same line as the tag name. Each consecutive attribute gets its own line and is indented to the level of the first attribute. Write the closing angle bracket on the same line as the last attribute.

I even wrote a SAX-based Python script which slurps XML and pretty prints it in this manner. I can dig it up and post if anyone is interested.

In Technology and Software

Posted at 08:04 AM | Permanent link

March 20, 2006

Pink Bunnies and Lisp

The problem with Lisp is that once you understand it... and I mean really understand it ... really grasp the implications of code as data and having the full power of the language available at all times, it causes you to go a little bit insane.

I've seen the future. The future is 1958, and it's all madening enough to make one want to put on a pink bunny outfit, wave a white flag, and mumble something about going to rodeo clown school (where the real crazies live1).

It's like finding out the ancient Romans had cold fusion, yet we continue to use crap like fossil fuels.

Nowadays whenever I'm on a date with a girl, I somehow manage to bring up the topic of Lisp. If that's not insane I don't know what is. Incidentally, this explains both why I'm still single and why the number of Lispers seems to be decreasing with every passing generation.

What a state of affairs...

Well, I'm off to find my propeller hat and head to work... Try not to trust me with any heavy machinery, though. I don't recommend it.

seriously.jpg

[1] That was a joke. No offense to any rodeo clowns. I don't actually know enough of them to know if they're crazy on the whole.

In Technology and Software

Posted at 08:18 AM | Permanent link

March 08, 2006

Notes for CS Undergrads: Do I really need to know assembly?

Paraphrasing a recent question from a CS undergrad:

Do I really have to know assembly? I hate everything about the language we're using. It's pretty much obsolete. It's hard to debug, and it is VERY time consuming.

etc. etc. ad infinitum

Yes, learning some form of assembly is very important. In order to be a competant computer scientist you need to know how the machine works down to the metal.

Even if you never write production code in assembly (and god I hope you never have to do that unless you happen to be writing a compiler or optimizing a critical path), understanding how to peek and poke registers and memory addresses under the Von Neuman architecture is key to grasping why certain higher level abstractions are what they are.

If you don't understand assembly then chances are you don't *really* understand pointers in C (and most people don't) which likely means you don't *really* understand references in C++, Java, Perl, Ruby, or Lisp either... nor why C and Java arrays aren't resizeable... nor why 2,147,483,647 + 2,147,483,639 can sometimes equal -10.

Needless to say, this leads to all manner of stupidity.

Yes. Learn assembly. Yes, yes, yes, absolutely! Even if it's for an architecture that's not in heavy use... Even if you're never paid to write a line of it in your life... It's like veggies and vitamins. It's good for you.

In Technology and Software

Posted at 08:06 PM | Permanent link

February 24, 2006

Tech Book Binge

Books I've bought over the past week:

Total: $208.92

This is what happens when you mix reading great technical essays with wine and amazon.com a few clicks away.

These are mostly the books from this list that I haven't read yet. Oh boy just wait until I go back and read this other list with a glass of wine in hand. That one's going to hurt the old pocketbook.

Luckily, I've become a true believer in the Mark Cuban philosophy of read as much as you possibly can. One good idea gleaned from a book can potentially pay for itself many times over over the course of a lifetime.

Nine times out of ten you can tell how good a programmer is by looking at what's on his bookshelf (assuming that he actually reads what's on his bookshelf and it's not just there for show). Most programmers don't read books on programming at all. Draw your own conclusions from that.

I've been trying to take up the habit of reading for ~3 hours per day. I think it's easier if you get up early in the morning, read for an hour and a half before work, and then read some more in the evening. This ensures that you've already got some reading in the bag before you tire yourself programming for eight hours straight, and it usually helps with the motivation to keep going in the evening. A nice bonus is that it also gives you something to think about during your morning commute (if you have one).

In Technology and Software

Posted at 07:47 PM | Permanent link

February 22, 2006

Wordiness Considered Harmful

Good programmers know that code is not an asset. Code is a liability. Lines of code are something you spend in order to build a product.

Why?

Two reasons (mainly):

  1. The only code you can be absolutely, positively sure is bug free is no code.
  2. The more code you write, the more you or someone else has to (re)read to understand what your system is doing.

This is the Zen.

I was pondering this idea on my way home from work this evening when it hit me that there is actually a corollary in writing (English, that is).

Words are not assets. Sentences are something that you need to spend to get your point across.

Whenever I finish a new blog, the first thing I do is go back and delete all the nonessential crap: extra words, prepositional phrases - usually sentences and paragraphs too. A lot of the in order to's, that's, anyway's and so's get the axe.

Then I go back and read what I wrote again with an eye towards rewording sentences so they require fewer words. Then I go back and rewrite what I wrote with an eye towards rewording sentences so they require fewer words.

Why does this make your writing better?

In our code corollary, above, it has more to do with point two than point one. Words are things that your eyes have to travel over and your mind has to process in order to absorbe their meaning. Reading, itself, would really blow if it weren't for the ideas conveyed by those words on the page. The less you have to read to get at that meaning the better1, but then if extra words are necessary to convey the exact feeling you want then they're necessary and there's nothing to be done about it.

This is why someone like Jane Austen is such a pleasure to read while someone like Kant is so awful that we mostly just keep him around to make fun of his writing in essays like this2.

In most cases, however, the difference isn't so pronounced. It's more subtle and subconscious.

It's the difference between walking into a room that has just been dusted and one that hasn't. Ninety-nine times out of a hundred you can't peg the difference unless you're specifically looking for it. You just know that the tidy room feels better.

Concise writing just feels better.

In and of itself, it may not be the quality without a name (that magical quality that defines good writing). But if the quality without a name is there, it allows it to come through more clearly. So bring the axe, and keep it clean.

This, similarly, is the Zen.

[1] With notable exceptions mostly having to do with poetry and word play I think.

[2] Ok, I'm being facetious here. I don't actually know very much about Kant. I'm sure his philosophies are brilliant in their own way. I just wouldn't know because whenever I try to read his stuff it feels so much like trying to wade through maple syrup that I have to stop.

In Matters that are otherwise worthwhile, Technology and Software, Writing

Posted at 09:39 PM | Permanent link

February 19, 2006

A Tribute to Steve Yegge

I don't know who Steve Yegge is, but he rocks.

And here I thought I was the only one in the world with a day job programming Java, an unhealthy obsession with Emacs, and secret affairs with Lisp, Scheme, Ruby, blogging, and Google on the side.

Observe:

and similar drunken blog rants.

I don't care how much of an idiot Stevey says he is; he's right up there with Paul Graham, Philip Greenspun, and Mark Pilgrim in my book. Those who know me know that's the highest compliment I can possibly pay a person.

Reading these guys for the first time stretches your mind. It makes it hurt a little - in a good way. It allows you to catch glimpses of things that were right in front of your nose that you didn't know were there. I can't really describe it other than to say, from what I've read about the Zen and Buddhism, this has to be what the enlightenment is like... at least a little bit... at least the awakening part. Ok, maybe not, but still.

'Welcome to my life. I'm the cow in the Gary Larsen comic1 -- the one who looks up, shocked, and says: "Hey, wait a minute! This is grass! We've been eating grass." The other cows stare blankly, munching the grass.'

-- Steve Yegge in The Emacs Problem

Quotes like that get me all kinda teary-eyed.

After years of pondering the Lisp and Emacs and Java and closures and SQL and XML and RSS and Atom and REST and continuations and Javascript and Objective-C and Cocoa and Perl and Python and Ruby and the Gang of Four and blogging and blog meetups and Peopleware problem I think I've finally gotten to the point where I can read a guy like Stevey, understand exactly where he's coming from on many issues and feel completely comfortable saying something like:

"See all that crap that guy over there is ranting about? Yeah... what he said. Right on, brotha."

Whereas before I would have simply said "Aha!" or "Holy hell, he's right!".

Of course, I'm still sa