7 ms·
Generating code from natural language is closer than you think
- deleted 16y ago[deleted]
- deleted 16y ago[deleted]
- amichail 16y agoA related thought experiment: if programmers were to work for free, would non-programmers think up of lots of clever things for them to build?
- jpwagner 16y agoThis is a great point. After a few minutes of thought, the biggest benefactor of natural language coding would be what I'd call late-bloomers: people who always thought like coders, but never actually did programming.
- pama 16y agoTo Wolfram Alpha: Hello, HAL. Do you read me, HAL? Result: Affirmative, Dave. I read you.
- stellar678 16y agoI would be fascinated to see several hundred years down the road how natural languages and computer languages have comingled and evolved into something new. I'd be inclined to believe that bringing natural language to computers won't just be a one-way street. You already see this in places like hacker news here where people often use constructs like "s/thing/other thing/" because it's more concise and useful than writing out the natural language version.
- alanh 16y agoI upvoted you. But I am not sure that "/thing/other thing/" is more concise or useful than all alternatives. "thing" → "other thing" is the same length, and while not natural language, it isn’t a computer language. I think using the sed-like (right?) language is more useful as a signaller. Check it out, yo, I grep shit all the time.
- silentbicycle 16y agoThe whole s/X/Y/ thing is very Unix, and is a (sub)cultural signifier as much as anything. I'm not sure if it's originally from ed, sed, or what, but most people (self included) probably picked it up from vi (nvi/vim/etc.) or perl. X->Y makes just as much sense, but the s (for "substitute") makes it mnemonic - I read it as "sub X for Y".
- aaronblohowiak 16y agoed gave rise to sed and vi. ed -> em -> ex (VIsual mode). vim is Vi iMproved. x->y suggests lambda to many people in our community. Edit: I meant to provide some additional information to other readers, not to disagree in any way.
- silentbicycle 16y agoWell, right, but how many people here have actually used ed standalone? (lone hand) It's overwhelmingly likely that most people picked it up from vi(m).
- ctkrohn 16y agoThis is comes up in Charles Stross's novel "Accelerando." He imagines a relatively near future where children grow up speaking partially synthetic languages. It's one of my favorite novels; you can read it online, too: http://www.antipope.org/charlie/blog-static/fiction/accelerando/accelerando.html http://www.antipope.org/charlie/blog-static/fiction/accelera... Stross is also an occasional commenter here on HN.
- jared314 16y agoThe "uncanny valley" might apply here.
- yafujifide 16y agoMight be right, you, I think.
- jerf 16y agoThis is in the class of "demoware", projects that are easy to program fancy demos for but are very difficult to bring to production status. (See also: "fully visual programming".) It's only really interesting if they escape from that. We'll have to wait and see.
- brudgers 16y agoThere is a difference between visual programming and natural language. Natural languages already have tokens, syntax, and grammar whereas visual fields do not have them. All those elements must be imposed onto a visual language before it can be translated into the machine language (e.g. there is no obvious convention for visual commands or visual conditionals).
- pak 16y agothere is no obvious convention for visual commands or visual conditionals I don't know about that. Within a particular domain, you can certainly come close to representing these things, or presenting the right controls for a user to represent commands and conditionals. For an example, check out QuickFuse http://quickfuseapps.com http://quickfuseapps.com Before we built this, we thought about common ways people "drew" voice apps, and commands and conditionals both have certain natural visual representations in the "voice app" space, e.g., blocks with branching arrows and writing text to indicate spoken words.
- brudgers 16y agoThe convention is arbitrary (e.g. most people don't have receivers on their phones and hanging up is done by pressing down a button not by placing the receiver in a horizontal position). If there were an obvious visual convention, the start button would not need to say "start" and the hang up button would not need to say "hang up." That's not to say that arbitrary visual conventions can't have great utility (the alphabet being a case in point). But to illustrate the issues with graphic conventions, Quickfuse does not use the long established conventions for flowcharting. It uses natural language instead.
- bradly 16y agoWhile it would be neat to give the power of programming to everyone, I'm not convinced coding in a natural language would necessarily be better/easier than writing code in Ruby or Lisp or Python. Sure, you eliminate the first big hurdle in programming, but learning the syntax of programming language is usually one of the easier parts of software development.
- brudgers 16y ago"Draw a red circle" is enough to get a red circle. Basic, C++, or Javascript just aren't that closely coupled with the way we think. The advantage of natural language over a high level programming language would appear to be analogous to that which a high level programming language has over assembly. I think you may be conflating programming with software development. People still develop software in assembly language, but few people use it in lieu of javascript on the web.
- Kev 16y ago> "Draw a red circle" is enough to get a red circle. Yes, but once you have to say "Draw a circle in this shade of red, give it a black border this thick, make it this big and put it at these coordinates" things are starting to get unwieldy. After a few different circles I'd probably start longing for draw_circle(fill_colour, radius, (x,y,z), border_colour, border_width). Edit: Added function arguments to make the comparison less biased.
- brudgers 16y ago> '"Draw a circle in this shade of red, give it a black border this thick, make it this big and put it at these coordinates"' Draw a 300 pixel DarkRed circle with a thin black border centered in the blue square. Wolfram's point is that conventional languages won't get your circle to that location as easily, e.g. if the blue square is named arbitrarily and its color is bluish but not literally <color>blue</color>. I'm not suggesting that high-level languages aren't useful, but the reason people often storyboard designs with felt-tips and tracing paper rather than Photoshop is to avoid interrupting the flow of thoughts with the task of translation.
- justin_vanw 16y agoWell, I since it isn't possible (natural language isn't precise enough to even communicate efficiently with other humans that share the same hardware as you, much less an unthinking autamoton such as a computer), that would put the time frame at around never. If it ever actually happens, that would by definition of 'never' be sooner than I think, so all he has to do is actually accomplish it instead of talking shit his entire life, and he'll have proved his statement correct. Maybe he'll call it 'A New Kind of Programming Language'.
- derefr 16y agoProgramming languages are specificational: you say everything up-front, then the computer interprets all your statements at once and executes them. Natural language, however, is conversational. You say A, the person you're talking to interprets that as Z and asks for clarification, you explain the difference between A and Z, now the other person thinks M and asks more clarifying questions, etc. Computers are fully capable of working conversationally, instead of specificationally; it just requires that instructions be stored in a form that's a bit more complicated than a linear tape (e.g. a database of constraints, like Prolog.)
- silentbicycle 16y agoIn more conventional programming terms, some languages have REPLs* for a conversation, and support declarative programming ("Here's what I want, figure it out"), but most are procedural ("Do this, than this, than this, then give me the result"). * Read/eval(uate)/print loops Prolog (also Erlang and some others) is mixed; you reload a file of rules read as a whole, but can easily prompt the system for easy testing, and reloading is very fast. It's very convenient with a Prolog shell terminal and a vi window, two buffers in Emacs, etc.
- derefr 16y agoProlog has a REPL, but only new facts can be declared through it efficiently, not new rules. If you (re-)declare a rule (through `assert`), the entire constraint database is actually re-evaluated behind the scenes. The big problem in conversational declarative programming is how to start with general-purpose rules, and work downward with more and more special-case exceptions, without each new assertion taking longer to integrate into the database than the last. Inform is an exapmple of a natural-language-ish, rule-based system (for programming text adventures), that could efficiently re-declare rules in a REPL (if not for its basis in virtual machine image formats that expect to be compiled from complete specifications.) Inform guarantees efficiency by using a hub-and-spoke system of rules: rather than every rule having the possibility to interact with every other rule, rules can only interact with rules in their own "rulebook" (module), the core rulebooks (standard library), and the "meta" rulebook (monkeypatches to re-specify libraries.) Thus, integrating a new definition only takes O(k + n + e) time—where k, n, and e should all be small—rather than O(n^2). This works well for Inform, but I'm not sure whether it would be as effective in a general-purpose programming environment.
- alanh 16y agoThese guys are smart.
- ADRIANFR 16y agoThis is clearly demoware, good enough to impress the general public. But once you go from "Draw a red circle" to "Draw a red circle overlapped one third with a blue square with white dots over the lower left corner" that would be progress. And then I wonder if this will also work: "Paint a white-dotted blue square that intersects over a third of a red circle in the lower-left corner. Or will it give a "compile error" Why not just create a DSL (e.g. in Scala) with a simple standardized NL-like syntax that can give meaningful "compile errors". There is no need to impress the general public.
- hackinthebochs 16y agoFirst off, did he really have to plug ANKS? Honestly it seems like every piece of writing I come across from him he has to mention it. Secondly, I think eventually programming will have to become more mainstream. And this will be done through some form of a natural language interface. Programming is best a tool to solve problems. It's way too limited now where only an elite group gets to control its use. Eventually programming will have to become a tool as common as mathematics. The problems we face are only going to continue to grow in complexity where the only way to get a handle on them is through automated computation. The user will need the instant, iterative feedback that only a self-made program can provide. For this to happen, the interface to programming will need a radical change.
- Uchikoma 16y agoMost people are not able to use mathematics as a tool.
- hackinthebochs 16y agoThat's not true. Most people with jobs that aren't just manual labor use basic math to solve problems. As the problems get more complicated, the tools have to grow as well. Furthermore, I'm not talking about your average office assistant. I'm talking about professionals in a science-related field. Being able to use programming as a tool is going to become invaluable.
- skybrian 16y agoIt's over-hyped as usual, but this looks like it could evolve into a handy way of generating snippets of working code that you can then modify. Think of it as an alternative to doing a Google search for a useful example to start from, or a better kind of Rails scaffolding.
- ckcheng 16y agoNot the same thing, but similar?, from 1983: "A natural language query system for a prolog database" (Hadley) http://ir.lib.sfu.ca/handle/1892/7254 http://ir.lib.sfu.ca/handle/1892/7254 Not general code generation I suppose, but there's been quite some work on natural language to database queries systems in AI research elsewhere.
- zellyn 16y agoSure, by the time you enter all the specifics of the Circle, you've got something more unwieldy than a succinct programmatic description. But for most people unfamiliar with Mathematica syntax, typing, "draw a red circle" and having the computer choose sensible (or any) defaults yields a template of the exact code one would have needed to type. Which saves Googling or reading the manual for circles, and teaches the syntax in a very natural way.
- elasticdog 16y agoThat is correct...it is nice to be able to see the underlying Mathematica code that any natural language query generates. Here's your "draw a red circle" example: http://img502.imageshack.us/img502/4355/drawaredcircle.png http://img502.imageshack.us/img502/4355/drawaredcircle.png
- blahedo 16y ago"Make it possible for programmers to write in English and you will find the programmers cannot write in English." I teach computer science and have a particular fondness for introductory CS. The reason Stephen Wolfram is wrong, wrong, wrong about this is that people that have never been taught programming can't express themselves precisely enough in their native language, either; and even among those of us that have been programming for decades, when we express ourselves in natural language we can be very precise but it takes a lot more work and becomes a lot more unwieldy than just writing out our instructions in [pseudo]code. CS educators have been wishing for a long time that "intro to CS" didn't equate to "intro to programming". And it doesn't have to, not quite, but the reason it always seems to revert there is that the prerequisite for every other thing in CS is, not programming itself, but a certain precision of thought that is easiest to teach just by teaching students to program. In a programming language. Because if you try to make them write out instructions in a natural language, and you notice that they aren't being precise and therefore deliberately misinterpret that instruction, they just think you're being a dick about it. They sometimes even think this if you honestly misinterpret them. (This is true even in a non-CS context.) Saying that we will soon be "generating code from natural language" is, at best, misleading. It implies that people who couldn't learn a programming language will be able to program, which is quite untrue---I promise that with the possible rare exception of a few pathological edge cases, when people can't learn to program, the language is the least of their problems. And for those of us that can and do learn programming languages, all but the simplest sorts of programs will probably be easier to write in a programming language (which was designed for that sort of thing) than in a natural language (which was not). (And holding up Mathematica as an exemplar is particularly egregious; it is so loaded with syntax that "just works" that you need to either have a deep familiarity with traditional mathematical notation or else a degree-level CS background in programming language theory if you want to have a good shot at learning the language in anything more than a pattern-matching fill-in-the-blank way.)
- madcaptenor 16y agoCloser than we think, maybe, but further than Stephen Wolfram thinks.
- hasenj 16y agoI'm suspecious of the usefulness of such an approach. What's easier, "5 + 10" or "five plus 10", or even worse "five added to ten"? Dijkstra had an article about that, titled: On the foolishness of "natural language programming"[1]. [1]: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD667.html http://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EW...
- mkramlich 16y agoTwo reactions to this piece. 1. I'm not sure what problem so-called natural language programming is trying to solve. 2. Though I admire this man's building of Mathematica and the company that sells it, I'm generally not a fan of what I perceive as his history of "discovering the obvious" and self-promotion. Or rather, rediscovering or making things sound like he invented them or came up with them for the first time. Cellular automata and it's implications in his book "A New Kind of Science", and now this piece sounds like more of the same. I give him a little slack because he's in business and so there's the self-promotion angle, but not much.
- waterlesscloud 16y agoSure, right after physics is adequately expressed in natural language. There's a reason physicists express their concepts in mathematics, and that's because math is the language humans devised to express those things, having found natural language inadequate. Programming is similar in that regard.
- erikpukinskis 16y agoAwesome, Stephen Wolfram has duplicated Terry Winograd's 1971 PhD thesis, which ran in 256K of memory on a PDP-6. Winograd: https://hci.stanford.edu/~winograd/shrdlu https://hci.stanford.edu/~winograd/shrdlu Wolfram: http://blog.stephenwolfram.com/data/uploads/2010/11/conesphere_11.jpg http://blog.stephenwolfram.com/data/uploads/2010/11/conesphe...
- hsuresh 16y agoOn a tangent, has anyone seen/used Intentional Workbench? They claim to be changing the way we program, but haven't seen anything concrete.
- Uchikoma 16y agoA programmer can code in English (though a programming language is easier, more concise, easier to understand) or in a programming language. A non-programmer cannot write code, neither in English nor in programming language.
- Uchikoma 16y agoThis will exactly end like Infocom adventures. They are mostly nice, but quite often you hunt for the exact phrase the parser understood (but to be fair, it happened more often in Magnetic Scrolls). But would you call using a text adventure (put blue ball in red box) programming?
- jcl 16y agoI was thinking the same thing. And it's no coincidence that Inform 7 -- the latest iteration of a popular text adventure game programming language -- is perhaps the most extreme example of a programming language pretending to be English. Here's the actual source code of a game: http://inform7.com/learn/eg/bronze/source.html http://inform7.com/learn/eg/bronze/source.html Of course, it's really a precise programming language that happens to read like English; the same text might not work if it were rearranged into semantically equivalent English.
- IAforyears 16y agoI think that the title should be: Generating code that can be described in a short phrase is closer than you think. We can create a database with the different phrases that people use to suggest a command, for example: Calculate the limit, find the limit ... all of this is Limit, and so on. To sell a product, this kind of ability is well received. Is like telling to your telephone: Please call this number for me, the number of my friend Alfred. And the computer lookup Alfred in its database and connect with that number, that is not deep IA but is a useful trick for selling products.
- EGreg 16y agoNatural language can lead to contradictions and ambiguities. Just look at that star trek episode where they supposedly brought down androids built by a very advanced ancient race just by saying stupid and self contradictory things. Which by the way was a stupid premise but hey :)