March 12, 2011

Lightnings, 17:30 Saturday March 12

Eric Holscher says use ReadTheDocs, they are hosting scads of stuff for some great people. DjangDash gave birth to this fully open source project. Learned chef ass-basckwards. Heading for half a million hits a month, custom themes, tags & branched from Git with PDF generation thanks to Sphinx. Subdomains and project shortcuts will bebrilliant. They support CNAMEs. Chef is awesome. Multiple servers, because it's architected and shit. Think hard about your URLs before they become dumb-assed lame legacy URLs. Promote your project and find a designer. Open source is cool because they've had patches. You don't get arbotrary code execution rights until you are trusted. You now have one less reason for not writing docs.

Nate Aune says managing servers sucks, nobody likes setting up nginx or Apache, establishing backups, monitoring. Why don't we just have a "DeployNow" button, and that'd what DjangoZoom is supposed to to this. Copy your source code URL from github, paste it into DjangoZoom, and add a new project. Zoom inspects the .py file to make intelligent guesses about what's in there, setting it up to be served from nginx. In less than a minute, here's a django CMS instance running against a publicly-available Internet address. Now there is no reason to admin your servers for deployment, just use DjangoZoom.

Update on the Red Cross donation challenge. So far 45 definites, somewhere between $450 and $800 raised so far. If you haven't donated, please do so. A nuclear reactor in Japan has breached containment. Thngs are pretty dire. Please test REDCROSS to 90999 and then tweet with hashtag #pythoncares.

Oops, this speaker suddenly realizes this isn't the latest version of his stuff. Philikon talks about English, which started out giving us German words, then French, anwadays Finnish, Afrikaans, anything. We can manage to communicate nevertheless, and despite English being a mess the whole world manages to communicate. JavaScript's kinf ont he same. JavAScript, y u not pythonic? It's a mess. But we have all these really great apps, and slowly even replace desktop apps. JavaScript will be moar pythonic, ES5 deprecates all kinds of silly stuff. ES Harmony (much of it already implemented) will do more. Structural (unpacking) assignments, generators (stlen wholesale from Python), iterators, array and generator comprehensions, fewer parentheses, records, all kinds of great stuff. Use these features they are super exciting.

Enrique Bastos is talking about Community Bootstrap. He is deeply involved in building the Python community in Brazil, which is growing really fast, but fortunately community can scale. Why do this? If you don't have a good reason you could falll into traps like chasing an amount opf money rather than what you could experience with it. You need to live an experience to understand it, but don't rush. At first simply get people together to allow interpersonal bonds to form naturally. Don't try and build a group, hold events. People like to join in, they have a lot of events. Your community is the people who turn up at your events. Actively reduce entrance barriers by focusing on newcomers as the most important part of the community. Students are often valuable contributors. Empower people. Rules have side-effects, try to avoid them but discover your principles. Shirts are available with the Brazilian group's ten principles.

Jacob reminds us that daylight savings time begins tomorrow, and that iPhone alarm clocks will not work tomorrow.

Barry Warsaw confirms we all internationalize our applications, right? (of course we do). The flufl.i18n module helps you much more than gettext. Doing stuff with this is pretty difficult. Mailman 3 has some internationalization stuff, which has now been refactored out of the project for standalone us. You can find catalogs using the built-in strategies, or write your own. You can build stacks of languages and query the state of the stack.  Adaptable, it's on PyPI and Launchpad, available now. I think that FLUFL thing has gone to Barry's head.

Aron Grifiths (sp?) wants to tell us he's been through a series of Window managers pretty much like us all. They are either not scriptable or you have to write complex things like C plug-ins. Tomorrow's window manager won't use today's plug-ins. PyWI allows you to program your WM in Python, sand focus in any direction, do all kinds if wonderful stuff. Nice screencast to finish.

Josiah Carlson is talking about Over-Engineering for Dummies. This means either over-building a system or service. RUle 1: write everything yourself. Under no circumstances use convenient modules that do exactly what you want. 2. Start with something completely unsuited to the task; like the professor Josiah knew who build Prolog on top of Scheme, or the guy who added distributed counters to Cassandra. 3. Keep adding features and functionality and so on until no-one can think of anything else to add. 

Grace Law wants to tell you how to get that job you want. Lots of really qualified people don't get the jobs they want, Grace is here to help. Insight into some and interview questions and answers. Employers are looking for hidden remarks. Unintentionally disses QA people to ribald amusement. Be able to talk about learning new things - the more complex a technology you are learning the more impressive that is. Build open source projects and offer to discuss the code. You have initiative, take actions, and undertake complex projects for fun. Poor speed of answers to questions can give a bad impression. Tips on job search, see Grace.

