Wednesday, March 30, 2005

FeedBurner

Jesse Montrose asked me to submit my blog to FeedBurner, which I have done http://feeds.feedburner.com/JJinuxLand.

Tuesday, March 29, 2005

Python: PyCon 2005 random thoughts

Some people have asked me to provide some comments on PyCon 2005. Here is an informal collection of impressions and opinions. I won't cover the Web topics because I've already done that.

Alex Martelli's talks are a joy. I especially liked his talk on 'Descriptors, Decorators, Metaclasses: Python's "Black Magic"'. I just wish he had more time. 25 minutes is simply not enough time to understand the subjects he is trying to convey unless you already understand them.

PyPy is definitely not what I thought it was. Apparently, it's about type inference. I thought it was an attempt to rewrite the front-end of the Python interpreter in Python so that the front-end could be shared among all the versions of Python. If this were the cases, the front-end could be distributed as .pyc's, and all the versions of Python would only need to write VM's to interpret the .pyc's. :-/

wxPython is a pain to use. PythonCard is a wrapper around wxPython that makes it a joy to use. PythonCard is obviously not as mature as a lot of widget toolkits, as I can see obvious deficiencies (e.g. more sophisticated layout strategies). However, it is quite impressive.

Schevo is interesting. It's a GUI for object databases.

"Dabo, the 3-tier Database Application Framework" is a database-neutral, GUI-neutral RDBMS GUI. The author complained about wxPython a lot. The author mentioned that 80% of his effort was spent working around wxPython. I asked why he didn't use PythonCard. He said he wanted to remain GUI neutral. The whole thing looked like a bit of a waste of time :-/

Durus is a trimmed down version of Zope's object database. Having seen Schevo, I can see that object databases can make a certain set of database problems a bit simpler to solve.

Soap box warning:
However, I just don't see why people have to spend so much time trying to solve problems that were already solved in the 70's. Why does everyone hate SQL? I think SQL's the best thing to happen to computer science in the last 30 years! Here are things that RDBMS's do that object databases have a hard time with (although some do succeed with some of these points):
  • Cluster.
  • Atomic transactions that work even if the power chord is pulled at an inopportune moment.
  • Query extremely large data sets without transmitting all of the data to the client. Furthermore, the RDBMS can execute the query one hard drive block at a time without trying to bring the whole table into memory.
  • View the data in ways it wasn't meant to be viewed, i.e. do joins on arbitrary fields.
Concerning iterators and generators, I took away these two points:
  1. Anytime the loop logic gets complicated, write a generator so that the loop logic can be reused.
  2. Use the itertools module. It's blazingly fast and convenient.
"Sequential Code in an Event-Driven World" was basically "generators are cool."

"Python for Series 60" was impressive. I want one, but Sprint doesn't have them. Bang for buck, it's hard to beat Symbian phones.

Web: The Brian Problem

