Skip to main content


Showing posts from January, 2008

Haskell: Well-typed Programs Can't be Blamed

Last Wednesday, I went to a Bay Area Functional Programmers talk to see Philip Wadler give a talk on his paper Well-typed Programs Can't be Blamed . Wadler was a good speaker. He was very friendly and interactive. He insisted on having people ask lots of questions. He called himself an "absent minded professor". Two things I didn't know about him were that he worked at Bell Labs and he also worked at Sun on Generic Java. Having tried to cram technical papers into my head way too late at night, I was pleased to find out that he's pretty easy to understand in person. However, his slides weren't always bug free. There were a couple of errors in the equations. Apparently, academic papers can have bugs too ;) The goal of the paper was to to mix typed and untyped modules in the same program. He admitted that untyped code lets you do fun and flexible things. His goal was to "coerce" a dynamic function to a typed function dynamically. This was

Computer Science: Everyone Wants to Write a Web Framework

I had my stint. I started a Python Web application framework called Aquarium seven years ago. It's now being used by IronPort all over the world. It's even been used in a couple apps at Yahoo. In the Python Web world, we have about 1.5 times as many frameworks as we have programmers. I've heard people joke that you can't be a serious Python programmer until you've written your own templating engine in Python ;) Ruby became mainstream, not thanks to its cool metaprogramming, but rather because DHH decided to write an app in it. Oh, and he also wrote some obscure Web framework that no one knows about ;) One of the most "vocal" blogs supporting Erlang is Yariv's Blog. Erlang is wicked cool, so what does he do with it? He wrote a Web framework called ErlyWeb . My buddy Alex Jacobson is a fascinating character. He's been coding in Haskell for almost as long as I've been coding in total. What's his project? HApps . It's label

Python: Oh How Long I've Known Thee

I have a buddy who was doing some Python programming with Oracle today. He has asked me a question, and after I thought about it, I said, "Hey, that sounds familiar. I think I have some code for that." I knew it was in my open source project, Aquarium , but I also knew it wasn't in newer releases. I eventually found the code and gave it to him. Here's the punchline: It was from 2001! Yes, I've been coding Python that long. In case you're wondering what it was, the Oracle driver doesn't have code to fetch rows as dicts, so that's what I was giving him. Here's what it looks like: def fetchonedict(self, cursor, force=1): """Fetch one row as a dict. If force is 1 and there are no more rows, I'll throw an EXPECTED_RECORD_NOT_FOUND exception. Otherwise (if force is 0 and there are no more rows), I'll simply return None. Note, database modules don't *have* to use this

Vim: Gimme More Magic

I spent an hour reading about TextMate to get a feel for what I'm missing since I know it's so popular. I'm sure it's a lovely editor, but I have such an emotional attachment to Vim, Linux, free software, etc. Anyway, I'm sure you're tired of hearing me talk about that ;) Anyway, I tried out the snippetsEmu plugin. It's a plugin that provides TextMate style snippets. Once you have it installed, you can edit a Python file, type "def<tab>" and it'll start doing interesting things. I can see the appeal of snippetsEmu for more verbose languages. It knows how to type "public static void main" ;) However, it's hard to get excited about it in Python. Python has such low syntactic overhead that it's faster for me to just type things out, especially considering I'm a touch typist. It'd probably make more sense in Ruby, where you have to type "end" all the time. Nonetheless, I'm happy to have some

Python: Django: SQL Queries in the Templates

I think Django is a great framework for Python Web newbies. Those guys have done a great job providing a cohesive framework that's easy to get started with. However, one thing that has always bothered me is the templating system. I was reading a bit of someone else's Django code, and I came across this in a template: <div> <div>Services:</div> <ul> {% for service in %} <li>{{ }}</li> {% endfor %} </ul> </div> There are two problems. First of all, "" is not being HTML escaped. That means you have to worry about XSS vulnerabilities. Thankfully, I no longer need to worry so much about things like that because Genshi can auto-escape things smartly. However, there's a much graver problem. "" is really a SQL query. Django tries really hard to provide a restricted templating environment because it assumes templat