It's hard to pick out trends in the industry because most things that we would call trends are really swings of a pendulum. This was brought home to me a few months ago when I was sitting across a table from someone who told me that the problem with IT is that we just don't have enough meta-data. If we had meta-data for everything, all of our problems would go away. I tried to tell him that this had been attempted number of times in the software industry and that it was quixotic - sort of like programming in pictures. But memes rise and fall. We each have to learn the hard way that the light you see from a distance isn't always as illuminating as we expect once we get to it.
Recently, another meme has been on the rise. The meme I'm talking about is the notion that code becomes better as it approaches English. I'm seeing this in a couple of different places now. One is the Domain Specific Languages community. While it's true that DSLs don't have to become English-like, there are a quite a few people who try.
The Behavior Driven Development (BDD) community also tends toward English-esque readability. Here is an example in rspec from Luke Redpath's blog:
specify "should be invalid without a password" do
@user.email = 'joe@bloggs.com'
@user.username = 'joebloggs'
@user.should_not_be_valid
@user.password = 'abcdefg'
@user.should_be_valid
end
It's fine, it reads like English. But, is that good?
I think that, fundamentally, we have at least two different ways of understanding text. One is narrative and the other is symbolic. In the narrative mode, we are approach text like prose and read through it the way we would read through English or any other natural language - it tickles the verbal centers of our brain. The symbolic mode is more visual. It helps us understand code like this even if we would fumble when giving a verbal explanation:
primes = sieve [ 2.. ]
where
sieve (p:x) = p : sieve [ n | n <- x; n mod p > 0 ]
We have to decode it, but the decoding is often swift and more precise than what we are used to with natural language.
I like to see narrative approaches in tools that can be user facing, like rspec's Story Runner, and FIT's DoFixture, but in code written by and for developers, I have mixed feelings. This code:
5.days.fromTomorrow.at(2.am)
reads very well, and it's hard to imagine a good symbolic alternative, but there are times when a symbolic approach can make code comprehension a breeze. The C++ iostream library is a good example. With the use of a couple of operators, much of the arcana of I/O is stripped away.
Ultimately, I think that some domains are more suited to the narrative approach than others but the criteria are tricky. On the one hand, if you are working in a domain like dates or scientific units, with settled definitions and nomenclature, it can pay to use a natural language style in your API. When definitions are settled, there is less of a chance that the machinery of a DSL will have to be refactored as much over time. On the other hand, once definitions are settled and well understood, you can eliminate a lot of cruft by moving toward a symbolic approach. The price, of course, is a steeper learning curve. It seems that there is a sweet point between those two poles and I have the sense that it might be narrower than we expect.
The narrative meme is rising. Many people are trying to write English in Java, C# and Ruby. I just hope that we learn where it is applicable and where it isn't. Natural language should not be the only direction we explore when we look for expressivity. Hopefully, after a few years, we'll walk away with a stronger sense of where natural language helps and hinders.

Comments (7)
Don't like the 5.days thing at all, its only advantage is reading like english, other than that it's a complete mess.
What's up with 5 days from tomorrow ? That's a completely unnessecary complication. Simplifying that yields 6 days from today.
I find it quite reasonable to have Today + 6 represent the day 6 days from now. It depends on the application offcourse, doesn't it always, but in many applications it makes sense to have Today represent the -start- of today (i.e. Today at 0:00), if that is so, the above can be written as:
Today + 6.days + 2.hours
Posted by Eivind | January 11, 2008 3:50 AM
As a reluctant coder (even as a computer scientist), I find the idea of English-like languages quite appealing.
The reality, however, is AppleScript, where code is easier (than Java, for example) to read, but significantly harder to code.
I'm looking forward to coding in pictures for real. Pass me the graphics tablet, I'm going in...
Posted by Ross McFarlane | January 11, 2008 5:08 AM
It's easy to forget that there was one massive attempt to make code read like English: COBOL. A great deal of work got done in Cobol, but I don't believe the results were very easy to live with.
Posted by Steve Freeman | January 11, 2008 5:11 AM
IMHO, it's all about maintainability. Unless you work completely alone, you need to write code that clearly explains itself to the next guy. Yes, this might be the job for comments, but I've cleaned up after l33t coders with undecipherable cleverness, and pedantic, long winded coders with 23 character variable names; I much prefer the latter.
-b
Posted by sporb | January 11, 2008 1:02 PM
I know this particular topic is quite subjective in nature but I prefer the narrative style of development.
I believe the goal is to create a reentrant code base for all members of the team. By authoring code in a narrative fashion makes it very easy to perform cursory overviews of a class definition and quickly ascertain the intention of what the code is doing. Intentions of the interface or method declarations are more soluble, provided the developer took the time to name it correctly. This lessens the friction later on as new developers enter the code base or old code is revisited. The narrative style of coding coupled with BDD style of specification produces pseudo documentation for the team which has the side of code coverage.
Posted by Joe Ocampo | January 11, 2008 5:58 PM
While reading I thought of the AppleScript examples as well. Very english, and a real pain to write because of it.
I have no problem with the 5 days from tomorrow one if that's how it is used in the domain.
I like just enough english to eliminate the ambiguity of what's being described symbolically. I get just enough english for my taste with good variable names.
One englishy thing I don't like is the 'a = true UNLESS something' type phrases. Englishy, but to me it requires I read a bunch of stuff only to find out I didn't need to. I prefer the conditional first. Always.
Posted by Greg Willits | January 21, 2008 4:23 AM
There must be a fixed syntax/way of writing or the readability will suffer tremendously.
You are forced to read the whole sentence to notice differences likes:
"should be invalid without a password"
and
"should be valid without a password"
Posted by Tom | January 24, 2008 9:43 AM