Archive for the 'Programming' Category

LIFA: Python packaging

2011-02-13 / 11:56 /

Next in the continuing series of Lest I Forget Again–in which I blog things that I should know but keep forgetting–installing the Python packaging tools.

As of February 2011 it looks like distribute, pip and virtualenv are the tools of choice.

Below is what I did for the combination of Windows 7, cygwin and the Windows (not-cygwin) binary release of Python 2.7. If you want real instructions you should check out The Hitchhiker’s Guide to Packaging (THGTP), especially the section on installation.

Install distribute

distribute includes setuptools and easy_install which you need to install pip. This is as easy as.

$ wget
$ python

This downloads the distribution archive to a temporary folder and installs it so you don’t even muddy up your cwd. You’ve now got the distribute in your Python Lib directory and easy_install.

Install pip

pip can be installed directly by easy_install.

$ easy_install pip

I extracted the tar by hand because I’d already downloaded it, but for future use easy_install is a better bet since it will get the latest version.

pip also comes built in to virtualenv (see below) but I prefer to install it standalone.

Install virtualenv (optional)

Several packages I need (e.g. cx_Oracle) don’t install via pip so virtualenv isn’t as handy for me. Still a nice idea for apps that you plan to ship, I used it for some pre-pyramid pylons stuff.

So cx_Oracle installs easiest as a binary package against a Python Windows binary. But since cmd is awful, I only ever run bash on cygwin. Unfortunately this combination of Win32 Python running on cygwin leads to a bug in virtualenv: it doesn’t install the activate script.

Last year I wrote a patch to go with the bug but this time I wanted to try the power of distributed source control so I made a BitBucket patch queue (read more about Patch Queues here).

$ hg qclone
$ cd virtualenv-cygwin32
$ hg qpush -a
$ python install


Another chance to work with me!

2010-04-07 / 16:32 /

Precision Therapeutics, Inc: Job Description

Job Title: Informatics Intern
Department: Informatics

The Opportunity

Precision Therapeutics, Inc. is a diagnostics services company dedicated to providing physicians and patients with actionable clinical information to personalize cancer treatments. We are currently seeking an Informatics Intern.

Duties and Responsibilities

(Include the following: other duties may be assigned)
The goal is to do a thorough investigation on the best way to measure in vitro chemosensitivity generated by ChemoFx assays. Traditionally the two major schools of thought are IC50 and AUC of the dose-response curves. Due to the special features of the curves from ChemoFx assays (e.g. non-monotone, resistant lines do not respond, non-sigmoidal), there are some AUC derivative metrics (such as aAUC, tAUC) that are intended to account for the curve characteristics that are not captured by AUC. However, it has been unclear which measure is the ‘best’, and it is difficult not to pre-specify this in a protocol.

The current thought is that this research involves two components. (1). Mathematically, what is the optimal way to quantify a dose-response curve from in vitro assays? This step involves the combination of mathematical models AND the knowledge of in vitro biology (especially w.r.t. how ChemoFx is setup). Both parametric models (such as logistic regression model, polynomial model; as well as the choice of IC50, IC25, etc) and non-parametric models (e.g. AUC and its derivatives, smoothing spline) need to be considered. (2). Use clinical data that have already demonstrated the ‘link’ between ChemoFx assay and clinical outcome to compare the performance of different metrics. This can be achieved by in-sample cross-validation approaches or by using multiple independent datasets.


Education requirements

  • Graduate student with 2 years towards PhD in Statistics


  • No prior working experience is needed

Required Skills

  • R and/or SAS programming
  • Good communication skills and writing skills
  • Able to perform statistical simulations

Preferred Skills

  • Knowledge of prediction and cross-validation
  • Knowledge of non-linear regression and model fitting, especially the 4-parameter logistic regression model for dose-response curves
  • Knowledge of area under the curve (AUC) calculation

If you are seeking a dynamic, challenging atmosphere, that is never boring, with a chance to make a difference and help cancer patients, email your resume to with the word “Informatics Intern” in the subject of the email

I didn’t write the posting, but feel free to ask me questions.

wdired-change-to-wdired-mode, because otherwise I will forget again

2010-03-15 / 18:32 /

