<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Ian Bicking: a blog</title>
	<link>http://blog.ianbicking.org</link>
	<description></description>
	<pubDate>Sat, 21 Jun 2008 19:42:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.3</generator>
	<language>en</language>
			<item>
		<title>My Experience Writing a Build System</title>
		<link>http://blog.ianbicking.org/2008/06/19/my-experience-writing-a-build-system/</link>
		<comments>http://blog.ianbicking.org/2008/06/19/my-experience-writing-a-build-system/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 04:41:54 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/06/19/my-experience-writing-a-build-system/</guid>
		<description><![CDATA[
Lately there&#8217;s been some interest in build processes among various people &#8212; Vellum was announced a while back, Ben has been looking for a tool and looking at Fabric, and Kevin announced Paver.  At the same time zc.buildout is starting to gain some users outside of the Zope world, and I noticed Minitage as [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>Lately there&#8217;s been some interest in build processes among various people &#8212; <a class="reference external" href="http://www.zedshaw.com/projects/vellum/">Vellum</a> was announced a while back, <a class="reference external" href="http://groovie.org/2008/04/09/wheres-the-capistrano-knock-off-for-us-python-web-devs">Ben has been looking for a tool</a> and looking at <a class="reference external" href="https://savannah.nongnu.org/projects/fab/">Fabric</a>, and <a class="reference external" href="http://www.blueskyonmars.com/projects/paver/">Kevin announced Paver</a>.  At the same time <a class="reference external" href="http://pypi.python.org/pypi/zc.buildout">zc.buildout</a> is starting to gain some users outside of the Zope world, and I noticed <a class="reference external" href="http://www.minitage.org/doc/rst/">Minitage</a> as an abstraction on top of zc.buildout.</p>
<p>A while ago I started working on a build project for <a class="reference external" href="http://topp.openplans.org">Open Plans</a> called <a class="reference external" href="https://svn.openplans.org/svn/fassembler/trunk">fassembler</a>.  I think the result has been fairly successful and maintainable, and I thought I&#8217;d share some of my own reflections on that tool.</p>
<div class="section" id="update-what-we-were-trying-to-accomplish">
<h2><strong>Update:</strong> what we were trying to accomplish</h2>
<p>I didn&#8217;t make it clear in the post just what we were trying to do, and what this build system would accomplish.</p>
<p>Our site (<a class="reference external" href="http://openplans.org">openplans.org</a>) is made up of several separate servers with an HTML-rewriting proxy on the front end.  We have a Zope server running a custom application, Apache running WordPress MU, and some servers running Pylons or other Python web applications for portions of our site.  We needed a way to consistently reproduce this entire stack, all the pieces, plugged together so that the site would actually work.  Two equally important places where we had to reproduce the stack are for developer rigs and the production site.</p>
<p>Our code is primarily Python and we use a <em>lot</em> of libraries, developed both internally and externally.  Setting up the site is primarily a matter of installing the right libraries and configuration and setting up any databases (both a <a class="reference external" href="http://www.zope.org/Products/StandaloneZODB">ZODB</a> databases and several MySQL databases).  We use a few libraries written in C, but <a class="reference external" href="http://python.org/doc/current/lib/module-distutils.html">distutils</a> handles the compilation of those pretty transparently.</p>
<p>For this case we really don&#8217;t care about build tools that focus on compilation.  We don&#8217;t care about careful dependency tracking because we are compiling very little software.</p>
</div>
<div class="section" id="make-doesn-t-make-sense">
<h2>make doesn&#8217;t make sense</h2>
<p><strong>Update 2</strong>: If you think the make model makes lots of sense, read the preceding section &#8212; it makes sense for a different problem set than what we&#8217;re doing.</p>
<p>We initially had a system based on <a class="reference external" href="http://agendaless.com/Members/chrism/software/buildit">BuildIt</a>, which is kind of like <a class="reference external" href="http://en.wikipedia.org/wiki/Make_(software)">make</a> with Python as the control code.  It wasn&#8217;t really a good basis for our build tool, and I think it added a lot of confusion, compounded by the fact that we weren&#8217;t quite sure what we wanted our build to do.  Ultimately I think the make model of building doesn&#8217;t make sense.</p>
<p>The make model is based on the idea that you <strong>really</strong> want to save work.  So you detect changes and remake things only as necessary.  For compilation this might make sense, because you edit code and recompile a lot and it&#8217;s tedious to wait.  But we are building a website, and installing software, and none of that style of efficiency matters.  make-style detection of work to be done doesn&#8217;t even save any time.  But it does make the build more fragile (e.g., if you define a dependency incorrectly) and much harder to understand, and you constantly find yourself wiping the build and starting from scratch because you don&#8217;t trust the system.</p>
<p>The metaphor for the new build system was much simpler: do a list of things, top to bottom.  There&#8217;s no effort into detecting changes in the build, or changes in the settings, or anything else.</p>
</div>
<div class="section" id="do-things-carefully">
<h2>Do things carefully</h2>
<p>In the build system almost all actions go through the <a class="reference external" href="https://svn.openplans.org/svn/fassembler/trunk/fassembler/filemaker.py">filemaker</a> module.  This is <em>kind of</em> a file abstraction library.  But the goals are entirely different than convenience: the goal is transparency and safety.  In contrast Paver uses <a class="reference external" href="http://www.jorendorff.com/articles/python/path/">path.py</a> for convenience, but I&#8217;m not sure what the win would be if we used a model like that.</p>
<p><tt class="docutils literal"><span class="pre">filemaker</span></tt> itself is heavily tied to the framework that it&#8217;s written for, specifically user interaction and logging.  Most tasks just <em>do</em> things, and rely on filemaker to detect problems and ask the user questions.  For example, every time a file is written, it checks if the file exists, and if it has the same content.  If it exists with other content, it asks the user about what to do.  It doesn&#8217;t overwrites files without asking (at least by default).  I think this makes the tool more humane as the default behavior for a build is to be careful and transparent.  The build author has to go out of their way to make things difficult.</p>
<p>Many zc.buildout recipes will blithely overwrite all sorts of files which always made me very uncomfortable with the product.  It&#8217;s the <em>recipes</em> in zc.buildout which do this, not the buildout framework itself, but because buildout made overwriting the easy thing to do, and didn&#8217;t start with humane conventions or tools, this behavior is the norm.</p>
<p>What I think filemaker most accomplished was the ability to do file operations while also asserting the expected state of the system, and so makes build bugs noticeable earlier instead of getting a build process that finishes successfully but creates a buggy build, or having an exception show up far from where the error was originally introduced.</p>
<p>Also, because it won&#8217;t overwrite your work in progress this has saved the build from engendering deep feelings of hatred in cases when it might overwrite your work in progress.  It&#8217;s hard to detect this absence of hatred, but I know that I&#8217;ve felt it with other systems.</p>
</div>
<div class="section" id="update-a-corollary-ignore-no-errors">
<h2><strong>Update:</strong> a corollary: ignore no errors</h2>
<p>One question you might wonder about: why not a shell script?  We did prototype some things as shell scripts, but we&#8217;ve consistently moved to Python at some point, even things that seemed really trivial.  The problem with shell scripts is they have horribly bad behavior with respect to errors.  Ignoring errors is really really easy, noticing errors is really hard.</p>
<p>This is absolutely unacceptable for builds.  Builds must not ignore errors.  The build may mostly work despite an error.  It might be totally broken, but the error message is lost in all sorts of useless output.  The error message probably makes no sense.  The context is lost.  No suggestion is given to the user.</p>
<p>When builds work, that&#8217;s great.  Build <em>do not</em> always work.  They always fail sometimes, and some poor sucker (usually in some hot potato-like arrangement) has to figure out what went wrong.  You have to plan for these problems.</p>
<p>Everything in the build tries to be careful about errors.  All places where it is not, it is a bug.  The resolution isn&#8217;t to see something appear to work, but create a broken build, and say &quot;oh, you forgot to set X&quot;.  The resolution is to make sure when you forget to set X it gives you an error that tells you to set X.</p>
<p>This is one of the more important and more often ignored principles of a good build/deployment system.  Maybe it&#8217;s gotten better, but when I first used zc.buildout (<em>very</em> early in its development) the poor handling of errors was by far the biggest problem and it left me with a bad taste in my mouth.  easy_install and setuptools in general is also very flawed in this respect.</p>
</div>
<div class="section" id="log-interesting-things">
<h2>Log interesting things</h2>
<p>I tried to make a compromise between logging very verbosely, and being too quiet.  As a user, I want to see everything <em>interesting</em> and leave out everything <em>boring</em>.  Determining interesting and boring can be a bit difficult, but really just require some attention and tweaking.</p>
<p>To make it possible to visually parse the output of the tool I found both indentation and color to be very useful.  Indentation is used to represent subtasks, and color to make sections and warnings stand out.</p>
<p>The default verbosity setting is not to be completely quiet.  Silence is a Unix convention that just doesn&#8217;t work for build tools.  Silence gets you interactions like this:</p>
<pre class="literal-block">
$ build-something target-directory/
(much time passes)
Error: cannot write /home/ianb/builds/20080426/target-directory/products/AuxInput/auxinput/config/configuration.xml
</pre>
<p>Why did it want to write that file?  Why can&#8217;t it write that file?  Is the build buggy?  Did I misconfigure it?  Does the directory exist?</p>
<p>The typical way of handling this is either to run the build again with logging setup or otherwise make it more verbose, or to get in the habit of always running it verbose.</p>
</div>
<div class="section" id="mixing-code-and-configuration">
<h2>Mixing code and configuration</h2>
<p>BuildIt, which we were using before, had the ability to put variables in settings, and you could read an option from another section with something like <tt class="docutils literal"><span class="pre">${section/option}</span></tt>.  It was limited to simple (but recursive) variable substitution, and had some clever but very confusing rules that created a kind of inheritance.</p>
<p>I liked the ability to do substitution, but wasn&#8217;t happy with the compromise BuildIt made.  I wasted a <em>lot</em> of time trying to figure out the context of substitutions.  So, I saw two directions.  One was to remove the cleverness and just do simple substitution.  This is the choice zc.buildout made.  The other was to go whole-hog.  With a bit of trepidation I decided to to go for it, and I made the choice to treat all configuration settings as <a class="reference external" href="http://pythonpaste.org/tempita/">Tempita</a> templates.  All configuration is generally accessed via <tt class="docutils literal"><span class="pre">config.setting_name</span></tt>, and that lazily interpolates the setting (it took me quite a while to figure out how to avoid infinite loops of substitution).  Because evaluation is done lazily settings can depend on each other and be overridden and have lots of code in defaults (e.g., a default that is calculated based on the value of another setting), and it works out okay.  Most settings just ended up having a smart default, and as a result very little tweaking of the configuration is necessary.</p>
<p>Somewhat ironically the result was a kind of atrophying of the settings, because no one actually <em>set</em> them, instead we just tweaked the defaults to get it right.  Now I&#8217;m not entirely sure what exactly the &quot;settings&quot; are setting, or who they should really belong to.  To the build?  To the tasks?  While this is conceptually confusing, in practice it isn&#8217;t so bad.  This mixing of code and configuration has been distinctly useful, and not <em>nearly</em> as problematic to debug as I worried it would be.   In some ways it was a way of building <tt class="docutils literal"><span class="pre">lambda</span></tt> into every string, and the lazy evaluation of those strings has been really important.  But it&#8217;s not clear if they are really settings.</p>
<p>Would normal string interpolation have been enough (e.g., with <a class="reference external" href="http://python.org/doc/current/lib/node40.html">string.Template</a>)?  I&#8217;m pretty sure it wouldn&#8217;t have been.  The ability to do a little math or use functions that read things from the environment has been very important.</p>
</div>
<div class="section" id="managing-python-libraries">
<h2>Managing Python libraries</h2>
<p>fassembler uses <a class="reference external" href="http://pypi.python.org/pypi/virtualenv">virtualenv</a> for building each piece of the stack.  Generally it creates several environments and installs things into them &#8212; it doesn&#8217;t run inside the environments itself.  This works fine.</p>
<p>zc.buildout in comparison does some fancy stuff to scripts where specific eggs are enabled when you run a script.  Each script has a list of <em>all</em> the eggs to enable.  You can&#8217;t install things or manage anything manually, even to test &#8212; you always have to go through buildout, and it will regenerate the scripts for you.  zc.buildout was implemented at the same time as workingenv (the predecessor to virtualenv), and I actually finished virtualenv with fassembler in mind, so I can&#8217;t blame zc.buildout for not using virtualenv.  That said, I don&#8217;t think the zc.buildout system makes any sense.  And it&#8217;s really complicated and has to access all sorts of not-really-public parts of easy_install to work.</p>
<p>Isolation is only the start.  easy_install makes sure each library&#8217;s claimed dependencies are satisfied.  You might then think easy_install would do all the work to make the stack work.  It is nowhere close to making the stack work.  <tt class="docutils literal"><span class="pre">setup.py</span></tt> files can/should contain the bare minimum that is known to be necessary to make a package work.  But they can&#8217;t predict future incompatibilities, and they can&#8217;t predict interactions.  And you don&#8217;t want all your packages changing versions arbitrarily.  If you work with a lot of libraries you <em>need</em> those libraries to be pinned, and only update them when you <em>want</em> to update them, not just because an update has been released.</p>
<p>So for each piece of the stack we have a set of &quot;requirements&quot;.  This is a flat files that indicates all the packages to install.  They can have explicit versions, far more restrictive than anything you should put in <tt class="docutils literal"><span class="pre">setup.py</span></tt>.  It also can check out from svn, including pinning to revisions.  This installation plan can go in svn, you can do diffs on it, you can branch and copy and do whatever.  Maybe at some point we could use it to keep cached copies of the libraries.  For now it mostly uses <tt class="docutils literal"><span class="pre">easy_install</span></tt> (and <tt class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">develop</span></tt> for checkouts).</p>
<p>In parallel we have a command-line program for just installing packages using files like this, called <a class="reference external" href="https://svn.openplans.org/svn/PoachEggs/trunk">PoachEggs</a>.  I want to make this better, and have fassembler use it, but I mostly note it because it implements a feature that can &quot;freeze&quot; all your packages to a requirements file.  You take a working build and freeze its requirements, giving explicit (<tt class="docutils literal"><span class="pre">==</span></tt>) versions for packages, and pin all the svn checkouts to a revision, so that the frozen requirements file will install exactly the packages you know work.</p>
<p>An alternative to this is what the <a class="reference external" href="http://repoze.org/">Repoze</a> guys are doing, which is to create a custom index that only includes the versions of libraries that you want.  You then tell easy_install to use this instead of <a class="reference external" href="http://pypi.python.org/pypi">PyPI</a>.  It works with zc.buildout (and anything that uses easy_install), but I can&#8217;t get excited about it compared to a simple text file.  I also want svn checkouts instead of create tarballs of the checkout &#8212; I like an editable environment, because the build is just as much to support developers as to support deployment.</p>
</div>
<div class="section" id="the-structure">
<h2>The structure</h2>
<p>A big part of the development of fassembler was nailing down the structure of our site, and moving to use tools like <a class="reference external" href="http://supervisord.org/">supervisor</a> to manage our processes.  A lot of these expectations are built into the builds and fassembler itself.  This is part of what makes the build Work &#8212; the pieces all conform to a common structure with some basic standards.  But this isn&#8217;t the build tool itself, it&#8217;s just a set of conventions.</p>
<p>I don&#8217;t know quite what to make of this.  Extracting the conventions from the builds leads to a situation where you can more easily misconfigure things, and the installation process ends up being more documentation-based instead of code-based.  We do <em>not</em> want to rely on documentation, because documentation is generally because of a flaw in the build process that needs explaining.  It&#8217;s faster for everyone if the code is just right.  Maybe these conventions could be put into code, separate from the build.  The abstraction worries me, though &#8212; too much to keep track of?</p>
</div>
<div class="section" id="what-we-don-t-get-right">
<h2>What we don&#8217;t get right</h2>
<p>The biggest problem is that fassembler is our own system and no one else uses it.  If someone wants to use just a piece of our stack they either have to build it manually or they have to use our system which is meant to build all our pieces together with our conventions.  There&#8217;s some pressure to use zc.buildout to make pieces more accessible to other Zope users.  We&#8217;ve also found things that build with zc.buildout that we&#8217;d like to use (e.g., setups for <a class="reference external" href="http://varnish.projects.linpro.no/">varnish</a>).</p>
<p>We haven&#8217;t figured out how to separate the code for building <em>our</em> stuff from the build software itself.  There&#8217;s a bootstrapping problem: you need to get the build code to build a project, and so it can&#8217;t be part of the project you are building.  zc.buildout uses configuration files (that aren&#8217;t code, so they lack the bootstrap problem) and it uses <a class="reference external" href="http://pypi.python.org/pypi/zc.buildout#id1">recipes</a> (a kind of plugin) and has gone to quite a bit of effort to bootstrap everything.  virtualenv also supports a kind of <a class="reference external" href="http://pypi.python.org/pypi/virtualenv#bootstrap-example">bootstrap</a> which we use to do the initial setup of the environment, but it doesn&#8217;t support code organization in the style of zc.buildout.</p>
<p>Builds are also fairly tedious to write.  They aren&#8217;t horrible, but they feel much longer than they should be.  Part of their length, though, is that over time we put in more code to guard against environment differences or build errors, and more code to detect the environment.  But compared to zc.buildout&#8217;s configuration files, it doesn&#8217;t feel quite as nice, and if it&#8217;s not as nice sometimes people are lazy and do ad hoc setups.</p>
</div>
<div class="section" id="the-future">
<h2>The future</h2>
<p>We haven&#8217;t really decided, but as you might have noticed zc.buildout gets a lot of attention here.  There&#8217;s quite a few things I don&#8217;t like about it, but a lot of these have to do with the recipes available.  We don&#8217;t <em>have</em> to use the standard zc.buildout egg installation recipe.  In fact that would be first on the chopping block, replaced with something much simpler that assumes you are running inside a virtualenv environment, and probably something that uses requirement files.</p>
<p>Also, we could extract filemaker into a library and recipes could use that.  Possibly logging could be handled the same way (the <a class="reference external" href="http://python.org/doc/current/lib/module-logging.html">logging</a> module just isn&#8217;t designed for an interactive experience like a build tool).  Then if we used other people&#8217;s recipes we might feel grumpy, since they&#8217;d use neither filemaker or our logging, but it would still work.  And our recipes would be full of awesome.  The one thing I don&#8217;t think we could do is introduce the template-based configuration.  Or, if we did, it would be hard.</p>
<p>That said, there is a very different direction we could go, one inspired more by <a class="reference external" href="http://code.google.com/appengine/">App Engine</a>.  In that model we build files under a directory, and that directory is the build.  Wherever you build, you get the same files, period.  All paths would be relative.  All environmental detection would happen in code at runtime.  Things that aren&#8217;t &quot;files&quot; exactly would simply be standard scripts.  E.g., database setup would not be done by the build, but would be a script put in a standard location.</p>
<p>This second file-based model of building is very much different than the principles behind zc.buildout.  zc.buildout requires rebuilding when anything changes, and does so without apology.  It requires rebuilding to move the directories, or to move to different machines.  Using a file-based model requires a lot of push-back into the products themselves.  Applications have to be patched to accept smart relative paths.  They have to manage themselves a lot more, detect their environment, handle any conflicts or ambiguities, being graceful about stuff like databases, because the files have to be universal.  In an extreme case I could imagine going so far as to only keep a template for a configuration file, and write the real configuration file to a temporary location before starting a server (if the server cannot be patched to accept runtime location information).</p>
<p>So this is the choice ahead.  I&#8217;m not sure <em>when</em> we&#8217;ll make this choice (if ever!) &#8212; build systems are dull and somewhat annoying, but they are no more dull and annoying than dealing with a poor build system.  Actually, they are <em>definitely</em> less dull than working with a build system that isn&#8217;t good enough or powerful enough, or one that simply lacks the TLC necessary to keep builds working.  So no choice is a choice too, and maybe a bad choice.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/06/19/my-experience-writing-a-build-system/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Thoughts About the Erlang Runtime</title>
		<link>http://blog.ianbicking.org/2008/06/09/thoughts-about-the-erlang-runtime/</link>
		<comments>http://blog.ianbicking.org/2008/06/09/thoughts-about-the-erlang-runtime/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 00:03:21 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Erlang]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/06/09/thoughts-about-the-erlang-runtime/</guid>
		<description><![CDATA[
I should preface this entire post by noting that I haven&#8217;t used Erlang, just read about it, and I handle most concurrency using Python threads, a model for which I have no great affection (or hate).  But I was reading two posts by Patrick Logan on Erlang and it got me thinking again.
From my [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>I should preface this entire post by noting that I haven&#8217;t used Erlang, just read about it, and I handle most concurrency using Python threads, a model for which I have no great affection (or hate).  But I was reading <a class="reference external" href="http://patricklogan.blogspot.com/2008/05/toward-finer-tuning-of-definitions-of.html">two</a> <a class="reference external" href="http://patricklogan.blogspot.com/2008/05/this-is-part-two-of-my-response-to-ted.html">posts</a> by Patrick Logan on Erlang and it got me thinking again.</p>
<p>From my reading and what I&#8217;ve heard from other people, Erlang the language-and-syntax seems quite crufty.  Erlang is not the Complete Package, the language that will make you leave your wife, the language that will have you walking into telephone polls because it&#8217;s just so <em>hot</em> that you can&#8217;t take your eyes off it.  Erlang is not that language.  People seem to get excited about two things in Erlang: the concurrency model and pattern matching.  I&#8217;m not quite sure why people are excited about pattern matching.  <a class="reference external" href="http://svn.colorstudy.com/home/ianb/recipes/patmatch.py">Pattern matching isn&#8217;t particularly hard to implement</a>, though maybe it interacts with other aspects of the system in a way I don&#8217;t understand.  I remain skeptical that it&#8217;s anything special.</p>
<p>Then there is the concurrency model (and its associated message passing), and this <em>does</em> strike me as special.  You can <a class="reference external" href="http://candygram.sourceforge.net/">kind of</a> implement that model in Python, but with none of the concrete benefits.</p>
<p>These are the useful features I see in the concurrency model:</p>
<ol class="arabic simple">
<li>Erlang processes are share-nothing.</li>
<li>The processes are light weight.  You can start lots of processes, and they start quickly and can die off quickly without any great overhead.  They aren&#8217;t OS-level processes.  These are sometimes called green processes or microprocesses.  There are many implementations of micro<em>threads</em> in Python, but you lose the benefits of share-nothing.</li>
<li>The runtime makes light weight processes feasible as well.  The OS overhead of a Python process is actually just a small part of the total overhead when spawning a process.  Loading and initializing the runtime libraries of a Python program of even modest complexity is problematic.  I&#8217;m not sure exactly how Erlang does this, but I suspect it&#8217;s because libraries can be safely shared because Erlang is a functional language.  (<a class="reference external" href="http://blog.ianbicking.org/2008/01/12/what-php-deployment-gets-right/">PHP is also like this</a>, with most of the library written in a sharable C library.)</li>
</ol>
<p>1 and 2 can be handled with the right VM.  This isn&#8217;t a particularly <em>common</em> VM design, but it&#8217;s certainly doable.  3 is tricky, and effects the language design.</p>
<p>I don&#8217;t think it effects the language design as greatly as to require a functional language.  It requires that sharable code itself be a functional (i.e., immutable) subset of the language.  What the code <em>does</em> doesn&#8217;t have to be functional, only what the code <em>is</em>.</p>
<p>To explain this, functions in most languages are immutable.  Python functions aren&#8217;t actually immutable, but they are close enough that hardly anyone would notice if you made them immutable (right now you can overwrite their name, compiled code, and some other stuff &#8212; but almost no one actually does this).  The function may have side effects, but as long as the function <em>object</em> is immutable then it can be shared safely among processes.</p>
<p>You can extend this to the module as a whole.  This means you couldn&#8217;t <a class="reference external" href="http://en.wikipedia.org/wiki/Monkey_patch">monkeypatch</a> objects in the module, and module-level assignments would effectively be constants.  Any module-level objects would have to be immutable.  Things like classes, which are also a kind of module-level object, would also have to be immutable &#8212; meaning things like class variables would be immutable.  It could still be possible to do module-level code if there was a way of freezing the module after its instantiation (this would be important for Python, as even decorators are a kind of code run at import time).  Adding a general concept of &quot;freezing&quot; to the language might be the most general and expedient way to make modules sharable.</p>
<p>The other half of the concurrency model in Erlang is message passing.  Erlang processes send messages around like other systems send methods.  It would be possible to use exactly Erlang&#8217;s system, as it&#8217;s not Erlang-specific and has been ported to many languages.  Though I&#8217;d be somewhat more inclined to use <a class="reference external" href="http://en.wikipedia.org/wiki/Bencode">bencode</a> as it has some cleverness in its design.  Or perhaps JSON, just because.  Regardless of the format you are always passing around <em>data</em>, which I think is important.  Systems that pass around &quot;objects&quot; become complex, mostly because you just <strong>cannot</strong> pass objects around and so those systems are just complex facades built around data exchange.</p>
<p>Lately I&#8217;ve become fond of thinking of objects as views over a more fundamental data structure (<a class="reference external" href="http://pythonpaste.org/webob/">WebOb</a> is strictly based on this pattern).  Methods are details of the implementation, but only the data can mean something to someone else.  At least this is the worldview you start to internalize when you think about REST a lot.  (My post <a class="reference external" href="http://blog.ianbicking.org/2008/01/15/documents-vs-objects/">Documents vs. Objects</a> is also about this.)</p>
<p>Arguable a plain-data-with-views world is just the <a class="reference external" href="http://blog.ianbicking.org/because-unanswered-problems-are-always-hard.html">dynamic-weak-typed</a> anti-pattern.  That anti-pattern is one where you get all the disadvantages of dynamic typing, and all the disadvantages of static typing, all in one ugly bundle.  Erlang&#8217;s records remind me of this anti-pattern.  Instead of dictionaries everything is a tuple, and getting a record is just syntactic sugar mapping record names to indexes &#8212; all in the context of a dynamically typed language where you could mistype a value and get strange output as a result.</p>
<p>The strong-static typing solution to the type problem involves complicated contracts, aka &quot;service descriptions&quot;, the stuff of WS-*, CORBA IDL, etc.  The strong-dynamic typing solution is that every object have an explicit type.  This is fine for things we all agree on: lists, dictionaries, bytes, numbers.  Sadly even a basic thing like unicode strings cause problems, as do dates, but at least those have straight-forward solutions (you add more basic types to the message format).  More complex types, like a domain object (e.g., a user record) are difficult.  Are they all just dictionaries?  Dictionaries plus special metadata?  XML namespaces address this problem in some ways, but are also the point at which XML starts to just piss people off and make them want to use JSON.  And for good reason, because XML namespaces force you to define entities and responsible parties very early on, possibly long before you know what you are actually trying to do.  Besides XML, are there other systems that aren&#8217;t just naive/unextendable (bencode, JSON) and are still basically dynamically typed?</p>
<p>This is the kind of thing I would really love to see <a class="reference external" href="http://codespeak.net/pypy/">PyPy</a> experiment with.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/06/09/thoughts-about-the-erlang-runtime/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Which way?</title>
		<link>http://blog.ianbicking.org/2008/06/08/which-way/</link>
		<comments>http://blog.ianbicking.org/2008/06/08/which-way/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 01:26:04 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Non-technical]]></category>

		<category><![CDATA[Politics]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/06/08/which-way/</guid>
		<description><![CDATA[
Do you believe the world is (a) getting better, or (b) getting worse?
Please explain.  Please, no more &#34;both/neither&#34; answers: choose just one

]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>Do you believe the world is (a) getting better, or (b) getting worse?</p>
<p>Please explain.  <strong>Please, no more &quot;both/neither&quot; answers: choose just one</strong></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/06/08/which-way/feed/</wfw:commentRss>
		</item>
		<item>
		<title>pdb in the browser</title>
		<link>http://blog.ianbicking.org/2008/05/16/pdb-in-the-browser/</link>
		<comments>http://blog.ianbicking.org/2008/05/16/pdb-in-the-browser/#comments</comments>
		<pubDate>Fri, 16 May 2008 18:03:22 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/05/16/pdb-in-the-browser/</guid>
		<description><![CDATA[
People have asked me a few times about evalexception and pdb &#8212; they&#8217;d like to be able to use something like pdb through the browser, stepping through code.
The technique I used for tracebacks wouldn&#8217;t really work for pdb.  For a traceback I saved all the information from the frames &#8212; mostly just the local [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>People have asked me a few times about <a class="reference external" href="http://blog.ianbicking.org/ajaxy-exception-catching.html">evalexception</a> and <a class="reference external" href="http://python.org/doc/current/lib/module-pdb.html">pdb</a> &#8212; they&#8217;d like to be able to use something like pdb through the browser, stepping through code.</p>
<p>The technique I used for tracebacks wouldn&#8217;t really work for pdb.  For a traceback I saved all the information from the frames &#8212; mostly just the local variables &#8212; and then let the user interact with that through the browser.  But with pdb you pause the application part way through waiting for user input, and the routine only completes much later.</p>
<p>While writing <a class="reference external" href="http://pythonpaste.org/waitforit/">WaitForIt</a> I played around with techniques to deal with very slow WSGI applications.  Not that hard, really &#8212; you launch every request in a new thread, and you manage those requests in an application of its own.  So I started thinking about pdb again, and it started seeming feasible.  Whenever the app reads from stdin it goes into an interactive mode, showing you what comes out on stdout and letting you add input to stdin.  It&#8217;s nothing specific to pdb really.</p>
<p>So, with a bit of hacking, I added it into <a class="reference external" href="http://pypi.python.org/pypi/WebError/">WebError</a> (which is an extraction of the exception handling in <a class="reference external" href="http://pythonpaste.org">Paste</a>).  To give the demo a try, do:</p>
<pre class="literal-block">
hg clone http://knowledgetap.com/hg/weberror/
cd weberror
python setup.py develop
# You need Paste trunk:
easy_install Paste==dev
python weberror/pdbcapture.py
</pre>
<p>What you&#8217;ll see is not polished, it&#8217;s just working, but since I mostly did it to see if I could do it, that&#8217;s good enough for me.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/05/16/pdb-in-the-browser/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The GPL and Principles</title>
		<link>http://blog.ianbicking.org/2008/05/06/the-gpl-and-principles/</link>
		<comments>http://blog.ianbicking.org/2008/05/06/the-gpl-and-principles/#comments</comments>
		<pubDate>Tue, 06 May 2008 18:08:14 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Politics]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/05/06/the-gpl-and-principles/</guid>
		<description><![CDATA[
For the most part by the time I finished writing my last article on licensing I had mostly convinced myself that the GPL isn&#8217;t a practical license for most projects.  That is, outcomes when using the GPL aren&#8217;t likely to be any better than outcomes using a permissive license, except for certain kinds of [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>For the most part by the time I finished writing my <a class="reference external" href="http://blog.ianbicking.org/2008/05/05/choosing-a-license/">last article on licensing</a> I had mostly convinced myself that the GPL isn&#8217;t a practical license for most projects.  That is, outcomes when using the GPL aren&#8217;t likely to be any better than outcomes using a permissive license, except for certain kinds of projects, mostly projects involving big faceless companies, and I&#8217;d just as soon avoid such projects anyway.</p>
<p>My own thinking on this has changed over the years in part because of a greater sense of humility about what I produce.  I&#8217;m really not that worried about people stealing my work because I don&#8217;t think that theft would be of much value.  But also because I realize that the value in software is not so much in the code as in the process.  The process is what is valuable, particularly for open source, and licensing doesn&#8217;t really address issues of process.</p>
<p>As an example, if I&#8217;m uncomfortable with how some member of an open source community is using the code, or the community, I will be much more effective by dealing with that head-on, talking with that member, or even confronting them if it&#8217;s really necessary.  If you give someone an unwelcoming attitude, they&#8217;ll probably go away.  The license doesn&#8217;t need to be your gatekeeper.  It&#8217;s not a particularly effective gatekeeper anyway.</p>
<p>Another change is perhaps a more reasonable valuation of code.  There was a time when people wanted to protect their intellectual property.  Even some non-software company might have gotten the idea that it should own the code it contracts someone else to write, under a proprietary license, so they could sell that software later.  That anyone would care to buy it was always an illusion, but the illusion is a little more obvious these days.</p>
<p>One value of the <a class="reference external" href="http://www.gnu.org/licenses/gpl.html">GPL</a> that I do want to acknowledge is its expression of <em>values</em>.  It makes this explicit:</p>
<blockquote>
<p>When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.</p>
<p>To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.</p>
</blockquote>
<p>But the GPL does more than just its text: adopting the GPL is a statement of principle on the part of the original authors, of the people who adopt the project, and of the people who later help maintain the project.  It is a statement that freedom is valued and that it is valued in a universal sense, not just in a personal or isolated sense.</p>
<p>This is implicit, not explicit, in the choice of license, but despite that I see this pattern in projects.  Projects that choose the GPL are more likely to engender a spirit of openness and sharing.  Not of the core project itself &#8212; both GPL and permissively licensed projects accomplish this just fine so long as they are properly maintained, and their success is far more related to how the project is managed than the licensing.  But I see the difference in the sofware that grows up around the project: extensions, complementary projects, documentation.</p>
<p>Maybe this is because of licensing.  The license filters the community, and the people who are left in a GPL project are all at least open to sharing.  But more than that, I think it puts people in the right state of mind to share.  The project feels more principled, the participation is based less on pragmatism and more on optimism.  And there&#8217;s always people coming into open source who haven&#8217;t really figured out why or what they want to get out of it.  Presenting them with the principles of Free Software influences their decision.  (This issue has <a class="reference external" href="http://www.gnu.org/philosophy/open-source-misses-the-point.html">caused some debate about terminology</a>.)</p>
<p>With all that said, you don&#8217;t need the GPL to present the principles of a project.  It&#8217;s certainly the easiest way to do so.  The GPL is shorthand for a rich set of principles and ideals.  But it&#8217;s shorthand for people who are already in the know.  The ideas need to be reiterated and explained and reconsidered to stay relevant.  I think a project might do more good with an explicit statement of principles.  With that in place the licensing might not matter so much.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/05/06/the-gpl-and-principles/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Governance</title>
		<link>http://blog.ianbicking.org/2008/05/05/governance/</link>
		<comments>http://blog.ianbicking.org/2008/05/05/governance/#comments</comments>
		<pubDate>Tue, 06 May 2008 04:08:30 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[Politics]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/05/05/governance/</guid>
		<description><![CDATA[
It occurred to me&#8230; Django is something like a dictatorship&#8230; or maybe an oligarchy.  At first it seems like Pylons is the same&#8230; but no.  Pylons is clearly feudal.  I lord over Paste, WebOb, FormEncode.  Mike Bayer lords over Mako and SQLAlchemy.  Ben lords over Routes, Beaker, and Pylons.
I suppose [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>It occurred to me&#8230; Django is something like a dictatorship&#8230; or maybe an <a class="reference external" href="http://en.wikipedia.org/wiki/Oligarchy">oligarchy</a>.  At first it seems like Pylons is the same&#8230; but no.  Pylons is clearly <a class="reference external" href="http://en.wikipedia.org/wiki/Feudalism">feudal</a>.  I lord over Paste, WebOb, FormEncode.  Mike Bayer lords over Mako and SQLAlchemy.  Ben lords over Routes, Beaker, and Pylons.</p>
<p>I suppose in all cases there is a certain amount of democracy, because there are no <a class="reference external" href="http://en.wikipedia.org/wiki/Serf">serfs</a>, and any individual is free to travel to any kingdom they like.  Well, at least among the open source kingdoms.  Without citizenship, and with no exclusiveness of ownership, with even property having largely disappeared, I suppose it&#8217;s inevitable that traditional metaphors of control and governance don&#8217;t really make sense.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/05/05/governance/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Choosing a License</title>
		<link>http://blog.ianbicking.org/2008/05/05/choosing-a-license/</link>
		<comments>http://blog.ianbicking.org/2008/05/05/choosing-a-license/#comments</comments>
		<pubDate>Mon, 05 May 2008 23:48:48 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/05/05/choosing-a-license/</guid>
		<description><![CDATA[
I thought I&#8217;d take some time to talk about licensing.
Licensing is something that F/OSS programmers talk about a lot.  There&#8217;s two major categories of licenses:

The GPL, aka Copyleft.  You must distribute source with your application, and users get full rights to the source code, including any additions you may make.
Permissive licenses, X/MIT, BSD, [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>I thought I&#8217;d take some time to talk about licensing.</p>
<p>Licensing is something that <a class="reference external" href="http://en.wikipedia.org/wiki/FOSS">F/OSS</a> programmers talk about a lot.  There&#8217;s two major categories of licenses:</p>
<ul class="simple">
<li>The <a class="reference external" href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GPL</a>, aka Copyleft.  You must distribute source with your application, and users get full rights to the source code, including any additions you may make.</li>
<li>Permissive licenses, X/MIT, BSD, etc.  These let you do pretty much everything.</li>
</ul>
<p>There&#8217;s also the <a class="reference external" href="http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License">LGPL</a>, which vaguely applies GPL-like terms to the original code, but is not &quot;viral&quot;.  LGPL originally meant &quot;Library GPL&quot; but was renamed to &quot;Lesser GPL&quot; because people automatically used it for libraries without considering what the license actually enforced.</p>
<p>How much do these licenses matter?  How should a person choose between these options?</p>
<p>First, the LGPL.  It has specific phrasing that makes some sense for C code, to distinguish between extending the library itself and using the library.  It doesn&#8217;t make much sense for other runtime environments.  Some people have tried to <a class="reference external" href="http://opensource.franz.com/preamble.html">clarify its meaning in other environments</a>, but I&#8217;m not sure if a clarification like that means much.  The ambiguity seems like the worst of all worlds.  People who are afraid of the GPL won&#8217;t use the software anyway.  People who act in bad faith can satisfy the terms of the license through trickery.  You don&#8217;t get any practical protection over a permissive license, and you get most of the stigma of the GPL.  The GPL has some success stories, places where source was actually released due to the terms of the license.  I don&#8217;t know of any similar success stories for the LGPL.  If you don&#8217;t want to use the GPL, just use a permissive license.</p>
<p>Then the question: GPL or permissive licensing?</p>
<p>For some time I&#8217;ve chosen a permissive license for my code.  But I&#8217;m not really advocating that, and every so often I throw out a little GPL code.  Underneath this is something of a disinterest in licensing.  I don&#8217;t think it means much.  If specifics of your license matters then something has gone wrong.  People are leeching code, and/or the community isn&#8217;t providing enough benefit to encourage participation.  I don&#8217;t believe that software has much intrinsic worth, and treating it like property doesn&#8217;t make that much sense to me.  Licensing treats software as property, which is why I see the relevance of licensing as a kind of disfunction.  But there is the outside chance that it&#8217;s really just a big project, or that the project is being participated in by rivals.  But nothing I work with is like this, and it&#8217;s pretty uncommon generally, and anyway those projects all have their licensing pretty much figured out.</p>
<p>The GPL does seem to serve a constructive purpose when rivals have to cooperate in some fashion.  It makes a kind of demilitarized zone where everyone has to work for the collective good.  But even this is a sign that you can&#8217;t trust the participants.  This is somewhat reasonable, because you can&#8217;t actually trust large corporations with faceless programmers working on the code.  But even that&#8217;s a kind of disfunction, because you can at least kind of trust large corporations with programmer employees who have a public face.  The individual programmers are going to be very uncomfortable participating in any kind of Machiavellian conspiracy.  Good open source projects are a coming together of individuals.  Institutions are not effective participants.  There are however scaling issues with individual participation: particularly that only a minority of developers are actually inclined to participate in this way.  An institution can pay someone to work on something they don&#8217;t care very deeply about, and that person can still do useful work.  But they won&#8217;t be part of the community.</p>
<p>Outside of this mediation of rivalries I&#8217;m not really sure what the GPL provides.  It protects users, because the terms of the GPL ensure that users get code.  It doesn&#8217;t actually ensure that code is made public, though it does give developer employees leverage to make their work public.  There&#8217;s some urban legends about the viral aspect of the GPL, but that&#8217;s really just bullshit.  Code doesn&#8217;t magically get relicensed just because there&#8217;s a little GPL in the mix.  The GPL police won&#8217;t show up at your door and confiscate your computers.  The only people who make those claims are GPL-haters like Microsoft.  Who should you trust: the FSF or Microsoft?  If you answered &quot;Microsoft&quot; then you need to get your head screwed on straight.</p>
<p>Unfortunately there is a stigma about the GPL, and there are competent developers that avoid all GPL software.  I find this frustrating, especially since I don&#8217;t actually care about licensing, and so this adds a point of contention that I don&#8217;t really care to pay attention to.  Some people in this situation then become GPL haters, because they feel like it&#8217;s all GPL&#8217;s fault.  But the GPL didn&#8217;t create the licensing situation &#8212; proprietary software started this.  Direct your hate where it belongs.  The GPL ain&#8217;t it.</p>
<p>If my libraries were GPL I doubt I could leverage that to make other people open source their code.  But I know I would alienate some people, and as a result I choose a permissive license because it&#8217;s just strategically advantageous.</p>
<p>Applications I think are different strategically.  You don&#8217;t just swap an application in and out like you might a library.  If you choose to use an application, then often the licensing is a secondary choice.  The licensing ultimately only really applies to extensions.  Libraries also have a different pattern of acceptance.  Stubborn GPL haters can in effect veto a library in many projects (this is because stubborn GPL haters are viral).  But in an application their influence is much smaller.  Developers concerns like architecture and choice of libraries are not what drives an application.  An application is driven by its functionality.  If you have a useful application then licensing tends to be a secondary concern.  The licensing tends to define the community in some sense as well, and as a result there&#8217;s a kind of opt-in consensus.  And I think the GPL in these cases really does create an environment of collaboration around extensions.  It has a real benefit.</p>
<p>This seems to be true empirically as well.  GPL&#8217;d libraries don&#8217;t tend to get very popular.  People will do <a class="reference external" href="http://harmony.apache.org/">crazy-big projects</a> just because of licensing issues.  GPL&#8217;d Applications seem to do quite well, with examples like WordPress, Plone, The Gimp, and even the Linux kernel, which is closer in structure to an application than a library.</p>
<p>I haven&#8217;t studied the GPL v3 very closely, but it seems useful to me.  Software-as-a-service has the potential to make the GPL irrelevant (especially for the kind of code I write), and could put the GPL in the same category as the LGPL where it retains its stigma without offering any practical advantages.  Version 3 makes the permission/GPL choice seem useful, but so far I&#8217;ve never made any truly conscious choice between version 2 and 3.</p>
<p>If you are thinking about choosing a license, or thinking about choosing software based on the licensing, maybe these thoughts will be helpful in your own thinking.  And please don&#8217;t GPL-hate in the comments, I&#8217;m not interested and if you feel the need then go write your own post.</p>
<p><strong>Update:</strong> I wrote a second article to expand on some thoughts: <a class="reference external" href="http://blog.ianbicking.org/2008/05/06/the-gpl-and-principles/">The GPL and Principles</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/05/05/choosing-a-license/feed/</wfw:commentRss>
		</item>
		<item>
		<title>&#8220;Something Must Be Done&#8221;</title>
		<link>http://blog.ianbicking.org/2008/05/04/something-must-be-done/</link>
		<comments>http://blog.ianbicking.org/2008/05/04/something-must-be-done/#comments</comments>
		<pubDate>Mon, 05 May 2008 05:50:49 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Non-technical]]></category>

		<category><![CDATA[Politics]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/05/04/something-must-be-done/</guid>
		<description><![CDATA[
Listening to Tavis Smiley&#8217;s show tonight, and the segment My America where they talked about gun violence.  At one point they quote a man who lost his brother to gun violence:

You can be in a club and bump into somebody on accident, a little of your liquor, a little of your water spill on [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>Listening to <a class="reference external" href="http://www.tavistalks.com/">Tavis Smiley&#8217;s show</a> tonight, and the segment <a class="reference external" href="http://www.myamerica2008.org/">My America</a> where they talked about gun violence.  At one point they quote a man who lost his brother to gun violence:</p>
<blockquote>
<p>You can be in a club and bump into somebody on accident, a little of your liquor, a little of your water spill on their coat, now, you go outside, he got five or six people out their because you spilled your damn drink.  Which, a person should be able to say, &quot;man, my fault dog, I apologize, you know how it is.&quot;  You got people that just ain&#8217;t gonna be right, man.</p>
<p><strong>Tavis Smiley:</strong> So you take that, you put guns into the equation, that changes mediation efforts dramatically.</p>
</blockquote>
<p>Several times they talk about how small matters of respect lead to violence.  The conclusion is that guns are the problem.</p>
<p>I don&#8217;t really know what to do with this.  In <em>my</em> life (and I suspect all of your lives) issues of respect do not lead to violence.  As a result I have a hard time thinking of this as a gun problem.</p>
<p>OK, so it&#8217;s a violence problem.  The other thing that gets me is there&#8217;s this strong undertone to this conversation that &quot;we aren&#8217;t doing enough.&quot;  This attitude is of course the norm for an NPR show.  But it&#8217;s <em>not</em> <strong>we</strong> &#8212; I, and everyone I know is not part of this <strong>we</strong>.  My &quot;we&quot; does not resort to violence.  My &quot;we&quot; does not project respect into minor social interactions.  When I say it&#8217;s not &quot;we&quot;, I don&#8217;t think it&#8217;s just that I tuned into the wrong radio show &#8212; am I being recruited into this &quot;we&quot;?  Do they really think listeners are part of this &quot;we&quot;?</p>
<p>There is no reflection in these shows about why <em>this</em> (whatever the issue of the show) is a general problem.  Of course most talk shows tend to generalize wildly, to turn every anecdote into a sign of some change in culture, some disease of our society, something more than just an anecdote.  (Though <a class="reference external" href="http://www.thislife.org/">some</a> <a class="reference external" href="http://thestory.org/">good</a> NPR shows do <em>not</em> attempt to generalize anecdotes at all.)</p>
<p>There&#8217;s a strong attitude, in this show and others, that this is a problem for us all to solve.  Why exactly is this a problem for me to solve?  Why is this a problem for government to solve?  (I&#8217;m not a conservative, but I feel it&#8217;s unfair that only conservatives seem to be able to ask that question: why should government solve this?)</p>
<p>I don&#8217;t ask these questions rhetorically (and maybe that makes me different from the conservatives, who tend to only ask questions rhetorically).  There may be a good answer to these questions.  But it&#8217;s far too easy to say &quot;we must do something about this&quot; without saying <em>who</em> and <em>why</em>.  We (especially those of us who listen to NPR) are all far too fatigued with the constant admonitions that not enough is being done, and something has to change.  This kind of approach is not an effective call to action.</p>
<p>And it&#8217;s yet another thing <a class="reference external" href="http://blog.ianbicking.org/2008/03/31/environmental-guilt/">trying to make me feel bad for something that&#8217;s not my fault</a>.  And dammit, it really isn&#8217;t my fault!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/05/04/something-must-be-done/feed/</wfw:commentRss>
		</item>
		<item>
		<title>WebOb Do-It-Yourself Framework</title>
		<link>http://blog.ianbicking.org/2008/04/17/webob-do-it-yourself-framework/</link>
		<comments>http://blog.ianbicking.org/2008/04/17/webob-do-it-yourself-framework/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 06:21:03 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/04/17/webob-do-it-yourself-framework/</guid>
		<description><![CDATA[
My old do-it-yourself framework tutorial was getting a bit long in the tooth, so I rewrote it to use WebOb.  Now: the new do-it-yourself framework.

]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>My old <a class="reference external" href="http://pythonpaste.org/do-it-yourself-framework.html">do-it-yourself framework</a> tutorial was getting a bit long in the tooth, so I rewrote it to use <a class="reference external" href="http://pythonpaste.org/webob/">WebOb</a>.  Now: <a class="reference external" href="http://pythonpaste.org/webob/do-it-yourself.html">the new do-it-yourself framework</a>.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/04/17/webob-do-it-yourself-framework/feed/</wfw:commentRss>
		</item>
		<item>
		<title>App Engine and Pylons</title>
		<link>http://blog.ianbicking.org/2008/04/13/app-engine-and-pylons/</link>
		<comments>http://blog.ianbicking.org/2008/04/13/app-engine-and-pylons/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 17:32:06 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/2008/04/13/app-engine-and-pylons/</guid>
		<description><![CDATA[
So I promised some more technical discussion of App Engine than my last two posts.  Here it is:
Google App Engine uses a somewhat CGI-like model.  That is, a script is run, and it uses stdin/stdout/environ to handle the requests.  To avoid the overhead of CGI a process can be reused by defining [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>So I promised some more technical discussion of App Engine than my <a class="reference external" href="http://blog.ianbicking.org/2008/04/09/app-engine-commodity-vs-proprietary/">last</a> <a class="reference external" href="http://blog.ianbicking.org/2008/04/09/app-engine-and-open-source/">two</a> posts.  Here it is:</p>
<p>Google App Engine uses a somewhat CGI-like model.  That is, a script is run, and it uses stdin/stdout/environ to handle the requests.  To avoid the overhead of CGI a process can be reused by defining <tt class="docutils literal"><span class="pre">__main__.main()</span></tt>.  But while a process <em>can</em> be reused, it might not be, and of course it might get run on an entirely separate server.  So in many ways it&#8217;s like the CGI model, with a small optimization so that, particularly under load, your requests can run with less latency.</p>
<p>This part is all well and good.  I&#8217;ve already come to terms with servers going up and down without warning.  But the environment itself has a number of other restrictions.  It seems that App Engine is providing security in the language itself.  The interpreter has been modified so that code is sandboxed, with no ability to write to the disk, open sockets, import C extensions, and see quite a few things in its environment.  It&#8217;s these things that are a bit harder to come to terms with.</p>
<p>While they claim it supports any Python framework, these restrictions don&#8217;t actually make it easy.  So for the last few days quite a few of us have been hacking various things to get stuff working.</p>
<p>The first thing people noticed is that <a class="reference external" href="http://www.makotemplates.org/">Mako</a> and <a class="reference external" href="http://genshi.edgewall.org/">Genshi</a> didn&#8217;t work, because they use the <a class="reference external" href="http://docs.python.org/lib/module-compiler.ast.html">ast</a> (via the <a class="reference external" href="http://python.org/doc/current/lib/module-parser.html">parser module</a>) to handle the templating, and that module has been restricted.  Apparently arbitrary bytecode is not safe in this environment, and so anything that can produce bytecode is considered dangerous.  From what I understand Philip Jenvy has been working on Mako and the trunk is currently working.  He&#8217;d already been doing work to get Mako working on Jython, which had similar issues.  Genshi is <a class="reference external" href="http://genshi.edgewall.org/wiki/AppEngine">also in progress</a> and fairly close to working, though with some missing features.  Genshi has the harder task as Mako was primarily reading the ast, while Genshi was writing it.</p>
<p>The first thing <em>I</em> noticed is that Setuptools doesn&#8217;t work.  I&#8217;m flattered that one of the only 3 libraries included with App Engine is <a class="reference external" href="http://pythonpaste.org/webob/">WebOb</a>, but of course I am more enamored of a rich set of reusable libraries.  Setuptools didn&#8217;t work because several modules and functions have been removed &#8212; this like <tt class="docutils literal"><span class="pre">os.open</span></tt>, <tt class="docutils literal"><span class="pre">os.uname</span></tt>, <tt class="docutils literal"><span class="pre">imp.acquire_lock</span></tt>, etc.  Some of these are kind of reasonable, while others are not.  The removal of many functions from <a class="reference external" href="http://python.org/doc/current/lib/module-imp.html">imp</a> doesn&#8217;t really make sense, for instance (I think the motivation was the difficulty of auditing the <em>implementation</em> of those functions, not that the functionality itself is dangerous).  And while some functions can&#8217;t be used in the environment, the fact you can&#8217;t <em>import</em> those functions is more problematic.  For instance, The Setuptools&#8217; <tt class="docutils literal"><span class="pre">pkg_resources</span></tt> module has support to unzip eggs when they are imported.  App Engine doesn&#8217;t support importing from zip files at all, and you certainly can&#8217;t unzip to a temporary location.  But withoutthe necessary modules and objects pkg_resources won&#8217;t even import.</p>
<p>To work around this I started a new project: <a class="reference external" href="http://code.google.com/p/appengine-monkey/">appengine-monkey</a>, which adds several monkeypatches and replacement dummy modules to the environment to simulate a more typical environment.  It&#8217;s just a small list so far (mostly in <a class="reference external" href="http://appengine-monkey.googlecode.com/svn/trunk/appengine_monkey.py">this module</a>), but I expect as people experiment with other libraries the list will increase.  For example, I would welcome implementations of things like <a class="reference external" href="http://python.org/doc/current/lib/module-httplib.html">httplib</a> on top of <a class="reference external" href="http://code.google.com/appengine/docs/urlfetch/">urlfetch</a> in this library.  (Implementing httplib and stubbing out parts of socket would probably make <a class="reference external" href="http://code.google.com/p/googleappengine/issues/detail?id=61">urllib run</a>.)</p>
<p>But the good news is that Pylons is pretty much working on App Engine, as is Setuptools and you can manage your libraries using <a class="reference external" href="http://pypi.python.org/pypi/virtualenv">virtualenv</a>.</p>
<p>The instructions are all located in the <a class="reference external" href="http://code.google.com/p/appengine-monkey/wiki/Pylons">appengine-monkey Pylons wiki page</a>.  Please leave comments if you have improvements or problems with that process.  I also welcome contributors and developers to the project itself &#8212; this is a project for expediting App Engine development, it is not a project I care to champion or control.  Or support to any large degree.</p>
<p>One ticket which is rather important is the apparent <a class="reference external" href="http://code.google.com/p/googleappengine/issues/detail?id=161">maximum number of files and blobs: 1000</a>.  Libraries involve lots of files, and the base Pylons install is only barely under this limit.  Now I just wish I could <a class="reference external" href="http://code.google.com/p/googleappengine/issues/detail?id=18">use lxml</a>, but that&#8217;s probably going to be a long time coming.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2008/04/13/app-engine-and-pylons/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
