Monday, June 13, 2005

Thinking in Twisted

I've been emailing with a fellow developer and friend about learning to write applications and parts of applications using the Twisted networking framework. Even though Twisted is written in Python, conceptually -- and from an abstract point of view -- it is like a language of its own, with a foundation, syntax, and grammar that is Python.

My friend was trying to make use of basic Twisted stuff like deferreds, combine that with other parts of Twisted, but traverse the problem-solving process from an essentially ground-up, Python approach. I had tried to provide the shift in perspective needed in order to write Twisted apps with much less effort than he was exerting, but I fear that I failed.

Then, this morning, I thought of the perfect analogy. Actually, it's more than an ananlog -- it is the thing itself. Since really starting to learn Twisted, my programming has changed. Well, that and since absorbing such books as Patterns of Enterprise Application Architecture and Refactoring to Patterns. The deal with writing applications in Twisted is that you're no longer programming in the same language (Python); you're learning a new language. A more abstract one.

When we learn to think in Twisted and write applications in Twisted, our solutions will be elegant and compact. Before that starts to happen, we try to use our "old" ways of Python programming mixed in with the new one we are learning... and that, of course, defeats the purpose of the new "language."

The tricky thing about Twisted is that its patterns are an integral part of its "language" (perhaps it would be better to stop using quotes, and just call it a meta-language...). This is not true of most other languages -- though I would venture to say it is true of good frameworks in general. You don't need to know the patterns to use the grammar/syntax/control structures of most languages. Patterns in a language are usually optional.

With Twisted, if you aren't using the patterns, you aren't really using Twisted.

I am midway through this learning process. Therefore, I can't point to the solutions for many Twisted problems immediately or directly. I have, however, learned to see most of the critical components of a Twisted implementation. I still miss a few, though, and I have to keep reviewing code until I catch them all. Seeing these components clearly is what leads to the solution. As the time between "component vision" and "solution" gets shorter and shorter, we come closer and closer to thinking in Twisted.


Saturday, June 11, 2005

pymon Nearing 0.3.3 Release

software



pymon is nearing its second public release (but first packaged
release). We've spent the past couple months doing a refactor by
examining the patters we were using or not using. In the process, we
have made MUCH better use of twisted's internals and are increasingly
more impressed with it as a networking application development
framework. To be honest, I would be very happy doing full-time twisted
development now.


Email alerts are turned on; ping hosts are running; HTTP status, HTTP
text checks, DNS dig checks, and MySQL admin queries are currently
being developed. We're going to try to knock out FTP and SMTP in the
next couple weeks, as well -- and then we'll bundle it up and release
it :-)

A tentative road map is up on the wiki, and we've got the beginnings of
developer docs on how to write "monitors" (like ping checks, HTTP
status checks, etc.).


http://pymon.sf.net


Friday, April 08, 2005

Vacation

leisure :: nature



So, even though it's been a week, I still haven't blogged about my
mini-vacation. I didn't go anywhere and I still had to do a little
work, but I did get to relax and hang out with a really good friend who
was visiting from out of town. She had her Spring break from
acupuncture school, and for the second half she came out to Colorado to
chill in the Rockies. We had the absolute best time; a much needed
vacation for both of us.


I swear, I will never get tired of the Rocky Mountains. The most
amazing vistas, trails, weather, etc. Just incredible. We went
horseback riding through a place in Estes Park, CO that does rides 365
days a year. It was such a blast. We were out in the afternoon sun on a
gorgeous day for over two hours. The best views I have seen since I've
been here (with the possible exception of a couple amazing sights inside
Rocky Mountain National Park).

For most of the trip, we vegged, watched movies, went window shopping
in Boulder, listened to music and talked. A genuine vacation. Not one
of those "run around and do all you can do till you pass out and need
another vacation" vacations. Rather, a time to really relax and
breathe. Also, her last night here, I introduced her to my Tibetan
friends at the weekly momo-making party. She had the absolute best
time. All of us laughed, ate, drank, and laughed some more. In fact, we
laughed so hard we were actually in pain. She got to listen to lots of
Tibetan and build up her ear for it. I taught her a little and
translated a little, but my understanding is so limited that it's not
much use. On the ride back to Loveland, we chatted away like a couple
prairie dogs about the Tibetan culture, their deep understanding of and
commitment to community, about how this impacts our own experiences,
understanding, and limitations, etc. It was an awesome time :-)