In a Dired buffer in Emacs 22, use ‘M-x wdired-change-to-wdired-mode’ to to make a buffer writable (recent CVS versions also have this bound to ‘C-x C-q’). Change the filenames as you see fit and hit ‘C-c C-c’ to make your changes permanent.


File under
I wrote this blog post just so I can easily find this next time I forget
Also under
Stuff you should know if you ever need to rename a bunch of files in emacs and hate having to remember the dired key-bindings.

UPDATE: …Or just make it real easy and bind it to the “e” key.

Is cygwin a ghetto too?

2009-10-14 / 13:00 /

We all know Windows is a ghetto (at least for developers); I just googled for confirmation. Unfortunately I’m stuck there because of work and have been using cygwin to make things easier.

Unfortunately I’m beginning to think cygwin is a ghetto too. You can compile some source, but there are enough differences to be annoying. Specifically you can’t compile libraries to link against other windows apps (like for Python & Haskell libraries) and the path wrangling & soft links break in any native app. It’s only nice if you don’t leave it’s confines.

So maybe a better analogy would be that cygwin is like having a really nice loft in a bad neighborhood.

In contrast MinGW seems more interested in making Windows habitable. Maybe it’s like bike paths & community gardens?

Anyone have any experience with MinGW? I think all I really need is the GCC tools, ssh and bash.

PS: and yes I’ve thought about VMware, etc. But I have to release under Windows anyway, so there’s no point having to maintain two environments. I do have an Ubuntu laptop but I never end up using it.

The environment shouldn’t be, part 2…

2009-10-13 / 12:30 /

…in which all I want to do is read and write some goddamn ID3 tags.

I’ve said I want to learn Haskell but I’ve also talked about the pains of learning new programming environments (and given an example from Forth). So when I wanted to rename some mp3 files based on ID3 tags I thought “that’s a great excuse to use Haskell! What could possibly go wrong?” So I simply…

  • install the Haskell Platform
  • check Hackage for ID3 libraries
  • cabal install taglib. FAIL: requires taglib_c C library
  • download the Windows MSVC binary and copy to correct dirs under c:\cygwin\usr\local\
  • update environmental variables according to the Cabal help pages. FAIL: still can’t find package
  • use cabal install --verbose=3 taglib to find out it’s failing calling pkg-config
  • remove MSVC binary of taglib_c
  • try building taglib_c from SVN tip. FAIL: no configure
  • try IDiii: cabal install idiii. FAIL: error installing encoding-0.6.2 dependency
  • back to TagLib: download tarball & install. Success.
  • add PKG_CONFIG_PATH='c:\cygwin\usr\local\lib\pkgconfig' to environment
  • cabal install taglib. FAIL: the .pc files for taglib contain cygwin style paths
  • rebuild taglib_c with --PREFIX=c:/cygwin/usr/local. Success: installed in same directory but with Windows style paths in the .pc files
  • cabal install taglib. Success!
  • run TagLib’s included test code (nice touch, btw). FAIL: can’t find DLL
  • try renaming DLL’s & rerunning test. FAIL: finds DLL’s, can’t link. Suspect this is because GHC is built with MinGW
  • uninstall source-built taglib
  • install taglib’s MinGW binaries, including copying & modifying source built .pc files
  • cabal install --verbose=3 --reinstall taglib
  • re-run test code. FAIL: can’t link because of duplicate symbols in bytestring. WTF?
  • test in ghci. FAIL: can’t find DLL
  • rename DLL’s… FAIL: can’t link to DLL
  • uninstall MinGW taglib
  • try MSVC taglib once more for fun. FAIL: can’t find/link to DLL’s

So I’ve got no ID3 library a broken GHC installation. Next stop: mailing list. But first…

Let’s try that in Python

I wish I could say it was sooo much easier in Python, because that would mean I was done. Instead…

A few dozen lines of code and a few Unicode issues later and I am automatically renaming files based on ID3 tag.

Unfortunately the next step is automatically tagging files based on filename and id3reader doesn’t write tags. This is why people write their own libraries.

So what’s the point

Nothing really. I just wanted to complain. Also people often ask me what it’s like to be a programmer. Sometimes, this is it. My advice: stay in business school.

Victoria, oh Victoria: part 5 (oh right, there was a conference)

