Friday, December 31, 2010

How To Skip The Usual New Years Blogging

No predictions.

No year goals.

I'll follow my needs and wants through the year and where I end up I'll be happy with.

Tuesday, December 28, 2010

How To Give Twisted a Friendly Zero-Step: Part 1

Zero-Step: n. The first impression and actions of a user's exposure to a new tool, before actual research and use of the details.

I'm not as involved with or using Twisted as much I'd like, but I still pay attention and I care about the project. I understand its strengths and its weaknesses and I want to see it used in more cases where it is the best tool for the job. There is a obvious and recently publicized problem with Twisted and the Zero-Step.

Why do people go to twistedmatrix.com for the first time?

Usually, it probably isn't to read the documentation or start investigating open bug reports. First time visitors are looking to solve a problem and the first thing that has to be impressed on them is if Twisted actually solves that problem. This is actually a really big problem in this case, because there are so many problems it can solve. How do you present that image without boring lists of functionality and supported protocols?

The most obvious use-case for Twisted is probably for HTTP setups, while another important angle is probably people looking to test it out with something simple and pointless like an IRC bot. While an IRC bot is boring to a lot of us already familiar with the details, it is a very common introduction people make for network programming.

What kind of timeout can we expect on their willingness to read before getting the gist of it?

Not much, probably. Certainly, it takes more upfront investment in personal time and energy than a lot of people care to make. It would have to be obvious and prominent at the front page how to get a quick introduction that gives you an idea if Twisted is what you're looking for. The most obvious section you'll see now is What is Twisted? with one link in bold that will stand out to a new visitor, sending them to the Twisted Core Documentation. This is a really boring looking page, with no styling, lots of parts with names people won't understand, and an 11-part finger tutorial. This is not an approachable presentation.

The whole section needs replaced with something more eye catching and it needs to lead to a new section of the site that exists just to impress those new eyes. "If you want to get started with Twisted, the first thing you should do is read the Twisted Core Documentation" is too much to ask new comers who have no idea if this is what they're looking for and often don't have time to read that much documentation to make the call, because they've already got a problem with a deadline or simply have a limited amount of free time to pursue the interest on their own. I think there can be a sentiment to just let these facts weed out the less motivated, but it serves to cut out too many who would do the project some good.

How can you get the greatest number of readers to continue interest in Twisted with only one page view to convince them?

If you can fit it in without scrolling, then even better. Being lax enough to allow some scrolling to grok the whole introduction, can you get people intrigued enough to sit through more complete readings of the docs, put up with difficulties getting started and adjusting their way of thinking, and dealing with a relatively steep learning curve?

In Part 2, I'll continue my previous post about Django influencing the presentation of Twisted. Hopefully we can come up with some ideas to make the approach to Twisted less frightening for new users.

Monday, December 27, 2010

How To Limit Application Trust

Why is it when I see an application in the Chome Web Store I see a little notice about what permissions the app will have, and I'll see a similar list of permissions before installing an Android application?


Why is it that I don't see something more like this?


How To Push Your Habit Building Onto Technology

I use desktop alerts to keep myself organized through the day, in various ways. There are things i want to do repeatedly and I don't have a good track record with keeping good habits, so I have found some ways to make tools fill in the gaps for me. There are some specific examples i can give. I have been using the great site 750words.com for almost a year, and I love it. I write nearly every day, and I'm getting better at that habit all nthe time. usaully I only miss it when something interrupts me. I remember with something better than an email reminder or a note on my calendar each day, which both i can build a habit to ignore. I use an alert program, which is KAlert in my case, but any alert program should work the same. Every morning at 5AM, it spawns a google chrome window opening the 750words.com write page, and so I wake up and sit down to my computer every morning to find the page already open with a blank page and a blinking cursor, and I start writing. I don't have to remember, and I don't have an alert I can easily ignore. I just find myself sitting in front of exactly what I need to do, every morning.

It works nice, give it a try. I use a similar alert to prompt me for hourly journal entries for mood tracking, and work start/stop times, among other things. If I can represent it as a URL, I don't need to remember it, because my computer is an supplement of my brain.

