3 ms·
Natural language is ambiguous, sure, but natural-language programming already exists. I suspect most readers of HN are already very familiar with it. Dijkstra
by NAR8789 6y ago
Natural language is ambiguous, sure, but natural-language programming already exists. I suspect most readers of HN are already very familiar with it.
Dijkstra is of course right that you can't replace the precision of formal languages. Precision allows you to "one-shot" a spec. For simplicity, consider just machine code. A compiled program, given to the right machine, is a sort of message that can be delivered unidirectionally and understood perfectly. From the perspective of natural languages, that is nothing short of a miracle. Can you think of a case where you said something mildly complex and were understood perfectly, the first time, without questions and clarification?
To drop the need for formality and precision then, the tradeoff is this: we must program by conversation; the compiler must be able to talk back and collaborate with the programmer to "discover" the program spec. This is not talking back in the sense of waiting for input or mouse events--at that point we are already running the fully compiled program. Remember, this conversation is replacing the work of writing the program. We want something that substitutes for the information content of the compiled binary, that "single message" I can send to a computer to tell it unambiguously what to do.
Programming by conversation ends up being a kind of iterative programming by trial-and-correction.
- Programmer says, "I my windows to automatically close when it's raining, and open when the sky is blue."
- Compiler: "I can almost do that, but what about when it's both raining and the sky has patches of blue?"
- Programmer: "That can happen?"
- Compiler: "It's kind of counterintuitive, but it happens occasonally"
- Programmer: "Well when that happens just keep the windows closed"
- Compiler: "Ok, but what about-"
- Programmer interrupts: "Do the other edge cases happen often?"
- Compiler: "Maybe 0.1% of the time."
- Programmer: "Ignore them and just let the system crash and call for help--I can just come work the windows myself those days"
- Compiler: "Sure, I'll just need to ziptie a few motors to the windows like so, and-"
- Programmer: "Whoa whoa, can't we make it prettier?"
- Compiler: "I guess... gonna take a while though"
- Programmer: "Oh, well I'm in a hurry. Ziptied motors it is!"
- Compiler: "Ziptied motors it is!"
You've seen this conversation before. You've had this conversation before. You've met and interacted with programmers who use this "natural language programming language".
We call these programmers "Product Managers". You are deeply familiar with natural language programming, because you are the first compile-step in the build chain. You, the "programmer", are a very-high-level conversational code editor.
Joking aside, any "natural language programming language" would probably need to operate in some kind of conversation format. Still probably immensely complex to build, and Dijkstra's point about ease of expression stands strong--some things are much, much faster to say in formal language rather than by having a slow conversation that whittles away the ambiguities, and it increases the amount of work from both Programmer and Compiler (conversations take mental energy!). But whittle away ambiguities we nonetheless can. Building a synthetic programmer is certainly a very far away goal, but "foolish"? Maybe, maybe not.