Thursday, April 07, 2005

Accounting

accounting :: software :: society



So, I'm preparing for taxes (after my extension, of course). I've been
using this open source software called SQL-Ledger (written in perl,
unfortunately) to do my books this year; it's a double entry accounting
package. It's ugly as hell (I've made improvements -- css and python),
but I love it. I emailed my accountant with some double entry questions
(checking to see if the lights really are dawning), and I decided to do
some checking on the internet, where I found this gem I thought I'd
share ;-)


This is the first thing I've ever read that has made me not only feel
good about accounting, but want to participate in the process :-)
We'll, the second thing, actually. The first thing was starting to use
SQL-Ledger to it's capacity.

It's kinda fun:


3.1 The history of double entry accounting

People had been tracking money (to pay bills, collect taxes) for
thousands of years, but it wasn't till the 1400's that the Italians
invented double entry accounting. This made banking reliable, enhanced
trade and commerce and very quickly Italy became the banking capital
and wealthiest country in Europe. It was the 1400's equivalent of the
invention of the internet and the dotcom boom. They had buckets of
money to spend. They spent it on paintings of Adam talking to God done
on black velvet. Well they would have but velvet hadn't been invented
yet. They made do with what they had, which was plaster ceilings. They
spent money on painters, sculptors and people like Leonardo da Vinci.

In grade school this period is called the Renaissance, a flowering of
art and intellect, that appeared in Italy for no obvious reason and
then spread to the rest of Europe.

Quite why all these geniuses suddenly appear without any warning is not
explained by your history teachers (who spend their life pondering deep
questions like this), but Jared Diamond (Guns, Germs and Steel, Pub:
Norton 1997) is happy to tell you. He says that geniuses like
Michealangelo and Einstein are rather commonplace. Most of them are
oppressed and are living in abject poverty, and are busy surviving if
they even do that. Give them a good feed, treat them well, put them in
the company of peers and pretty soon they'll be coming up with all
sorts of things you hadn't dreamed of.

The Renaissance then was a result of the invention of double entry
accounting, not (as we've been told) a flowering of intellect and art
that happened for no reason at all.

Reference:
http://www.austintek.com/gnucash/ncsa-
gnucash-talk-3.html


Wednesday, April 06, 2005

pymon

python :: programming :: software



As so often happens, when working/playing on one thing, the miraculous
inner lights of the frail but mysterious human mind shed their
brilliance on another. Okay, so perhaps in this instance the areas are
not so far separated, nor the lumens so brilliant as those in a dying
plastic camping flashlight. Nonetheless, the fancy is tickled, and
besides actual development, that's what matters!


So what the hell am I talking about? APIs. I was working on the PyKon
Nevow code the other day, and some things I had written and prototyped
fermented in a corner of my brain, and popped into a completely new
perspective today, one that I could use with
pymon. I am addicted to good APIs. I
study twisted's internals as well as that of Phillip Eby's PEAK
framework(s). I hunger for elegant, efficient, and clever design
strategies. It's very Newtonian of me, but I love well-ordered systems.
The discussions that have been underway on the pymon maillist boiled
down (very quickly) to the following:


    * The need for several mini-APIs to be used internally by pymon

    * The need to define user- and/or enternal-APIs

    * The need to get rid of a little cruft that had accumulated while in
    branch (both old an new)

    * The need to utilize twisted component-based approach (adaptors) to
    accomplish these goals

We're really excited about this, because we're trying to be true to the
art of programming. QualityRUs, not time-contraint, budget-driven,
happenstancery. I wrote some more about it on the 2005.04.06 news item
at http://pymon.sf.net. It's going to
be fun writing all the adaptors we will need :-)


PyKon

I got some more work done on PyKon last night after finishing a deadline for a client. I'm excited about having a modern, functional, python-based image gallery application. The first version will allow both:
  • manual image uploads (ftp/scp, i.e., changes you would make on the file system with a shell account) and the daemon that runs the web user interface will also regularly check for gallery/album/image changes and process added/changed files), as well as
  • through-the-web uploads.
