Slashdot Mirror


The State of Natural Language Programming

gManZboy writes "Brad Meyers (and co) of the Human Computer Interaction Institute at Carnegie Mellon have written an interesting paper about the state of natural language programming. They point out that well understood HCI principles aren't finding their way into relatively new languages like Java and C#."

19 of 387 comments (clear)

  1. Proposal by Anonymous Coward · · Score: 5, Funny

    If
    Natural Language is not making its way into Programming
    Then
    Programming should make its way into Natural Language
    Else
    Continue

  2. Programming in english sucks anyway by Qzukk · · Score: 4, Insightful

    Inevitably you end up with an artificially rigid language structure that sounds like something that nobody would EVER say. Perfectly easy to read, after all, who wouldn't understand what "ADD VAR1 TO VAR2 GIVING VARX", but who the hell would use the word "giving" in such a way. It's a nightmare to learn or write, at least for English-speaking people who would have to constantly fight years of learning to speak real English to make up for the fake english in the language.

    --
    If I have been able to see further than others, it is because I bought a pair of binoculars.
    1. Re:Programming in english sucks anyway by Anonymous Coward · · Score: 4, Insightful

      Witness--why everyone hates legalese in EULA's. Achieving unambiguous precision with English is HARD.

    2. Re:Programming in english sucks anyway by Pxtl · · Score: 4, Insightful

      imho, natural language programming languages are awful because they add a tiny bit of verbal legibility in exchange for a) losing nice obvious visual cues like { and } and b) missing something painfully obvious:

      We learn math pretty friggin' soon after learning to spell. And at that point, you never write "one plus one equals two" ever again, if you ever did.

      The fact is that comptur language has a closer relationship mentally to math than to english. So why not use mathematical language? Its even better, as its not tied to a single human language (who wants to translate "plus" into Swahili?)

      IMHO, modern commercial languages do suck for not learning from their more academic peers (Java, I'm looking in your direction - inner classes rock, but they're no excuse for all the missing stuff).

      But for "englishoid" languages, I learned VB first and then Java, and I have to say the first thing I loved about Java was the unambiguous { and } blocking.

      I'm all for using natural english in the parts of programming where it belongs - like flow control, function calls, class definitions, etc. But having unambigous "this is a block" characters helps mental consistency, and using mathematical syntax helps people understand the more mathematical concepts (although the C = as assignment thing is an abomination - := pwns it).

    3. Re:Programming in english sucks anyway by wmshub · · Score: 5, Informative

      Did you two (the parent & grandparent of this) really read the article? It's not about programming in English, it's not about syntax, it's about structure.

      For example, they pointed out that people think about tasks in an event-driven way, their example is "when pac-man is out of lives, the game is over". But they must program by finding where in the program the number of lives goes down, and inserting the code there. An event driven language would simplify.

      Their other example was that most languages make people think in loops, when they really want to operate on a group. Saying "for (i = 0; i len; ++i) { x[i] += 10; }" it a really clumsy way to express what people thought, which was "add 10 to everything in x".

      Anyway, I agree that parts of the article don't sound too helpful, but they aren't talking about writing in English; they're talking about changing the structure of languages to more closely match what people think.

  3. Is it any wonder? by Tackhead · · Score: 5, Funny
    > They point out that well understood HCI principles aren't finding their way into relatively new languages like Java and C#."

    Well, duh! That's because if, according to the article...

    > The goal is to make it possible for people to express their ideas in the same way they think about them.

    ...most ideas just don't work that way.

    #include // Do What I Mean

    thingy main (thingy list) { Sort thingy
    No, like this
    With the guy's name on the right
    No, I guess the middle initial deserves its own column. No, I didn't think of that.
    But don't print the middle initial.
    No, not like that.
    Eew, that font sucks.
    Yeah, like that.
    No, like it was before.
    Yeah, no--wait. I gotta talk to my boss.
    He said to do it like this. // wave hands
    But he didnt like it.
    Fuck this, I'll pay some guy in India to do it.
    }

  4. Not gonna work by JohnGrahamCumming · · Score: 5, Funny

    Given the state of natural language on /. this isn't going to work :-)

    John.

  5. I don't buy it. by vontrotsky · · Score: 5, Insightful

    I disagree with the article's assumption that interesting programming errors are due to people being unable to express themselves "naturally" in code. Rather, I find that almost all errors worthy of debugging come not understanding the problem domain correctly.

    jeff

    1. Re:I don't buy it. by Bastian · · Score: 4, Interesting

      One thing that I have noticed about any debate about what programming facilities will most help programmers to write more bug-free code or spend less time debugging is that the debate is based entirely around anecdote.

      I would love to see some numbers on the frequency and nature of bugs in software, and I want to see these numbers broken up by language as well as by appliction domain. I suspect that a comprehensive collection of such statistics doesn't exist, since I haven't seen any empirical data enter into the various debates to which they would apply.

      Until someone spends some more time researching this information, I doubt that the development of programmign technology will advance in a fashion any more directed or smooth than science and technology did back in the fourteenth century.

  6. Natural language programming. by Adhemar · · Score: 5, Insightful
    The virtue of formal texts is that their manipulations, in order to be legitimate, need to satisfy only a few simple rules; they are, when you come to think of it, an amazingly effective tool for ruling out all sorts of nonsense that, when we use our native tongues, are almost impossible to avoid.
    - Edsger Wybe Dijkstra, "On the foolishness of natural language programming".
    An interesting read.
  7. Write a Natural Language Compiler by TheUnFounded · · Score: 5, Interesting

    Write a Natural Language Compiler and you'll find that programmers can't write in a Natural Language. Can you imagine what would happen when you have to understand, not the flow of the code, not the overall process of the application(s), but HOW the writer was THINKING when they wrote the code? I've worked on a couple interesting projects where the programmers originally were involved in the physical business process, and eventually ended up coding (don't ask). When I had to edit their code, there was NO way of understanding it unless you actually talked to them and realized how they were thinking about the problem. It's not that the code was so poor, but they wrote code based on how they'd seen the business operate, and that just didn't translate nicely into straightforward code.

    Personally, I don't see how creating a language that encourages this behaviour can be a good thing. Isn't this the point of learned programmers? The ability to translate real world situations into easy to understand processes? Then again, I'm no language development guru. :)

  8. Good point! by goldspider · · Score: 4, Insightful

    One thing that programming languages force upon you (the programmer) is the ability to get what you want using the least possible resources.

    Natural language, while easier for beginners, would make for horribly inefficient code and would be undesirable for any sizeable application.

    --
    "Ask not what your country can do for you." --John F. Kennedy
  9. on a bumper sticker by devphil · · Score: 5, Funny


    YOU FORTH LOVE IF HONK THEN

    And here's some filler text to compensate for /.'s sucktacular lameness filter. Blah blah blah. "It won't be any more frightening than the time I climbed up an elevator shaft with my teeth," said Sunny.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  10. Wow. by cbiffle · · Score: 4, Insightful

    Well, I'm not sure if it's that nobody read the article, or if nobody actually understood it, but.

    We've had a lot of posts about "OH NO! COBOL!" Yes, yes, I agree with you -- pretending to be English usually results in awkward and unnatural syntaxes. One of the advantages of a formal syntax like most programming languages is that it clicks the brain into a different mode. (How many of you can read sigs like 2b||~2b? I thought so.)

    But that's not really the paper's main aim. It makes a couple of notes that all of us, particularly those of us in language design, could benefit from.

    1. People tend to deal with collections in the aggregate far more often than they step through them an item at a time. The example given was "set the nectar of all the flowers to 0." Look past the syntax for a moment and look at how simple that is.

    2. Debugging the traditional way sucks. Did anyone actually read that bit at the end about the 'Why?' questions, and look at the screenshots? Holy crap. That's really impressive.

    Of course, I may be biased, because the points made in the article are basically the same that underlie a language I'm currently designing. :-) (And no, I'm not using Englishy COBOL syntax.)

  11. Is this a good idea? by hugesmile · · Score: 4, Insightful
    It seems that the effort here is to allow end users to state their "problem" in natural language, and then a program gets generated to solve their problem.

    Right now that happens - only the program gets generated by programmers (sometimes outsourced to India!)

    Unfortunately, what the user says they want, and what they really want are usually very different things. Natural Language Programming really doesn't solve that problem.

    The critical piece is the Designer, who sits between the end user and the programmer, and asks the tough questions: "Do you really want that? Let me explain the implications of what you just asked for." "How critical is that piece of functionality that you just added on a whim, but it just added 3 years to the project plan?" "You're asking for the data to be selected this way, but really there's no use for that - have you considered selecting the data this other way?" etc.

    1. Re:Is this a good idea? by Taladar · · Score: 5, Insightful

      The difficult thing with programming isn't usually the syntax but the fact that most people can't cope with the computer doing exactly what they tell it to do.

  12. Some 17 years ago ... by KlaymenDK · · Score: 4, Informative
    ... Dan Winkler created HyperCard together with Bill Atkinson.
    Granted, it was by no means a fast runner, but you could write more or less plain English to it:
    go to the last card of stack "Home"
    go to black with visual effect fade to black
    go to the previous card with visual effect venetian blinds
    get the third word of line 2 of field "Slashdot"
    put it into the messagebox
    Who could possible be confied by this code?
    Notice the brilliant little keyword called "it", that you could use with "put" and "get". Neat, simple, easy!

    eulogy
  13. Re:Applescript by MoneyT · · Score: 4, Interesting
    Probably because it's too obvious. I ran into that problem a few months ago. Version 6 of matlab for OS X had a unique problem in that one needed to start X11 and then start Matlab before it could be run, there wasn't a single command to do both. Of course, this lead to confusion on the part of our users, and so the simple and obvious solution would be to write an apple script to do it. That was the easy part:
    tell Finder to open application X11
    tell Finder to open application MatLab
    The problem was, in the way that Matlab was setup, the helper app used to launch MatLab in the X11 environment never truely opens (it bounces in the dock for a while and then goes away having begun the true MatLab startup. The end result of this was that since Apple Script was not being notified that the application had finished opening, it was recieving an error that startup had failed and kept retrying the start. This resulted in an infinate loop of MatLab window creation.

    The solution of course was to tell Apple Script that regardless of what hapens, just issue the open application command and stop caring. I spent a good hour or so digging through documentation until I finaly found how to do this, and the answer is so blaringly obvious that it makes one feel stupid when they realize they should have known it all along:
    ignoring all errors
    tell Finder to open application MatLab
    That's it.
    --
    T Money
    World Domination with a plastic spoon since 1984
  14. Specialsied languages are not just for programming by EmbeddedJanitor · · Score: 5, Insightful
    Natural languages are often not the best way to express problems/concepts concisely. The use of specialised languages is not something that is specific to programming. We (humans) have special languages for all branches of mathematics, chemistry (H2O...), physics (E=Mc2), music, drawing house plans.... These specialised languages came about because natural languages do not provide an effective means for communicating these ideas. For an example, consider some music written in a natural language: "Big drum beat followed by a bit of silence then a soft ....." Imagine trying to read and play that.

    Programming is also something that is easier to express in a specialised language. Sure we can make some things more human readable but does that make it easier to understand? The hard part of programming isn't reading/writing the code so much as knowing what structures and concepts to use. Making programming more natural language like will not really make programming easier, you still need skill and practice. Using the music analogy again: I don't play music and can't read music score (the language of music). If Beethoven's fifth (if he ever had a fifth) was rewritten in a natural language it would not make it easier for me to play; I'd still need a whole lot of practice with a piano or whatever to play effectively. Relative to aquiring the piano skills, I expect learning to read sheet music would be relatively simple.

    Where natural languaages might help is in system design and requirement capture. Still, however, I think that most often things go wrong because when people are expressing their thoughts in a natural language they use very woolly thinking and use vague terms.

    --
    Engineering is the art of compromise.