Tuesday, May 30, 2006

Geek post: subpixel decimation and filtering on Linux

Of the three platforms I use on a daily basis (Linux on my office PC, OSX on my trusty if slowish Powerbook, and WinXP on my wife's laptop) I think I like WinXP's Cleartype fonts best. Actually, OSX's rendering is not "worse" than XP's---it's just different. Hinting seems to be lighter, and the emphasis is on getting font shapes right, rather than maximizing crispness. This is probably a good thing if you are a graphics / desktop publishing person trying to get a feel for how your document will look on paper. But, in terms of crispness, XP wins.

Unfortunately, Linux font rendering used to fall quite a bit behind both. Until last week. David Turner (of Freetype fame) released a set of patches to Xft2 and Cairo that (finally!) implement decent filtering of subpixel-rendered fonts. You are much better off getting the details from the source, but the results are really quite impressive. I upgraded from Ubuntu Breezy to Dapper last week, and today I installed the .deb's that a very kind soul has made available. Really, really sweet!

Friday, May 05, 2006

Linux in the wild

Just a quick note. I have now been to two theory talks this quarter where the speakers used Linux-powered laptops for their presentation. The first was David Levine (who, incidentally, has very interesting and provocative thoughts on patents and IP in general: check out his web site). The second was my colleague Jeff Ely, who is a founding member (and major force behind) the first open-access journal in Economic Theory, aptly named Theoretical Economics.

I am not an empirical economist, so I don't know if this qualifies as a trend :-)

Monday, May 01, 2006

Java and C# for cross-platform development

Well, I haven't posted in a long, long time, so let me jot down a few quick thoughts to liven up this blog.

In my work, I have to deal with three platforms: Linux (I run Ubuntu Breezy on my office PC), Mac OSX (on my laptop) and Windows XP (my coauthors are all running standard-issue Dell PC's with standard-issue OS's).

Collaborative writing has long been a non-issue: LaTeX is wonderfully cross-platform, and even though one of my past co-authors insisted on using Scientific Word (which produces appalling LaTeX code), I have had no problems making things work smoothly enough.

However, one of my current projects involves running numerical simulations. I am the one doing most of the coding, but I'd like my coauthor to be able to run the simulations, experiment with different parameters, etc. So, it is essential for me to write code in a cross-platform environment. Since execution speed is important, too (although not crucial at this stage), Java and C#/.NET seem to be reasonable alternatives.

I must admit I have a fair bit of bias against Microsoft "solutions". However, I am willing to consider C#, partly because it does have a few nice features that Java still lacks, and partly because it is straightforward for my Windows-based coauthor to install and use the .NET framework. Also, the Mono projects supposedly provides a cross-platform implementation of .NET (there is also another effort, Portable.NET, which also aims at porting the "dotnet" stuff to non-Windows platforms).

However, it turns out that the Mono OSX port is quite a bit behind its Linux counterpart. In particular, Windows Forms is basically non-functional on the Mac, and Gtk# requires installing a bunch of extra stuff from Fink, and requires X11. Now, the Gtk# issues are not too serious per se; however, as an added complication, if I do decide to go the Gtk# route, I would have to ask my coauthor to install the required DLL's and assemblies, whereas Windows Forms is part of the .NET Framework and so works "out of the box".

On the other hand, Java is truly, 100% cross-platform (for my purposes at least). I am not enough of an expert to comment on the finer points of language design, but I must say that I like languages that adopt one particular "metaphor" and stick to it --- it makes things predictable and consistent. In Java, everything is a class, including events and event handlers. There is a certain elegance to it. On the other hand, C# introduces "ad-hoc" constructs (events and delegates) that may save some typing but, at least in this writer's opinion, remain... well, adhockeries. There, I've said it!

Bottom line: for the time being, I'm sticking with Java. But I'm keeping my eyes open.

Monday, April 03, 2006

Paul Graham on software patents

Check this out. In my opinion, it's a very thoughtful piece, even if you disagree with the conclusion Paul reaches (see below).

In particular, I find this part of the analysis very compelling:

One thing I do feel pretty certain of is that if you're against software patents, you're against patents in general. Gradually our machines consist more and more of software. Things that used to be done with levers and cams and gears are now done with loops and trees and closures. There's nothing special about physical embodiments of control systems that should make them patentable, and the software equivalent not.
To put it differently, the same economics apply to "software" and "hardware" patents. In both cases, there is a cost to society because a monopoly is (temporarily) established; however, this distortion may be compensated by the additional innovation spurred by the promise of monopoly profits.

Figuring out the costs and benefits involved is hard. Paul Graham notes that perhaps patent examiners are not yet fully equipped to do so in a consistent and "reasonable" way. As a result, the system is open to manipulation by clever patent attorneys and patent trolls. This is clearly undesirable.

On the other hand, I am not sure abolishing software patents is the right way to resolve the cost-benefit tradeoff. For one thing, a law prohibiting such patents would be hard to enforce in practice, for reasons related to Paul's comments cited above. A silly example: suppose I design an e-commerce application that renders ultra-high-res, 3D pictures of items available for sale---but requires that the user install a fancy, custom-designed graphics card. Strictly speaking, my e-commerce application requires specific hardware, so it is not "software-only". Should it be patentable? It is also clear that there is a slippery-slope problem: how about copy-protected software that requires a USB dongle to run?

But, even abstracting from these "implementation" issues, the key question in my mind has to do with the provision of incentives to innovate. I really don't know the answer to this. It is certainly true that if Firm B can duplicate Firm A's innovation at little or no cost, then Firm B has diminished incentives to innovate in the first place. But duplicating all the functionality of a sophisticated piece of software like, say, Microsoft Word, or iTunes (even sans music store/iPod) is not trivial. So, perhaps, the very complexity of the product in question provides a sufficient, if temporary, barrier to the entry of competitors---even in the absence of patents.

Well, I'll post what I have and come back to this topic at a later date...

Friday, March 24, 2006

Free software for economists

Now that I have a blog (zero comments still...), I thought it'd be nice to get a Googlepage. So I did, and to get things started, I compiled a list of free and open source software for economists, with links to the relevant Web pages, and comments on each package based on my own direct experience.

Actually, this list should be useful to anybody who has to deal with math on a daily basis; this includes, well, mathematicians, statisticians, physicists, etc. However, my sense is that these folks are way ahead of us economists when it comes to using powerful, featureful free software. And there's no reason why they should be having all the fun!

The current list is not meant to be exhaustive. If you know and use a package that is not listed, please let me know by dropping a comment here. In general, constructive criticism is much appreciated. Thanks!

Wednesday, March 22, 2006

Ruby noob

Caution: this is a computer-related posting, so skip it if you are not interested. It's a neat trick I learned a while ago, and it's served me well. I'm sure it can be improved in many ways, but at least it has helped me learn a bit of Ruby.

Problem: I usually keep my office PC and my Mac laptop synchronized using rsync. I do something like

rsync -e ssh -auvz <office>:<dir> <dir>

when the most recent changes are on the office PC, and

rsync -e ssh -auvz --exclude=".DS_Store" <dir> <office>:<dir>

when I finish working on the laptop and want to sync up everything ot my office PC. The additional "exclude" is necessary to avoid copying files created by the OSX Finder in practically every directory, and for which Linux obviously has no use.

Anyway, the other day I forgot this "exclude" thingy, and as a result my office PC was littered with .DS_Store files all over my working directories. How to get rid of them (short of hunting them down manually)?

I knew about Python's os.walk, but could something like that be done in Ruby, which for some reason I find more compatible with my way of thinking? YES! Here goes:

require 'find'
require 'FileUtils'

Find.find("top_level_working_directory") do |path|
FileUtils.rm(path, :verbose => true) if path[-9..-1]==".DS_Store"
end


This thing recurses through all subdirectories, starting with top_level_working_directory and passes each file to the block, which then performs the required deletion if the (full) path matches the loathed pattern.

I am sure there are other ways, including turning this into a one-liner (I still launched irb and did things by trial and error), but this Worked for Me (TM).

Welcome!

So I thought about it for a long time, and finally decided to take the plunge: I'll start my own blog. Wouldn't it be nice if I could quickly post a thought or two about my current job-related obsession? About my long-running love affair with computers and technology? About politics and current events... no, maybe not that.

There is, of course, the pretension that somebody will actually read this stuff. That would be great! I guess I should let Mom and Dad know about it... A famous Italian novelist used to joke about his "twentyfive readers". In my case, this would be a wild exaggeration; a couple of readers would be nice though... Bottom line: if you stumble upon this blog, feel free to peruse the Comments section.

Also, quite a few famous economists (more! and more!) have been writing successful blogs. Again, I don't dare hope to have even a fraction of their readership. After all, I may be an economist, but I'm certainly not famous, by any stretch of the imagination. I do hope though that, should an economist happen to drop by, he or she won't feel like this blog is the sort of thing that gives economics a bad name...

In short, I apologize in advance to any and all. I'll try to keep my posts short; I'd like to promise they will be frequent and entertaining, but I don't know yet whether I'll have the required energy and motivation. This is very much an experiment, so please be patient.

Thank you for tuning in, and see you soon!