ANTLR Is Not As Cool As I’d Hoped

September 11th, 2005

About 5 years ago while I was doing some part time work for my university one of my lecturers walked by, looked at the program I was developing and asked: "You're using antlr or something like it to generate your parser aren't you?".  I wasn't, I'd written the parser by hand in an hour or two and it worked exactly as I wanted so I saw no need to go back and rewrite it.

Since then every time I've wound up writing a parser I've thought, "I probably should use antlr for this" but then decided to just take 10 minutes and write it myself instead of introducing another dependency and having to muck around with the build system etc.  I've had to support these over multi-year periods without problems.

Finally today I hit a case where I needed to write a reasonably complex parser that was likely to see a lot of updates in it's life time.  So I went off and took the time to add antlr as a dependency and learn how to use it etc.  Now it's worth noting that I'd already written a perfectly working first iteration of this parser by hand in about an hour.

I now finally have an antlr parser working after about 1-2 hours of reading up on ANTLR and about 3 hours of actually working on tweaking the grammar.  It's very brittle (otherwise known as strict) which in this case is a major problem so I've had to add in Java code to perform recovery when unexpected input arises. I'm now much more concerned that I'll wind up with an unmaintainable mess than I was with my hand written parser.

The worst part of it is that more people would be able to understand and work with the hand written, plain Java parser than could understand the antlr grammar files.  Not to mention the fact that the generated source code (2 files, a lexer and a parser) generate 27 warnings in eclipse - so much for a nice clean warning free code base.

It's great that things like antlr are available for when you have a very clearly defined grammar (particularly for large or complex grammars) and you want the strict checking it provides but I'm not sure I'll feel so bad about writing my own parsers in future.

Why Microsoft Gets A Hard Time

September 11th, 2005

Brian McCallister gives a brief synopsis of Microsoft's 2005 financial statement. I think it pretty clearly shows why people dislike Microsoft:

Regarding Windows sales and profits:

Well, we see a pretty nice top line revenue of $12.2 billion. The fun part of that is that the operating income (profit before taxes and interest) is a tidy $9.4 billion. It is awfully nice to pull a 77% operating margin (profit before taxes, hereafter referred to as "profit").

Regarding Office sales and profits:

This one has slightly slimmer profit margins, only 71.8% profit on $11 billion revenue.

See that's called price gouging.  

It is of course nice to look at the non-monopoly business divisions as well. MSN is squeaking out a pretty respectable (20%) profit, with $2.2 billion in revenue and $405 million in profit. Servers have a very respectable margin as well, about 33% on $9.9 billion revenue. Both are very nice from a profit perspective

It would be interesting to see what other company's profit margins on software are, but I suspect they would be closer to the 20% or 33% from the non-monopoly products than the 70-80% of the monopoly products.  Of course, Microsoft isn't the only ones pulling this kind of stunt - I'd be surprised to find that Apple wasn't making a very large profit margin on off-the-shelf copies of OS X either, however Microsoft is making 80% of it's Windows profit from the discounted prices given to OEMs.  Yikes!

Somehow though I don't think we'll see Microsoft giving its customers a price cut any time soon though. Then again, I probably wouldn't if I were them either.