Thanks to all speakers and, of course, Jacob Kaplan Moss.

March 11, 2011

PyCon Lightnings, 17:30 March 11, 2011

Session starts almost 20 minutes late - looked to me like logistical problems with the stage change, but I am so far out of the loop and the people in charge are so competent that the best thing I can do is start the post and wait patiently like everyone else.

I am sitting with Titus Brown and Peter Conerly, who are discussing matters of great technical moment. It's Peter's first PyCon, and the opening announcement is the every lightning slot in the conference is allcoated.

The opening talk is a request for PyCOn to raise $10,000. If 1 in 5 gave $10 each ... Text REDCROSS to 90999, then tweet that you gave with hashtag #pythoncares. End of talks on Sunday we will get a count.

Next speaker's display isn't working. Awkward pause. Silent audience. I am hoping things soon run more smoothly for Jacob (Kaplan Moss, the evergreen sprint chair who is here for the first time as a gentleman farmer).

Jeff Daily talks about Global Arrays Parallel Programming Toolkit, that added Python bindings to it toolkit in the last year. It gives access to a high performance computing array, giving access to distributed numpy-style ndarrays. Compared with other models, Global Arrays is less general than some techniques, but it scales well to at least 200,000 cores. This finally achieves highly parallel programming with true Python programming ease. Much simpler than message-passing interfaces, the technique is extensible and scalable, but requires that algorithms acknowledge the need for data consistency. If you're at PyCon, see Jeff at Poster #13.

Matt Harrison talks about his geek inferiority complex. He bought a computer at Fry's because computer class at school was too full. For years now people have been declaring "the year of Unix". Linux people run stuff like Gnome and KDE and a tiny set of other window managers. This guy inhabits a pretty specialized point in the Linux desktop fractal space, a rarified atmosphere in which indexing by 1 is awesome. And still we get more specialized. Matt's wrists forced him into this (in)sanity by screaming when he tried to pick the mouse up. Impressive demonstration of driving a window manager from the keyboard ensues, and lo! relevance: the QTile window manager is written in Python and is scriptable: now windows are flashing on and off in four different virtual screen. 2 further users will amount to exponential growth in the user population. Please join him.

Pete Fein wants us to hack for freedom. Video of protesters, under attack by flame throwers, getting pictures out through cellphone. Pete explains how he has helped freedom by getting stuff out on the street in 105 cities in a week. He worked with to help keep sites up and services running. They are leaderless and fanatically devoted to freedom. When the net was up they provided encryption and other services, mirrored censored sites and manually relayed tweets for egyptian users with no network access later. With Anonymous they set up a network to send information by fax, and by injecting information into logs of a few servers they found still up. It can be exhausting working for freedom, but we have the power to help people achieve it.