2009-09-23 / 12:08 /

4 and a half months later, the thrilling conclusion.

2008-09-25 (Thursday) – 2008-09-27 (Saturday)

Oh right, I came here for a reason. Both DEFUN & CUFP were good. The functional community seems really nice (and smart). Basically everything else I said a year ago.

Then on the walk back I saw the Pandora draw bridge in action. Score!

Drawbridge in action (Pandora Ave)

2008-09-28 (Sunday)

Then I flew home. The End

Polyglotism: not over your head, just overhead

2009-08-07 / 16:05 /

(A comment gone long, I decided to turn this into its own post)

The reality, though, is that we all do polyglot programming all the time. We use command line scripting languages to simplify our lives, and build languages to manage repetitious build processes. In the sphere of web development, we’re regularly working with regular expressions, JavaScript, and declarative languages like XML, CSS, and SQL (or its derivative, HQL). It’s exceedingly common to see jobs looking for developers who can write both an ActionScript front-end and a JVM back-end (Grails, Roo, whatever). I worked at a shop where we used perl for file processing and fed those into a database, just to be consumed by Java batch process. One gig had service calls from Java to .NET in order to interoperate with Microsoft Office products. In none of these cases did the architects sit around and go, “Oh, man, we can’t implement that solution: people are just too stupid to handle it.”

Robert Fischer, We Aren’t Too Stupid for Polyglot Programming

I think Robert’s absolutely right in that we use many languages all the time, the questions are 1) why and 2) is it the right thing to do.

In my experience, polyglotism falls into a few patterns:

  1. Low level + scripting language driver (C + Lua)
  2. Frontend + Backend (Web)
  3. Core product + automation (Make, perl)
  4. Well establish DSL + general language (SQL, regexps)

In all cases polyglotism provides some obvious benefit. For the first two, that benefit is that it allows the project to work. If Lua were fast enough and Ruby ran in the browser… For #3: mixed language automation is an artifact of low-level languages. Make is a good build tool for C but Ruby’s build tool is Ruby (Rake). Given a change in technology and the right language, these could all be monoglot.

In the last case the DSL’s are chosen for convienence: SQL is better than hand B-tree manipulation and regexps better than FSA‘s.

Using multiple languages isn’t without cost. An obvious one is that learning languages is hard. Most developers know SQL but how many are good at tuning queries? Knowing a language also isn’t the same as fluency. Until you’re fluent in both languages, you’re likely to favor one. See the object/relational–not to mention FP/OOP–divide for examples.

There’s also the technical costs in translating data. XML, Protocol Buffers, Thrift, etc. are all valid interchange formats, but they’re not free. Robert’s emphasis on JVM languages does ease this hurdle, since I believe all the JVM languages can pass objects.

Finally there’s the cost of tools & debugging. You now need tooling–compilers, debuggers, syntax-aware editors–for several languages. More languages can lead to more complexity. Making matters worse, error messages across language boundaries are often cryptic, even when both languages are on the JVM.

So should we all be polyglot? As a matter of personal improvement, I’m all for learning new languages & techniques. But in terms of actually writing good software quickly, it probably only applies if

  • There’s obvious, quick benefit
  • There’s a clear separation
  • None of the other costs are too high

Personally, I think the big efficiency gains are in monoglot solutions. In the web world, glot-supremicists–i.e. Lisp and Smalltalk–have come up with some interesting web frameworks. Polyglotism is a fallback when abstractions leak.

A fistful of papers

2009-08-07 / 12:55 /

Like many dilemmas, this one results from either/or thinking. A third alternative is to try both methods in parallel and just use whichever result arrives first.

Conal Elliott, Simply efficient functional reactivity [PDF]

Peter Van Roy’s excellent Programming Paradigms for Dummies: What Every Programmer Should Know [PDF] lead me to reread–or I suppose “read instead of just skim”–Conal Elliott’s 2008 FRP paper. It’s interesting, but a little too wrapped up in Haskell type insanity for me understand deeply. I did like the above quote though, it’s such a simple reminder that multicore is changing programming.

Speaking of changing programming, Optical information processing in
Bose–Einstein condensates [PDF]
is a great paper by Dr. Lene Vestergaard Hau. You may remember Dr. Hau from 1999 when she slowed light to 38 mph and from 2007 when she transformed light into matter and back again. Smart cookie, that one.

