Archive for June, 2008

h1

KISS (Keep It Simple, Super)

June 28, 2008

Remember this?

I start cussing every time I come across that post :)

Not to say it’s not a great post, going to the trouble of writing all that down in such a lucid, careful manner was positively a service to the rest of us. Thanks, Foom.

It’s just that, the whole thing with super is so broken. Which brings to mind a conversation over sushi, about Python:

Friend: “Oh, that scripting language. Yeah I remember that, man that’s got such a broken object model.”

Me: (Squirms)

There wasn’t really much to say, was there? Super, new-style classes vs. old-style classes, can’t raise new-style objects, yada yada yada? Aieh…

End rant. What really I wanted to do here is write down the condensed version of Fuhm’s post, as a series of simple rules I can go back to. Here goes -

  1. Don’t mix regular classes with exception classes
  2. All regular classes should be new-style, derived from object
  3. They should have the constructor signature __init__(self, **kwargs)
  4. Every such __init__ invokes super(ClassName, self).__init__(**kwargs)
  5. Never extend a new-style class that doesn’t follow these rules
  6. Don’t use multiple inheritance for exceptions
The point is that if you follow these rules then Python’s super behaves pretty much like Dylan’s next-method, and then Fuhm’s objections are moot, as long as you stick with the rules…
And there is not really any reason to bother with this unless you want to be prepared for multiple inheritance. Even if you are doing multiple inheritance you might prefer simple, stateless mix-ins – at least I do – in which case you don’t need an __init__ (there is no state) and life is somewhat easier (although, according to Fuhm you still need the placeholder __init__ with a direct super call to object.__init__).
Now, I wonder if Python3000 really fixes this?
h1

Google App Engine Languages?

June 28, 2008

I was idly browsing through the abbreviated digest for the Google App Engine group when I came across a post with a subject that seemed mildly offensive to me: 

Please don’t add support for other languages

I’ve been thinking a lot about localization, and as a result I completely misunderstood. I thought this was some kind of petition to stick with English only. (Yes, that wouldn’t make any sense would it?)

So, I was actually getting a little hot under the collar, you know, like this… 

Duty Calls

(xkcd is great isn’t it?)

But, thankfully, I had completely misunderstood. What was really going on was a little cheer-fest for a blog post by Jonathan Feinberg at IBM, encouraging Google to just stick with Python for the Google App Engine libraries for now, and get those really “right” rather than put resources into translating the libraries into PHP, Java, and all those other things

I just figured I’d add my three cheers to Jonathan’s post… how about it Google, let’s get a really functional stack first and more languages second?