When I hear people start talking about “natural” programming, easier ways of programming or making programming available to non-programmers, I get very skeptical. It makes me think of Logo and Turtle Graphics, or programming languages made to be more similar to natural language. It’s like you could make a simpler English to make it easier for non-authors to write literature. So when I first read about The Natural Programming Project, I balked – although for no reason.

The researchers working on NPP certainly does approach programming with the aim of making it easier for laypeople, which seems like a turn-off. However, the output of the project is surprisingly interesting to the professional:  Lab studies scientifically testing the utility of design patterns (they are not all great, it turns out), examining how time is spent during programming (35% on navigating code, 22% on reading!) and how we think during debugging (why did this happen?) – to mention some of the research from their department at CMU.

And then they have actually implementation advice and real software to help utilize the findings, like the Java debugging tool WhyLine. You really have to see the 90 second introduction to WhyLine to get the point, but to me it really opens up a whole new world of possible IDE addons intelligently interpreting your code to you.

This is a presentation from the Google Tech Talks which summarizes a lot of the work they do. If you think like me on programming for novices, tolerate the first 7 minutes on making programming accessible – after that it gets good:

A final note relating this to my current programming language of choice, Perl: When Perl was first designed, it was with a lot of thought from Larry Wall on implementing natural language conventions that actually makes sense, like implicit variables, rather than blindly making it like English. Currently, however, few new things in this humanist regard has come out in the Perl world. The largest modernizing effort in Perl is the current, long-running effort to recreate Perl with Perl 6. This, however, is rather playing catch-up with other dynamic languages such as Ruby and Python on technical merits, losing what sets Perl aside as a particularly expressive and truly useful language, namely the natural approach.

At the same time, thorough, scientific study of programming such as the NPP has made serious progress past the “make programming like writing English” idea that usually plague humanist and psychological studies of programming.  If Perl wanted to build on it’s strengths, it would be better reinvented by looking at this kind of approach -how can it fulfill the virtues of a programmer better for experts who are also human?

Not surprisingly, I have some suggestions on what I would have liked to see for a modern Perl, that differs a wee bit from what is being done now:

  • An IDE that uses an idea such as WhyLine.
  • An IDE with better code navigation tools – watch the video to see some ideas.
  • A compiler that compiles your bytecode into human natural language (English) – that is only meant for assisting reading and understanding code!
  • A
    use warnings;

    that warns about constructions that are difficult to understand: do you use ! with precedence that readers understand? Do you manipulate more variables in a block than human brains can keep track of? Is your indentation following your blocks? And so on.

  • Systematic testing of all the design patterns out there. Can we get quantitative data on number of bugs, development time, maintenance effort and reading time that you can expect when using a specific pattern? Then we would be able to sort out which patterns are worth using and which will be detrimental to your product – a very helpful addition to the current pattern collections and books.
  • Variables that even closer follow their semantic use – how about having specialized iterator variables, temporary variables, variables with history and more. (I see that I have to explain this idea further in a later post… Until then, have a look at the idea of variable roles)

Those are some ideas of the top of my head – and not all of them of equal merit..

As the NPP provides statistics on, and as most programmers know by experience, most of your time does not go into writing fresh, new code. For an expert programmer, I dare suggest the act of expressing what you want the computer to do is rarely where the challenge lies in your 9 to 5 job. A programming language and environment that starts taking that seriously would be a truly modern and enlightened language – and winning support would be like shooting fish in a barrel.

In the Perl world, a common criticism of the Perl 6 development is that it is a solution to a non-existing problem. The above, I suggest, is the problem that is just waiting to be solved by a modern Perl.

4 thoughts on “A natural way of programming – the way for Perl?

  1. admin says:

    Not so much a criticism as a thought and an attempt at a vision for Perl that takes a different approach than what I have seen lately.

    By the way, chromatic: I tried to give you a summary and a link on your blog post on the subject a while back. However, your system refuses to let me create an account..

  2. Gabor Szabo says:

    A bit late response but here it goes.
    There seem to be good ideas here. I am sure we would be glad to have some of those implemented in Padre
    I’d be glad to see you on our IRC channel to discuss this.

  3. admin says:

    Gabor, I’ve been thinking of that for a while, but I’m still at the stage of trying to get Padre to run on my Mac. It’s a wee bit tricky to install.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.