For the second release, I want to enable some work we've been doing on an object registry. This would essentially make PyKon like iPhoto for Mac OS X: a global repository for images, and the capability to create albums with multiple overlapping images (duplicates) with no extra space taken up by the images (as they would only be references/links to the image tagged in repository).

We're hoping to make this better than IDS (written in perl), Gallery (in PHP), and JAlbum (in java). We really want this thing to kick ass and be very easy to use. We're a ways off, but progress so far is exciting.

Oh, and Nevow (for Twisted) rocks.


Saturday, March 26, 2005

Pete Yorn

music :: leisure



I am really behind the times. I discovered Pete Yorn only yesterday. I
was watching "Me, Myself, & Irene" with my mother last night. We were
both in a punchy mood, just having watched Bruce Campbell's "Alien
Invasion", so we laughed ourselves silly at Jim Carey's schizoid
antics. At some point in the movie near where they met Whitey, the
coolest song started playing. I've owned this movie since it came out,
and had never heard this song before. Well, it turned out it was the
song "Strange Condition" by Pete Yorn.


So I got a couple of his CDs, and holy crap -- this guy's good! He
reminds me of Elliot Smith, some classic REM, Counting Crows and a
little Grant Lee Buffalo. And sometimes you can hear a little Robert
Smith (The Cure). I feel like one of those dorks in "High Fidelity"
now... "She's kind of a
Sheryl-Crow-meets-a-post-Partridge-Family-pre-LA
Law-Susan-Day...only...black."


Thursday, March 24, 2005

Nevow: URLdb

Well, I am really, really impressed with Nevow. It really grows on you as you code. I've been posting little tidbits that I learn on the Nevow wiki, the kinds of things that beginners should have easy access to.

Today, I dug really deep into the nevow libs and followed the path of form posts (configurables, validation, etc.). Very interesting stuff. Not only do I like the way Nevow behaves and handles for developers, I like its guts, too. That's actually fairly uncommon when it comes to web app frameworks.

Anyway, today was very successful: my TinyURL knockoff (URLdb) is "fully" functional. It has a form interface for posting/creating shorter URLs as well as a URL you can post to via javascript, etc. The reason that I put "fully" in quotes, is that there is no persistent backend storage yet: it's all in memory. This was for simplifying the development/learning process only, and I have already started on writing the Atop classes.

I look forward to using Nevow in the future -- immediately, on the PyKon project; but in general, for any web app that doesn't require the pre-built functionality of a full-blown CMS.


Wednesday, March 23, 2005

Ruby on Rails vs Nevow

nevow :: web :: programming :: python :: ruby



I've just read the post at Blue Sky on Mars, and
I've got to agree 100%. In fact, earlier today, I posted a couple small
projects I am working on in the Nevow
wiki
, and mentioned a personal preference for Nevow over Ruby on
Rails. Personally, I believe one has more power and capabilities at
one's finger tips with Nevow. And this in no way takes away from the
simplicity and elegance of Nevow.


First, let me say that I am a huge Zope/Plone, twisted/Nevow,
and PEAK fan. Each has its strengths. But as far as general web
development frameworks go in python, nothing compares to Nevow for
building custom applications from the ground up. I know there are lots
of tools to choose from (Quixote, WebWare, among others), but the
simplest, cleanest -- and in my view -- the most powerful, is Nevow.

Nevow
has a thriving, active community, so I propose we give David
Heinemeier Hansson
and Ruby on Rails a run for their money. Nevow
and it's community can beat them hands-down. Let's get some amazing and
easy-to-read docs up. Let's get some videos. Let's show the world that
python has even more to offer than Ruby, and a clean web app dev
framework in Nevow is one of them.

Here are some Nevow resources:

nevow.org

Nevow Manual


Nevow at Divmod

Nevow Wiki

Code Repository

Nevow mail list archives

Nevow at del.icio.us

Nevow at PyWebOff

Nevow examples - these are
the examples that come with the Nevow distribution


Python Eggs

python :: programming



Okay, two developers that I highly regard are working on
something very, very cool: a package/utility that works around
distutils limitations and will be able to provide the same
functionality as java .jar files do, but for python. And then some.
They are called python .egg files, and you can read about them here:


Python Eggs

DirtSimple