She’s got more papers on her lab web page.

Are you a software tester looking for a job? You can work with me!

2009-05-29 / 16:43 /

Feel free to email me if you’ve got questions.

Title: Software Test Engineer

The Opportunity

Precision Therapeutics, Inc. (Precision) is an applied sciences medical laboratory located on the South Side of Pittsburgh. Precision assists oncologists in choosing effective cancer therapies for cancer patients. We are currently seeking a Software Test Engineer to join the Precision team.

Duties & Responsibilities

Precision is seeking a highly motivated person to fill the Software Test Engineer position. The successful candidate for the position will join a talented team of ‘A player’ technology and biology professionals in the development of hardware and software systems designed to personalize cancer therapy treatment on an individualized patient basis.

This position is within the Technology Development Department and will report to the Software Release Manager. The successful candidate will maintain and monitor verification and validation activities within the Technology Development Department. The scope of position includes verification and some validation of all software applications and automation hardware that support other corporate departments, including: the clinical laboratory, records management, clinical trials, customer service, billing, sales, and accounting.

The responsibilities of the Software Test Engineer will include working with developers and users to verify and validate software requirements, assess risk, enforce change control, assist and monitor the creation of test plans and test cases, create automated test scripts, and execute test cases during phased releases. The position will be empowered to reject deployment of any software change that has not completed the change control process.
Specific duties include: Requirement reviews and validation, change control, risk assessment, documentation reviews, test case authoring, unit, integration, and system verification, code reviews, occasional test team leadership, and providing daily/weekly test status data to management for corporate project tracking.

If you are seeking a dynamic, challenging atmosphere, which is never boring, and a chance to make a difference and help cancer patients, email your resume to with the words Software Test Engineer in the subject of the email.



  • Bachelor’s degree in computer science, engineering, or a related discipline. Master’s degree preferred


  • 3+ years Software Testing experience in a process-driven, web-based software development environment (Agile or risk-based preferred.)
  • 2+ years experience as a test case author and manual tester
  • 2+ years experience assessing requirements and technical specifications for completeness and accuracy
  • 1+ year(s) in a team leadership role mentoring new test team members
  • Served as a Test Engineer on one or more projects throughout the entire software lifecycle.

Required Skills

  • Excellent organization skills
  • Excellent writing skills with exceptional typing speed
  • Ability to rapidly document detailed test cases that are traced to functional requirements and engineering specifications
  • Ability to identify configurability and undocumented features for high-risk test opportunities
  • Ability to identify gaps in requirements, specifications, and documented test cases
  • Experience maintaining test documentation and traceability to changes in requirements and technical specifications.
  • Experience with documenting project Test plans and exit/acceptance criteria
  • Experience with manual test case execution techniques.
  • Experience evaluating risk associated with application changes
  • Ability to adapt to priorities that change frequently
  • Ability to justify the categorization of test cases. (Acceptance, Regression, Feature)
  • “Get it done!” attitude that strives to uphold commitments and stay on schedule
  • Working experience in a software development environment with formal software quality processes conforming to ISO, IEEE, or FDA QSR standards and guidelines
  • Understanding of web based application architecture and OOP concepts, specifically Java, Struts, JavaScript™, and HTML
  • Ability to trace data throughput using Oracle SQL queries and xml parsing tools
  • Experience writing automation scripts with Selenium IDE, Perl, or Python.
  • Familiar with Eclipse development environment, source control, and ANT targets
  • Ability to effectively describe anomalies in sufficient detail to reproduce the behavior
  • Ability to work independently or in small teams
  • Well developed and effective oral and written communication and interpersonal skills
  • Ability to effectively communicate technical concepts with non-technical end users
  • Proficiency with Microsoft® Office, Project, and Visio

Preferred Skills

  • Team leadership experience
  • Experience with process control and/or data acquisition
  • Knowledge of statistics and numerical methods
  • Experience with database design, development, and optimization

A principle for online discussion

2009-04-11 / 11:57 /

…Are you assuming malice or incompetence where none might exist?

Chris Winters, Bitter Discourse Indeed

