Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have seen some horrible code in my time including people virtually duplicating the code in comments

// add 4 to x

// for each i in 0 to 9 
for (int i = 0; i < 10; i++) {
    // multiply x by i
    x *= i;

Taking this concept further, I'm curious whether prose to code compilers exist.

  • Is there a valid use case for English prose to code?
  • Do compilers exist that do this?

The distinction between this and auto generated code, is that auto generated code is generally always a subset of a project. Can we have complete projects auto generated from english prose?

I realise that this might overlap with the concept of declarative languages.

share|improve this question
This is an odd question. You want to know if there are any, but don't want it for your own use. Is this like poison? Are you going to try to get someone else to use one? –  Matt Ellen Jul 1 '11 at 11:03
Guess you're going to write a compiler for the DeCSS haiku? www-2.cs.cmu.edu/~dst/DeCSS/Gallery/decss-haiku.txt –  SK-logic Jul 1 '11 at 12:53
Why would we want one? Trying to make sense of abritary natural-language prose is close to impossible as of now and will propably never be easy and there will inevitably be ambiguities. Restrict the grammar and the vocabulary to make it parsable and unambigious, and you end up with a regular programming language with particular verbose syntax that's being praised as "just like english", bit of course isn't - programming always requires more detail and thought than human communication - leading to non-programmers trying to program with predicatable results (failure and/or horrible code). –  delnan Jul 1 '11 at 13:15
That's the easy part. The hard part is getting the prose from the stakeholders for what they want. It's a chore getting them to even tell you in ENGLISH. –  JohnFx Jul 1 '11 at 22:37

5 Answers 5

up vote 17 down vote accepted

There are lots of prose to code compilers. It's even an entire class of tools. They are commonly called "programmers" or "software engineers".

Apart from that, writing software without knowing programming languages (which is what having a prose-to-code compiler would typically attempt to achieve) has fundamental problems. There is an entire field dedicated to dealing with these fundamental problems called Natural Language Processing. The biggest problem is that natural languages are typically extremely ambiguous (even short sentences can have thousands of potential parses).

share|improve this answer
Where can I get an automated programmer? One that compiles in minutes rather then months? –  Raynos Jul 1 '11 at 13:03
@Raynos - the less expensive ones tend to produce code the soonest. –  Scott Whitlock Aug 26 at 20:59
@Raynos: Automation is orthogonal to speed. –  Thomas Eding Aug 26 at 23:31

Is there a valid use case for English prose to code?

In some domains. For example Inform language for interactive fiction. Example program in Inform 7:

"Hello Deductible" by "I.F. Author"
The story headline is "An Interactive Example".
The Living Room is a room. "A comfortably furnished living room."
The Kitchen is north of the Living Room.
The Front Door is south of the Living Room.
The Front Door is a door. The Front Door is closed and locked.
The insurance salesman is a man in the Living Room. "An insurance salesman in a tacky polyester suit. He seems eager to speak to you." Understand "man" as the insurance salesman.
A briefcase is carried by the insurance salesman. The description is "A slightly worn, black briefcase." Understand "case" as the briefcase.
The insurance paperwork is in the briefcase. The description is "Page after page of small legalese." Understand "papers" or "documents" or "forms" as the paperwork.
Instead of listening to the insurance salesman for the first time:
say "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you.";
move the insurance paperwork to the player.

For general purpose programming, COBOL was attempt to build a language, which would be as close to English prose as possible:

One of the design goals of COBOL was that non-programmers—managers, supervisors, and users—could read and understand the code. This is why COBOL has an English-like syntax and structural elements—including: nouns, verbs, clauses, sentences, sections, and divisions.

share|improve this answer
Note that this also means that COBOL code is very easy to read for a non-COBOL programmer. –  user1249 Jul 1 '11 at 13:06
@ThorbjornRavnAndersen if COBOL is so easy to read, why do COBOL programmers get paid so well? –  Raynos Jul 1 '11 at 13:28
@Raynos: COBOL is supposed to be easy to read for non-programmers (another thing is it didn't quite achieve that goal). For programmer let's say i++ is easier to read than i + 1 YIELDS i –  vartec Jul 1 '11 at 13:36
@Raynos, there is a vast difference between being able to read existing, working code, and write new code. –  user1249 Jul 1 '11 at 13:51
As a professional reader of COBOL code, the bulk of COBOL code written by professionals is opaque. The same would be true of the "comment-to-code" subset of English used by a "comment-to-code compiler". It would be opaque. –  S.Lott Jul 1 '11 at 19:05

Take a look at cdecl. It is a little tool which can convert C-declarations to English and vice versa. It is not exactly converting any code to English prose, but perhaps the closest you can get.

share|improve this answer
I wanted to convert english prose to code ;) It can of course go the other way too. Of course your example is a simple bijection, rather. I.e. C <-> Specific Subset of English. –  Raynos Jul 1 '11 at 12:11

Wolfram|Alpha is able to calculate queries written in plain-English, so eventually they may be able to extend that to some more of programming. In general, even if you could get prose to be rigorous enough, it would be much too long, so regular programming would be much more efficient.

share|improve this answer

Ask Siri...

Siri (Apple's software personal assistant) also translates plain English to a request for information and executes the request. Not really programming, though.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.