Next speaker (fumanchu at not using his own laptop, another pause but we are now seeing images. No, gone again. Back again. Go. Logging. Really? Yes, because all the modules in your application can use the logging model independently, but this isn't applicable for things like performance statistics so that independent modules can log performance data and report on it. Solution: log into Python dictionaries, with package names as the top-level namespace. You can define record structures, and (for reporting only) can insert functions into the dict to be used when reports are required (writing the log should be high speed, so no function calls). This allows people to build their own reporting tools, or to user ready-made ones such as the one built into CherryPy. Open Space tomorrow.

More AV glitches as the next speaker arrives, then departs so I have no insight into the problem. Ah, they need a VGA dongle for a mini-display port. Strange, PyCon normally has this stuff buttoned down. I hear someone say "waht are the odds" and don't know whether this is a good sign or a bad one. BVideo at last appears, and Nathan Nichols wants to tell us some lessons he learned writing automated content generation systems using DSLs. Clients send data, they create quality content for it. Journalists are needed but hey they don't know Python. So instead use DSLs. Rules: 1. Keep Parsing Simple, Stupid (PyParsng was overqualified for the job, regexes and YAML serve better); 2. Keep things on rails (no, not Rails - Nathan knows his audience) and remember that while we think Python is awesome journalists don't and would be overwhelmed by its complexity; 3. Tools are super-important, and DSLs allow you to write very specific tools. Good talk.

Another pause, this time to load the next presenter's files ont he same laptop. It's Giles Thomas wants to tell us why Resolver Systems switched from IronPython back to CPython. Resolver are known for their eponymous spreadsheet, which is quite clearly a windows application. They now have a new project, Dirigible, was written for the web to provide similar services. The initial strategy of marketing to financial companies, and Windows was mandated bh the conservative nature of the client base. So Resolver 1 was a full .NET application. For Dirigible, CPython was the natural choice since none of the .NET stuff was required.

The SingPath competition is about to start somewhere close by. More lightnings in the morning. Awesome day 1!

Supporting All Versions of Python All The Time With Tox

This talk actually used the differences between Python 2 and Python 3 as the major version differences, but these are just an extreme example of inter-version differences.

Tox uses a config file that allows you to specify (among other things) which Python versions should be tested, dependencies between tests and so on. But how do we cope with syntax differences, where(for example) Python 2 code will raise syntax errors. The 2to3 utility is a fast and very comprehensive tool, and you can test for Python 3 and run 2to3 automatically in your

It is possible to generate a single source file that compiles under both Python 2 and Python 3, but this is not easy. Often it's easier to convert - particularly for tests, where automatic conversion may not work. Tests may be distributes or non-distributed. In both cases converting the tests to Python 3 is likely to be required. Automated conversion is always subject to failure.

It's possible to use different environments (virtualenv) for the different versions, and even with Jython. Although tox can be used from the command line, it was designed for use in continuous integration. It does need to be bootstrapped a little bit: it should be installed locally (probably under a virtualenv!) You can also define a custion PyPI index.

Summary: the most important thing is to be able to support Python3. The single source approach requires most discipline. Mozilla is hiring. Had to leave the Q&A to start a meeting. Sorry.

JavaScript for Pythonistas

My first extreme talk, and Ian Bicking is always worth a listen. Because it's extreme, no intro to JavaScript. "It's a small, simple language with some weird things that are totally understandable." Ian wants to focus on what the language does rather than why it does it.

JavaScript is easily accessible to Python programmers, but the data structures can be tricky. Arrays are like Python lists, objects are like Python dicts. Objects can be fairly lightweight, and can be passed around. Keys are always strings, -- subscripted notation and attribute notation are equivalent. Exceptrions work very similarly to Python, but JavaScript programmers don't use them anywhere near as extensively.

Function declarations are fairly intuitive, but unlike in Python an undeclared variable is assumed to be located in some "containing" scope, and the var keyword causes them to be bound locally. Function arguments are always optional, and parameters for which there is no corresponding actual argument will be undefined. Undefined is "falsish", and we have to use typeof(name) == "undefined" to test for this.

Object classes are created by prototype, which is more like Self, or perhaps Ruby, than Python. The new operator is the only way to effectively create new instances. A function call implicitly binds to the variable this, but without new the binding will be to some global object (in a browser typically the document or the window). The inheritance hierarchy is handled similarly to Python except that instance creation calls the prototype function using new. It's not, therefore, as simple to use factory functions and classes interchangeably - though it can be done if you work.

The this object is almost comparable to Python's self, but the way JavaScript figures out what value it takes is, Ian submits, insane. With no equivalent to Python's bound methods, and method calls are determined syntactically. Consequently assigning an object's method to a local variable will cause this to be computed completely differently depending on whether the method is called directly or through the local variable. This is also problematic when closures are used to create private data stores. You can sometimes overcome it my saving this for later use (Ian chose the name self for the local variable he used to do this).

Functions have .call() and .apply() methods, whihc you can use to call them in specific ways.

Monkey patching should be avoided.

Types are one of the aspects of JavaScript makes least sense to people. It has numbers, strings and Booleans. The language also has the same kind of distinction between primitive and boxed values that Java does. There should really be no need to use the classes that wrap the primitive types. This gives rise to strange non-intuitive rules that are applied during comparisons. The "===" operator is similar to Python's is.

Arrays are disappointing to Python users, being a pale shadow of the Python list. There is not iteration protocol, and no test for containment of a value within a list.

Much of JavaScript's applications work on the browser Document Object Model (DOM). C++ is responsible for the DOM's complexity. The language is improving, but the new features are only slowly working their way into implementations. Many newer features have been inspired by, among other languages, Python.

If you like Python, you might want to try using CoffeeScript. It is more whitespace sensitive than Python, and handles arrays better than JavaScript.

Alas, time for only a few questions:

Q: What do you recommend as the closest equivalent in JavaScript to Python's interactive console. A: Firebug and the like.

Q: What does inheritance look like with prototypes?
A: If a prototype has a prototype that is essentially subclassing.

March 1, 2011

Promoting and Supporting Open Source

I was a little surprised today to discover that my Twitter buds mostly hadn't heard I had moved to Portland, and when I thought about it I realized that blog readers had no way to know either, since although I have been talking about the move a lot I have been too busy to write about it. This condition still holds, really, so this is a sketch for now.

In order to engage the Portland business, government and open source communities I organized a reception a couple of weeks ago, which also represented the announcement of a new business, The Open Bastion. As you can see from the web site we are still in well, not exactly stealth mode, but it's early days yet. I am happy to say that the reception appears to have started many conversations abut open source, which I will be following up on as they develop.

Why Portland? Well, I have been feeling the pull of the West coast for some time, and have visited Portland quite a but recently, including running DjangoCon US there last September. So the plan for the new business is to organize and run technical events–conferences, presentations, training sessions. There is also a very active Python user group here, which I attended shortly after my arrival in the city as one of about forty people there that evening. Portland likes to think of itself as the open source capital, but I want it to put its money where its mouth is.

Portland, being a conference city, is marvelously well endowed with venues. I am happy to say that it appears to be a city that values its heritage and it still has many fine original buildings, which makes the place a pleasure to walk around. With excellent public transport (including a fare-free zone in the center to discourage the use of private cars) it's a wonderful place to live and to visit, and I am looking forward to spending time here.

I will be keeping in touch with the East coast, too, by spending roughly a  quarter of my time in New York, where I expect technical events will also be required. We are, of course, equally happy to help you with events in the location of your choice. So if you are thinking about running a technical sales presentation, or a conference, or any other similar sort of event and you would like someone to take the organization off your hands, drop me a line. I am "sholden at theopenbastion dot com".

Community or Fanbois?

Regular readers will know that I place a lot of stock in community. I started PyCon, the US Python community conference, which has taken off worldwide. In earlier incarnations I was chairman of the Sun UK User Group and Treasurer of DECUS UK. As chairman of the Python Software Foundation I spend a lot of time thinking about how to engender community spirit and encourage people to contribute to the Python language in any way they can. This is an ongoing battle, but I do think that the Board is showing signs of understanding how to involve people, and also that the Foundation relies on the involvement of third parties in order to achieve most of what supports its mission.

In my own life, I have recently decided to become (even) more involved in open source, hopefully to the extent that I can make a better living at it - the PSF chairmanship is an honorary position and takes time away from business matters. So I have moved to Portland (whose natives frequently refer to it by its PDX airport code), and recently hosted a reception to get PDX open source people together with elected representatives and business people with the intention of starting new conversations about how each can benefit the other. I am hoping that the move will allow me to work in a more sympathetic environment, and one in which the potential of open source is more clearly perceived.

So anyone who cares to look should be able to discern that I am at least fairly serious about Portland and its open source community, and working towards improving things for the open source community (on the theory that a rising tide lifts all boats). I have found in the past that it's generally possible to share plans with open source community members and have them respect the sensitive nature of the information you have shared with them. This is one of the things I like about working in the open source community: generally speaking (and with the occasional unavoidable exception) people are willing to respect your concerns, and are generally much more concerned about producing good software than scooping each other on news of features and the like.

The people I meet in the open source world are generally responsive to new ideas and quite willing to discuss them. Generally speaking people are both willing and able to discuss the work they are doing - after all, it i going to be published, so there is little point in secrecy. Contrast this, however, with the brouhaha that arose today about the latest version of Apple's OS X operating system. It seems that Apple shared a beta version with some developers, who have naughtily (and anonymously) disclosed what purports to be real information about what Apple rather grandiosely term "the world's most advanced operating system". To which  my reply is a snort of derision, since I think that Mac OS X is actually in some ways inferior to Windows.

It turns out that they really don't like it when engineers who are given access to a pre-release (in this case OS X Lion, the forthcoming 10.7 release) copy and then promptly spill the beans to all and sundry. But frankly these look like small beans indeed. It seems as though Apple has tweaked quite a bit, but hasn't introduced any fundamentally new features into the operating system.  It's all very well for Apple to delight in being different, but the radical differences between Apple's GUI and everyone else's just don't seem to actually make using the computer any easier, and leave me wondering whether Apple is really heading in the right direction.

Whatever else they may have going for them they certainly don't seem to have engendered a lot of loyalty in their fan base. Or maybe this was just a few bad apples (so to speak).,