Occasionally, and often related to language wars or Zed Shaw, the internet realizes that there is a stunning lack of online decency. A backlash occurs. In one of these exchanges I read a blog post–the source of which I’ve unfortunately forgotten–that crystallized my opinion: practice the principle of charity.

PS: Speaking of bitter discourse and moral codes, I highly recommend Doubt.

Sure it’s complicated, but it might also be important

2009-04-10 / 20:10 /

Because if it’s YOU who dies, smashed to death on the iceberg by your skunkweed-stoned ship captain, you’re going to be REALLY pissed off. I guarantee it.

Steve Yegge, Have you ever legalized marijuana?

The tl;dr crowd might summarize Steve Yegge’s latest article as “it’s harder than you think.” But that would miss the entertainment of Steve’ writing (see above). It would also miss the comments which, while not perfect, are good enough to summarize my opinion:

So yeah. Things are more complicated than you think. But if they’re important you figure it out and do what’s necessary.

And it’s obvious but bears repeating: the law != code.

Open source, network effect and Google; bad Photoshop

2009-03-20 / 12:45 /

Price & quality aside, an advantage of open source software is network effect: the more people are using a piece of software, the better the chance someone else has the same problem as you (and hopefully the sooner you’ll have the same solution as them). Not that open source itself causes the network effect, rather it’s the arms control treaty that allows competitors to contribute to shared code. So this New York Times’ article on Hadoop made me wonder how Google’s closed source infrastructure will play out.

Using closed source makes sense if the code would help competitors more than they would contribute back. Given that Hadoop was inspired by Google’s MapReduce paper [1] it seems like that was originally the case. But, to the article’s main point, Hadoop is now used by Yahoo, Microsoft, Facebook, Autodesk, numerous startups, etc… which is to say at least a few smart people. If you believe in the power of open source, this eats away at Google’s proprietary advantage.

Google could, of course, switch to Hadoop, either fully or via an in-house version (whose changes don’t have to be re-released since they’re not selling the software). Both require a cost, either up front or in ongoing merging. Alternately, they could simply adopt any ideas that seem worthwhile; at scale the coding cost is probably small compared to 1) developing the idea (necessary for any change) and 2) maintenance. According to the article, Google and IBM are are financing college-level Hadoop classes, so Google at least wants students to graduate understanding MapReduce theory and/or parallelism.

On an unrelated note, check out that photo at the top of the story. Was the guy on the right badly photo-shopped in or does he just not cast a shadow?

[1]: And, yes, I’m sure the idea of MapReduce has been around forever. It’s at least as old as functional programming; it’s probably somewhere in Backus’ classic [PDF] though I don’t feel like checking.

So you want to use PyX with Cygwin TeX and Windows Python…

2009-01-09 / 22:38 /

…er, actually that’s probably just me. My work laptop runs Windows for unfortunate corporate reasons. Cygwin staunches the bleeding, but the Cygwin build of Python has trouble with some packages (e.g. matplotlib and pymssql). So I’m running the cygwin shell but a Windows build of Python.

PyX–cool looking plotting/graphics tool–makes a subprocess call to kpsewhich to find files. The cygwin build of kpsewhich naturally returns a cygwin path; the windows build of python naturally chokes. As a hack, I edited /Python25/Lib/site-packages/pyx/pykpathsea/ to add a call to cygpath -w. I also replaced the os.popen calls with subprocess.Popen since os.popen 1) wasn’t working for me and 2) is deprecated.

The modified function:

    def find_file(filename, kpse_file_format):
        # 2009-01-08: DAG: edits to allow working with cygwin tex but windows
        # python.  Replaced os.popen with subprocess.Popen and added call to
        # "cygpath -w"
        command = 'kpsewhich --format="%s" %s' % (kpse_file_format, filename)
        if not find_file_cache.has_key(command):
            path = Popen(command, stdout=PIPE).communicate()[0].strip()
            if path:
                path = Popen('cygpath -w %s' % path, stdout=PIPE).communicate()[0].strip()
            find_file_cache[command] = path
        return find_file_cache[command]

The patch: pyx_cygwin.diff

The full file (zipped w/ path relative to Python25/Lib):


Progressive computing

2009-01-07 / 17:55 /

