21 May 2007

Amazingly bad APIs?

There are some amazingly bad APIs in Java, so Paul Buchheit says. The best API is system(), or backticks.

The end result is basically an ImageMagick conversion (kudos to a useful incantation for the less than sign):

mogrify -geometry "220x133>" -antialias -quality 90 /tmp/c.jpg /tmp/c-thumb.jpg

You wouldn't write an encyclopedia in limericks (though it's been done before), so there's no need to use a general purpose programming language to manipulate images. Small Pieces Loosely Joined is pretty popular for Unix, CGI/REST, Erlang, Messenger RNA, etc.

2 comments:

apatheticagnostic said...

Sure, but then you're not writing os-independent code, and arguably any general purpose language should provide such things nowadays.

I only bring up the os-independent thing because it's java.

Leo Meyerovich said...

It's not so much about the APIs as about the glue. The theory of pipes (hah!), is that programs are written to do basic things well, and That's It. ImageMagick is made to take an image, transform it, and give you the result. Doing it iteratively - yielding movies, complex filters, whatever - falls out as well. We don't care whether ImageMagick to be extensible. As long as it does its basic task, as does everything else, we can glue our result together.

The combination of C and the shell is powerful. I'd argue that it is for general purposes, except that the general purposefulness parameterize your shell language.

For apatheticagnostic... no reason not to endorse such a style within Java. /tmp/ is still questionable, but so goes.