Archive for March, 2008

Mar 31 2008

My TweetSpeak Update

For those of you who are on Twitter, you might appreciate TweetSpeak. It makes Twitter a bit more like office banter by speaking it in the background. Here are some updates I made to it — basically, I added some error handling to deal with having too many client requests, put a few more substitutions in so that Alex figured out how to translate Twitterese like “kthxbye” and “crrrrrraaaaaaaaaaaaaaaxzy”, and generally cleaned up Twitterisms in the feed.

Continue Reading »

Popularity: 5% [?]

5 responses so far

Mar 30 2008

But what is it good for?

Published by Brian under Navel Gazing and Miscellany

One of the things I don’t think I did well in my post on A Mathematician’s Lament is to properly state that I disagree with Paul Lockhart that Mathematics is inherently useless, but I understand why he takes that position. Mathematics is one of the most useful tools that mankind has ever invented. But to make that statement to someone who doesn’t know mathematics (such as, for example, a grade student), will be met with the question “But what is it good for?”

Note that this question gets raised about computer science as well- take, for example, some of the responses I’ve gotten from this post. So I’d like to tackle this question head on, and hopefully provide my answer to this eternal question.

Continue Reading »

Popularity: 5% [?]

No responses yet

Mar 29 2008

Working on Rebuilding the Dialog

My blog posting has taken a bit of a break, because I’ve been working on a couple of projects and filling out an application for the Ocaml Summer Project based on CloudProxy and a couple of excellent programming students I know. Hopefully that works out: not to oversell it, but the project would be awesome for the world.

As for my blogging: after some soul-searching prompted by insightful comments, I’ve decided that my last post on Ruby came a bit too close to violating my own rule #1. It has also left people with the impression that I just hate Ruby and Rails and metaprogramming, which just isn’t true (as I’ve said).

So, I’m pulling together a post right now to try to rebuild some dialog. Specifically, I’m going to be comparing some of the most popular aspects of Ruby/Groovy/Perl’s dynamic typing, and what their analogs look like in Ocaml. If you’ve got a request, let me know.

Popularity: 2% [?]

No responses yet

Mar 24 2008

My Frustrations with REXML: Ruby’s Standard Library for Reading/Writing XML; or, Ruby’s Problem Is Its Type System, and Don’t Try to Tell Me Otherwise

Edit: Once you get the gist of this rant, jump to the comments for a slightly more reasoned approach. Or my follow-up post which attempts to re-open the dialog.


So, I’m trying to do a little bit of XML reading/writing. Nothing major — read in an XML, grab out some values, and then store the raw XML into the database. I’m doing pretty much the same thing in Groovy, and the XmlSlurper made that blissfully easy.

Since the core library comes with the REXML parser, I figured that it was a nice, stable library, and I’d roll with it. The interface wasn’t as nice as XmlSlurper, but it seems like it would do.

This was the start of the pain.

In fact, the pain pissed me off enough to share my frustrations with the world. Hopefully someone finds this useful, and they can avoid the pain and suffering I put up with. And yes, I could spend the time I’m griping going through and fixing up all the bugs, but I shouldn’t have to for a language as mature as Ruby. Core libraries are supposed to be stable, reliable beasties. If I wanted to spend all my time debugging half-baked implementations or rolling my own solutions, I’d never leave Ocaml — I come to Ruby for the community support. That’s supposed to be the big advantage.

Anyway, here we go:

Problem #1 came along when I tried to parse XML. First of all, the API documentation completely sucks — if you look at the top level REXML package, it’s totally worthless. If you manage to figure out that it’s REXML::Document that you probably want, you’re still not much better off. If you check out #new, which is really what you probably want, you’re rewarded with one word: “Constructor” You also have some “@param” tags that ran together and tell you things like the second argument, called “context”, should be a Hash of the context. That clears up a lot! And, seriously, if you’re telling me that it should be a Hash in the documentation, why aren’t we just doing implied static typing and being done with it?

Anyway, I retreated to Google, found the REXML tutorial, and managed to figure it out from there.

But then I kept having this annoying bug: when I called Element#text(), it was not only ignoring my instructions to leave entities alone (i.e. don’t turn “&lt;” into “<”), but it then seemed to go through and attempt to re-parse it, because it was complaining about unbalanced tags! Principle of Least Surprise my ass(1)! I’m not sure why the second part of that was happening, but the first part is apparently documented, so I stopped using the easy-to-read convenience method and went to Element#write.

This is where the real pain began. See, Element#write is broken. Deprecated and broken, actually. But the tutorial still tells you to use it. The solution is to use their Formatter approach. Except — ready for it? — that’s broken, too! No, I’m not kidding. In this language core library, both versions are broke! The solution is for me to reach in and make a change to the core library so that we avoid a null. In the standard Ruby deployment, using the standard core XML processing library, there is no way to write out XML. It is impossible because of bugs in the library.

The worst part?

THAT STUPID BUG IN THEIR CORE LIBRARY WOULD HAVE BEEN FIXED WITH STATIC TYPING. Even more if you have a type system which can check nulls for you. Null pointers/”nil when you didn’t expect it!” errors are totally solvable problems. The fact that our industry hasn’t moved past this painful left-over from C is driving me crazy. The next person who tries to tell me that dynamic typing is the best thing since sliced bread is going to get an earful. It is a flat-out wrong position, and I’m done hearing otherwise from anyone.

(1) As much as I’d love to claim that quote, it actually comes from Paul Cantrell’s excellent exploration of closures in Ruby.

Popularity: 20% [?]

19 responses so far

Mar 24 2008

“The Big Bang Theory”

There is a woefully underappreciated show on TV right now: “The Big Bang Theory”. The most recent episode — “The Cooper-Hofstadler Polarization” — was awesome. You can watch it right now at: CBS’s website.

The show started out really rough, but with a charming cast. In the most recent few episodes, it’s really hit its stride.

Get it while it’s hot, because it’s the kind of show that’s just not going to last long.

Popularity: 3% [?]

2 responses so far

Next »

Green Web Hosting! This site hosted by DreamHost.