Conservative logic is a comprehensive model of computation which explicitly reflects a number of fundamental principles of physics…

Edward Fredkin and Tommaso Toffoli, Conservative Logic p. 1

Axioms for computation that are based on noninvertible primitives can only reflect aspects of macroscopic physics. While they offer enough expressive power for dealing in a formal way with what can eventually be computed by any physical means, they may deprive us of essential tools for discussing how best to compute in particular, whether and how the kT barrier can be overcome-since many relevant aspects of microscopic physics are totally out of their reach. To remedy these eficiencies, the axioms of computation must be told some of the “facts of life” of the microscopic world. This is one of the goals of conservative logic.

Edward Fredkin and Tommaso Toffoli, Conservative Logic p. 3

Via the LtU Inspiring papers thread comes Fredkin and Toffoli’s 2001 paper: Conservative Logic [PDF] (local cache since I couldn’t find an official site with a download; thanks to Strange Paths for having a copy of the PDF). The paper 1) presents a model of computation based on physics-inspired axioms, 2) demonstrates that the model is computationally universal and then 3) gives an example implemented using billiard balls. Well, technically perfectly elastic collisions of spherical bodies constrained to a 2-dimensional plane, but still fun.

It reminded me of Neil Gershenfeld‘s Programming Bits and Atoms talk. Specifically both changed my concepts of computation: Gershenfeld shows a bunch of examples of asynchronous logic automata (sorry for the crap link to a google index, I haven’t read enough to find a good reference; let me know if you find one) and also demonstrates physical logic gates built from plastic tubing and air bubbles. Given that Toffoli was cranking out papers in the late 70′s, I wouldn’t be surprised if Gershenfeld draws from his work.

Beyond the cool factor, both works have practical outcomes. Gershenfeld shows proof of concepts like the “paintable computer”: a computational surface that runs a Postscript interpreter. He also demonstrates a(nother) linear-time sorting algorithm that depends on the ALA property that transmission is also storage (cells store values, transmission is merely the passing of values down a chain of cells). Fredkin and Toffoli make no such claims, but since a primitive of Conservative Logic is the unit wire–an element that both stores and transmits a value–the same should hold.

Fredkin and Toffoli’s emphasis on conservative physics principles leads to another huge benefit: “The central result of conservative logic is that it is ideally possible to build sequential circuits with zero internal power dissipation.” Nice.

But, really, my interest is in the combination of computer nerdery with physics nerdery (I spent years doing integrals studying physics). This is the stuff inspires me when I feel like a programming career is nothing more than CRUD web interfaces; you might even say reading these papers prevents my architecture from sucking.

In a similar vein, I recommend The Feynman Lectures on Computation and Scott Aaronson’s blog. Aaronson’s blog is a cornucopia of technical things I don’t fully understand, including one of my favorite blog posts of 2008: Time: Different from space.

So you want to add a method to an existing Python object…

2009-01-06 / 15:22 /

While working on my goof-off POTM, I needed to add a function to an already instantiated object.

The obvious thing almost works:

>>> class MyClass(object): foo = lambda self: "Foo"
>>> myobj = MyClass()
>>> hasattr(myobj, 'bar')
>>> = lambda self: "Bar"
>>> hasattr(myobj, 'bar')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: <lambda>() takes exactly 1 argument (0 given)

Here’s the problem:

>>> type(
<type 'instancemethod'>
>>> type(
<type 'function'>

Our dynamically added bar is a regular function so the self-injection magic isn’t happening.

It turns out that the magic is actually just descriptors. As Bruno Desthuilliers points out you can manually activate the descriptor machinery:

>>> = (lambda self: "Bar").__get__(myobj)
>>> type(
<type 'instancemethod'>

For those who are more semantically inclined, you could instead use the (deprecated) new module:

>>> from new import instancemethod
>>> myobj2 = MyClass()
>>> = instancemethod(lambda self: "Bar", myobj2)

And if you want your semantics without the deprecation, use types:

>>> from types import MethodType
>>> myobj3 = MyClass()
>>> = MethodType(lambda self: "Bar", myobj3)

“Easy as cake!”

How Buildings Learn: RECOMMENDED

2008-11-24 / 22:57 /

How Buildings Learn front coverOn Daniel Burka’s recommendation (at MeshU) I checked-out a copy of How Buildings Learn from the Carnegie. Summary: RECOMMENDED.

In the book, Stewart Brand–of Whole Earth Catalog fame–looks at the evolution of buildings, a subject he claims is sorely under-researched. He first establishes his framework, the six S’s: site, structure, skin, services, space Plan, and stuff; and then outlines the major archetypes of buildings: high-road (cathedral), low-road (warehouse), and hollow-souled sell-out architectural-digest pornography (most everything else, incidentally it was the high-road/low-road distinction that Burka used in his talk), Next he descends into detail. Finally he provides some hints for designing for change. And then, for emphasis, he re-states everything in the appendix and ends with a final plea for everyone to start paying attention to how things change in the long term, damnit.

University of Pittsburgh TowersLike anyone who’s learned software patterns, I know of the Christopher Alexander classic. But I put it off in favor of reading books about, well, software. How Buildings Learn frequently references Alexander’s works. It also shares a lot with software design: Brand advocates less up-front design, direct client involvement, choosing processes and artifacts that provide feedback and “short” iterations with rapid deliverables–basically Agile. (He also advocates spending time & money on a solid foundation and “documentation”: he lauds John Abrams “as-built” photo documentation. These could be interpreted as “anti-agile”, but as James Shore points out agile is no excuse for irresponsibility.) Unlike books on Agile software, How Buildings Learn benefits from being about something tangible: buildings. I spent my freshmen year in the University of Pittsburgh’s Litchfield Towers (picture above) and I currently work in a new office building that has the perfect triumvirate of leaky roof, non-function HVAC and architectural awards. It was easy to understand Brand’s examples. It took me much longer to actually understand–not just parrot–Agile. Such is the power of metaphor.

So recommended. Even if you’re not a programmer.

Adopting functional programming (or “Just why did people start using Python anyway?”)

2008-10-08 / 18:30 /

The end of CUFP 2008 was an open discussion that focused on–surprise surprise!–how to take functional languages mainstream. The future looks pretty bright to me: as Don Syme pointed out Microsoft is serious about F# and–although it got no love at ICFP–Clojure provides a functional escape for the JVM bound.

Of course availability is not enough: people also need a reason to switch. Many people brought up the “killer app”, the functional programming Rails. One functional language already has one: Erlang. Instead of db-backed webapps, Erlang makes it “easy” to create massive backends (hee hee). Francesco Cesarini, Nick Gerakines & Mark Zweifel (slides [PDF]) and Bob Ippolito (slides) all had commercial examples. Of course process oriented concurrency, no shared state and the OTP aren’t exactly an app… maybe “killer underlying philosophy and toolkit”?

Most other commercial users were either financial quants or small startups looking for their Paul Graham advantage (see the list of abstracts). All emphasized the enhanced productivity of functional programming. The quants were an interesting case. They are small groups within huge–and conservative–companies. Functional programming snuck-in around the edges. And once you have working code…

Hence the subtitular question: why did people start using Python? I don’t know of any killer Python apps. It’s just easy to code yet feels “solid”: it’s got unit testing frameworks, test coverage tools, documentation extractors, a REPL, a package manager, etc. Knowing that smart developers are writing tools for Python is pretty reassuring. (So is having Guido work for Google.)

Haskell feels solid. GHC is easy to install and comes with an interpreter (though not quite a REPL, which still bothers me). Hackage and cabal-install handle package distribution. And there are enough developer tools: QuickCheck, HUnit, HPC, Haddock, etc. It even has an Emacs mode.

All that is to say that from my “I work for a small group within a small company and can get away with a lot” point of view, Haskell is ready. All I have to do now is decide if it’s easy… and then produce some working code.

PyComparable: you probably don’t need it

2008-10-04 / 18:02 /

This thread tangentially brought up the fact that Python doesn’t automatically generate __ne__ (called by !=) from __eq__ (==).

Madness ensued.

In a libertarian spirit, I hacked out a class decorator to add rich comparison methods. Then I forgot all about it. Then I was bored on a plane flying back from Victoria. Now I present to you…


PyComparable is a Python package to add rich comparison methods to a class. The name is based on Ruby’s Comparable mixin, though it turns out to be a bad name. Ruby’s Comparable defines rich comparisons based on the <=> method, something Python already does. PyComparable is instead intended for when you have some rich comparison methods and want to generate the rest. (Of course, this hardly ever happens which is why you will probably never ever need PyComparable. Oh well.)

It’s also not really meant to be used as a mixin (though I provide ComparableMixin and ComparableMetaclass for your pleasure). Instead it’s a designed for future use as a class decorator: the comparable function takes a class as an argument, adds the methods, and returns a new class.

You can get more details in the README.

PS: It looks like this was done back in January 2007. Unfortunately, the link was dead.


There’s also an ActiveState recipe that takes a slightly different approach. It assumes the objects being compared are “reflective” (I doubt that’s technically correct): it relies on reversing the operands. The upshot is that it only requires you to implement one comparison method. PyComparable requires two comparison methods, but never calls a method of the right hand side operand.

Oh, and there’s the fact that neither will work in Python 2.6 or 3. Doh!

Chromium build: I FAIL

2008-10-01 / 16:44 /

I was getting ready to blog a bit about attending DFUN and CUFP–both co-located with ICFP–and noticed I had this draft sitting around. I was hoping to send it out as a “ha ha, look how hard it was to build Chromium, but now it’s working!”

But now, it’s a “ha ha building Chromium was so hard, er… I failed!”

So folllow along won’t you on my trip to FAIL

  • Following Google’s Win32 build instructions, download Google’s depot tools [ZIP] & install in C:\depot_tools (blah)
  • Follow directions to get version of source
  • Download & install Visual Studios Express 2005 (C++)
  • Download & install Visual studios service pack 1
  • Download & install Microsoft SDK for Vista
  • Run Start Menu -> Microsoft Windows SDK -> Visual Studios Integration
  • Download & install Microsoft SDK for Server 2003 (to get ATL; Server 2008 won’t run on Express 2005)
  • Run Start Menu -> Microsoft Windows SDK for Windows 2003 R2 -> Visual Studios Integration (since order of integration may matter)
  • Since the above didn’t work, add paths as per this help forum thead
  • Also add C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\atl
  • Disable exception config as per this thread
  • Re-order includes as per this thread
  • Make WTL changes (hey, why not) as in this this post
  • Ask work for a full-blown copy of VS2005. Get handed a copy of VS2003.
  • Go back and get a stack of MSDN discs. Find out it’s got the MSDN libary, SQL Server developer edition and… a bunch of little utilities
  • Throw up your hands and fly to Victoria for a week of hiking and 3 days of functional programming immersion. Ahhh…

If you are interested in building Win32 Chromium with free tools you might want to follow this thread on building Chromium with Visual Studios 2005 Express. I assume someday it will work.

The obligatory Chrome backlash

2008-09-13 / 19:40 /

Since waxing poetically about chrome, I’ve hit a few more snags. So now… THE BACKLASH!

A futile search

Chrome find example

“Find in page” doesn’t search text I entered! So when I’m, say, editing my WordPress posts, I can’t search within the edit box. I know, I know another reason to actually get APP working

This turns out to be a known bug with WebKit: Bug #269

The problems with bookmark keywords

I loved Firefox’s bookmark keywords. If you’re not familiar, you basically assign a keyboard shortcut for a bookmark. For instance I assigned “rlike” to the Reddit upvote bookmarklet so I could vote without touching the mouse (well, mouse nub on the Thinkpad). It’s Ubiquity lite.

Chrome separates bookmarks (static, no keywords) from “Search Engines”, which seems like a strange design decision. I’d prefer them to be integrated or to at least allow the magic Omnibox to search through your local bookmarks. It is the Omnibox after all.

Adding search engines also has some problems. Primarily, { isn’t allowed, which pretty much kills javascript bookmarklets. The second is a minor UI issue: there’s no quick visual feedback for failed input. Hence:

  • Bug 2238: Add search engine dialog doesn’t allow “{” (open curly brace); can interfere with javascript
  • Bug 2239: Add Search Engine dialog: green checkmark icons indicate success even for failed input

Well do something about it

Turns out Chromium doesn’t build under Visual Studios Express, but that’s an ordeal for another post.