Thinking back to the early days of Aquarium, Chuck Esterbrook and I thought about merging Aquarium and Webware. Unfortunately, I'm a bit of a code nazi, and Webware isn't the most minimal, style-conforming code around (which multiple people have confirmed, so it's not just me). This dissuaded me from joining forces. The fact that I was out of the Web world for about two years gave Webware a big leg up :-/

Moving forward, I'd like:
  • To work hard on newbie documentation for the PyWebOff's concept of "Brian" (i.e. a Python newbie who knows PHP and is now trying to write Web applications in Python).

  • To revive Piranha for all the "Ruby on Rails" folk. SQLObject and the Subway project may make some or all of this work unnecessary.

  • To better integrate with SQLObject and FormEncode.

  • To write a WebServerAdaptor for Twisted. At IronPort, we use coroutines. I work with Sam Rushing, the author of Medusa. Since coroutines are strictly better than Twisted (same benefits, but easier to code), if I can't support Twisted, I'm going to push harder for IronPort to open source its coroutines library and its version of stackless Python. This will be great since Aquarium's Web server, Glass, can already run in a coroutine environment.
There are many Web frameworks out there. Although reducing code duplication among them is a laudable goal (e.g. WSGI), I think having common things like Cheetah, SQLObject, FormEncode, etc. are great places to reuse code. However, having many Web frameworks reuse code doesn't really help "Brian". What we need for "Brian" is:
  • Great beginner documentation.

  • A larger community who agree on how Web applications should be developed.

  • Mind share.
I think unifying the best parts and people from the Aquarium, Webware, CherryPy, Quixote, Subway, and Twisted community would be a great way to achieve this goal. Hence, I am approaching the "Brian" problem as a political one. The code is already there.

Web: PyCon 2005

I just finished attending PyCon. Specifically concerning the Web, I'd like to direct your attention to:

http://pyre.third-bit.com/pyweb/index.html
Basically, there are too damned many Web application frameworks, and they all assume you know what you're doing. The PyWebOff is an attempt to figure out which is best from a newbie's perspective. Hopefully the talk will be available in video format later. I just finished reading the blog. She said, "Please, whatever you do, don't try to solve the problem by writing another Web application framework!!!"

http://www.python.org/peps/pep-0333.html
Ian Bicking gave a talk on this. It's an attempt at consolidating some underlying Web application API's. Basically, it's an attempt at making up for lack of a servlet API. It's great in that Web application framework authors may be able to share some code, but it still doesn't address the fact that there are too many choices for the user. Furthermore, it does nothing for the API's exposed to the user himself. These aren't changing, it's the underlying API's that are changing. The API exposed to the user has to remain pretty much the same or else existing code will break :-/

http://www.python.org/pycon/2005/papers/75/LivePage.pdf
Donovan Preston, the author of Nevow, did a talk on writing dynamic Web applications. About the coolest thing is that he transparently transmits selected JavaScript events to the server so that he can write the callbacks in Python. From Python, he can do things like "client.myDiv.innerHTML = 'foo'". Furthermore, he uses an iframe that is always waiting for a response from the server. In this way, he can have the server "push" data to the client at anytime. I'm a bit bummed because I thought of almost all of these things before I had heard of him doing it, but he beat me to the punch in writing a proposal for PyCon. Nonetheless, it's always a pleasure talking to him.

http://sqlobject.org
I just ran into this. It's from Ian Bicking.

http://www.python.org/moin/Aquarium
I didn't write this, but I'm definitely impressed with how well the author summarized Aquarium. I've talked to him via email, and he sounds like a great guy. In fact, he suggested SQLObject would be a good combination with Aquarium, which is news to me ;)

I'm a little bummed about the whole WSGI thing since so much of it is really a duplication of the API's that Aquarium sought to lay down. Porting Aquarium to WSGI is like making an adaptor for an adaptor :-/ Nonetheless, I will probably make an Aquarium WebServerAdaptor to support WSGI's API.

I'm also a bit bummed about the "Ruby on Rails" thing, since Aquarium had the same functionality in a subproject called Piranha about three years ago (both automatic retrieval of data from an RDBMS and automatic code generation for a GUI to work with that data). The essential difference wasn't features, but it was accessibility for newbies, and it didn't help that I "left the Web" for about two years to work on the IPv6 project. In the future, I'm hoping to direct more of my attention to the newbies.

Python: Create a new class on the fly

At PyCon, Alex Martelli mentioned that you could create a class on the fly using the type function. Previously, I probably would have used the exec function. I feel like such a dork:
>>> class Template(object): # Must be a new-style class.
... def bark(self):
... print "woof"
...
>>> Page = type("Page", (Template,), {})
>>> Page().bark()
woof
>>>
>>> def meow(self):
... print `self`
... print "meow"
...
>>> Page.meow = meow
>>>
>>> Page().meow()
<__main__.page>
meow

Welcome to JJinuxLand

Karl Guertin told me, "He who blogs gets his opinion heard." Hence, inspired by the blogs of Anthony Eden, Leon Atkinson, and Ian Bicking, I have created my own. This is a purely technical blog concerning topics such as Python, Linux, FreeBSD, open source software, the Web, and lesser-known programming languages. In the interest of everyone's time, including my own, I hope to keep the volume low, and the technical content high.

Please excuse the fact that I did not write my own blog software. It isn't that I am unable to. It's simply that I hate reinventing the wheel when exceedingly round ones already exist. I chose blogger.com specifically on the recommendation of Krishna Srinivasan, Tung Wai Yip, Anthony Eden, and Google.

I look forward to your comments.