Saturday, December 25, 2010

How To Tease Everyone On Christmas

This project may never become a serious thing, but it is fun. I intend to write an introductory post on the project, but for now I just want to post two code examples that should peek some interest.

# counter.py
from trapdoor.extension import Extension, Factory

class Counter(Extension):

    value = 0

    @Extension.method()
    @Extension.returns(int)
    def get(self):
        self._result = self.value

    @Extension.method()
    def incr(self):
        self.value += 1

counter = Factory(Counter)

and,

// counterdemo.js
WindowManager.createWindow();

document.write('<input id="a" />' +
'<br />'+
'<input onclick="window.t = window.t - 100;" name="faster" value="faster" type="button" />'+
'<input onclick="window.t = window.t + 100;" name="slower" value="slower" type="button" />'+
'<input id="t" />');

var t = 500;
var globalcounter = counter.create();

function update() {
    $('#t').val(typeof globalcounter.get);
    $('#a').val(globalcounter.get());
    globalcounter.incr();

    window.setTimeout(update, t);
}

window.setTimeout(update, t);

The result is a simple desktop app.

Sunday, December 19, 2010

How To Influence Twisted With Django

This is probably taken as the concept for a horror novel by many, but bare with me as I am going somewhere productive with this line of thought. There are a number of valuable ideas in Django, even if they aren’t original. I think some of the concepts could be interesting if applied to Twisted. We can’t start over, but maybe we could bridge the gap.

The Project

A “Project” is a very vague concept that we all start when we’re doing something new, but in a system like Django it is a codified piece of the framework. What a project is, how it is structured, and where its boundaries lie are all documented carefully. This provides an obvious starting point and creates a wonderful sense of consistency from one project to the next.

The Application

Within a Django project one or more Django applications are combined, and each application provides a unit of reusable functionality. This might consist of DB models and views to aid in tagging objects, providing search indexes, or generating thumbnails from uploaded photos. Like the Project itself, the application is documented by Django in terms of its boundaries and structure.

If Twisted Took A Page From the Django Book?

I think we can make a case for borrowing these concepts and patterns. The running theme is breaking large things up into reusable chunks and defining the boundaries and interactions in ways that we can connect them largely via configuration. Can this work with Twisted? I think it can, in specific areas.

We can probably borrow the Project unit directly, add a script to every project that runs twistd and loads commands, like the manage.py in Django. A standard settings module to configure a project is an obvious choice.

At the next level we would configure smaller, reusable parts the project would bring together. Instead of a urls.py, we might define a ports.py, which we use to map the interfaces we listen on and the services that handle them.

I think we can’t map “Application” to any one concept, but need a variety of types of reusable things. That is fine and Django does the same. We talk about apps all the time, but we also have Request Middleware, Context Middleware, etc. Twisted has a lot of room for configurable middleware.

This is certainly something that deserves more thought.

How To Avoid the Fear of Overkill

Something I read today in a Javascript forum gave me pause to think about broader attitudes in developer tools and libraries.
I love jQuery, but if this is all you want to do, jQuery is overkill. 

Javascript libraries are great if you want to do a lot of things, or one really complicated thing, but if you're just doing something small and simple, just write the javascript code. arandomgeek
I respectfully disagree.

Of course, people say this about a lot of other libraries and I defend against this stance in, more or less, all of these cases. I have heard it about Python and things in the standard library, about jQuery, about Django and Twisted, and about any language that isn't C. The common thread here is someone feeling that, as they are not using every or many parts of a tool, they should not use it for the one or two things it could be useful for. These people suffer from the Fear of Overkill.

I can summarize the argument against this very simply.

It would be overkill for you to write the entire tool for the one or two uses you have. It would also be overkill for you to write a bad version of the one or two uses, when you could use what already exists. It is not overkill to simply use what has already been provided to you.
I write here about programming, how to program better, things I think are neat and are related to programming. I might write other things at my personal website.

I am happily employed by the excellent Caktus Group, located in beautiful and friendly Carrboro, NC, where I work with Python, Django, and Javascript.

Blog Archive