Libraries are a part of language's expressiveness. A language can be compressible and foldable, but if it doesn't have the right libraries, you'll write more code than you have to. Therefore, when you select a language for a project, emphasize libraries.
I don't think Python is a particularly expressive language. It has crappy broken lambdas, no syntax for arbitrary anonymous functions, no currying, no encapsulation, no overloading, no macros, and no regular expression syntax and lame string interpolation. As a scripting language I think Ruby is a whole lot better, and as an application language I think Scala trumps them both. But I'm using Python right because it has the libraries I need. Library beats language feature.
For large do-it-yourself projects it's the opposite: language beats library, because if you're going to be writing your own libraries, you don't want to pay a large language tax while you're doing it. Steve Yegge has talked about the enormous 1/2 Million line game he wrote, and he wishes he'd chosen a more expressive language than Java -- code size becomes a maintenance hazard; the less code you have the happier you'll be, and that is the foremost reason for picking an expressive language in large projects such as his: to avoid paying the language tax and to avoid producing a monstrously large code-base. Languages that support lots of higher order features like Scala or Ruby let you compress your code and factor out syntactic patterns (like for-each) which are intractable in languages with out higher order functions. In such languages, the control structures that come with the language are all that you're going to get, whereas in Scala or Ruby there's syntax for writing your own 'foreach', or you own 'do_times', or your own 'synchronized' etcetera.
Most of the projects I've worked on have not been more than a few thousand lines, ever; and that is because I've made extensive use of libraries and avoided writing thing myself. On that basis I will choose an anemic language like Python or (god forbid) Java if that's what it takes to get things done. Thankfully, I rarely have to choose Java anymore because there are so many other better languages on the JVM which can seamlessly interop with old Java code; but as in the case of Python, I still have to occasionally make the hard choice between a richer platform, or a richer language. And I choose a richer platform almost all of time: with the one exception of (as I said) large do-it-yourself projects for which you do not want to have to pay the language tax.
Saturday, February 7, 2009
Subscribe to:
Posts (Atom)
