Thinking of creating a natural looking programming language

Started by
21 comments, last by ToohrVyk 16 years, 4 months ago
I was thinking of creating a programming language that looks a lot like English, making it easy to learn. Good or bad idea? Here is an example of the language: Create a variable called password. Output the text "Please enter the password:" and a newline. Accept input from the user and store it in the variable password. While the variable password is not equal to the text "admin123" then do the following: Output the text "Access denied. Please enter the password:" and a newline. Accept input from the user and store it in the variable password. Then end the loop. Output the text "Access granted. Welcome".
Advertisement
Ok,
Number 1: The English language is so extensive, that you can say one thing in many ways. You would have to be able to parse the text in your compiler in a manner of ways so that you could cover all possible translations of the text.

Number 2: D you know how long the code would be? You're looking at full essays for simple tasks! Lots of needless text. A waste of time.

Number 3: Who wants programming to be easier? I don't want the market to be flooded (kind of already is) with programmers.

What I'm trying to say is: Yes, it's a cool idea, but not practical. Think about computers that translate one human speaking language to another. They're not perfect, sometimes they completely suck. That's why we still use human translators. In programming, you can't afford to be slightly wrong in translating the code. Would you like to hire translators to change English into a programming code... wait a second, that's what programmers are :D.
bi-FreeSoftware
Quote:Original post by AdamGL
Ok,
Number 1: The English language is so extensive, that you can say one thing in many ways. You would have to be able to parse the text in your compiler in a manner of ways so that you could cover all possible translations of the text.

Well, people need to stick to a predefined way of doing things, but it still makes everything easier to understand.

Quote:Original post by AdamGL
Number 2: D you know how long the code would be? You're looking at full essays for simple tasks! Lots of needless text. A waste of time.

See number 1.

Quote:Original post by AdamGL
Number 3: Who wants programming to be easier? I don't want the market to be flooded (kind of already is) with programmers.

People who want to just create things quickly and easily.

Quote:Original post by AdamGL
What I'm trying to say is: Yes, it's a cool idea, but not practical. Think about computers that translate one human speaking language to another. They're not perfect, sometimes they completely suck. That's why we still use human translators. In programming, you can't afford to be slightly wrong in translating the code. Would you like to hire translators to change English into a programming code... wait a second, that's what programmers are :D.

Yes, I know. I probably will work on this though, and see where it goes...
English is a highly unstructured and ambiguous language, not designed for explicit communication. As a result, teaching a new language to a programmer is much simpler than teaching English to a computer, per se. The state of the art in natural language processing is still highly fallible, and what you would end up with is a subset of English -- which is far more difficult to code in than a new language entirely, because people would expect any sentence that was grammatically correct (or that they THOUGHT was grammatically correct) to compile properly, and it wouldn't, making a debugging into a nightmare...not to mention coding long paragraphs of gobbledygook that ends up looking like a randomly generated spam email
Quote:Original post by SpamBurger
I was thinking of creating a programming language that looks a lot like English, making it easy to learn. Good or bad idea? Here is an example of the language:

I'd argue that programming languages (yes, even C++) are already easier to learn than English.
Of course you need a few other skills as well to be a programmer, but learning the *language* part of C++ is much easier than learning English.

Second, what is it about "natural languages" that are desirable?
That they're vague and ambiguous? That there are two hundred different ways to say even the simplest things, and that there are usually half a dozen different (and all valid) interpretations of what you're saying?

I fail to see how those are at all good things.

Quote:Create a variable called password.

Or 'please create a varable called password.'.
or 'create <lowercase c> a variable named <instead of called> password.'
or 'make a variable called password'
or 'I'd like a variable called password'
or 'create a variable and call it password'
...

How do I, the programmer know which of the above are legal?
How does the compiler know that what I meant was equivalent to "create a variable called password"?

Natural languages only make things harder to understand, by introducing needless ambiguities and complexities.

In short, it'd be impossibly hard to create a programing language like this, even harder to compile it, harder still to ensure that two separate compilers would interpret the language in the same way (and emit equivalent code).
And for the developer trying to program with this, it'd be just plain impossible.

The hard part when learning programming is not to learn to write "while(true)", it is to get used to *thinking* in terms of variables, if statements, loops, functions, recursion and whatever else.

Your language would still require all of this (create a variable named....), and (while the variable .... is.... then do the following)

All you've achieved is to make the language *much* more verbose, make it *much* harder to verify that my code is correct, *much* harder to debug, *much* harder to parse and overall, just a bad idea.

Yes, programming is hard. But it doesn't become easier by taking the least hard part of it and turning it into something completely impossible.
You might want to take a look at AppleScript, as a case-in-point for natural language not working well for computers. It *still* takes me 3 tries to get a working loop in AppleScript, something you will never have with simple 'for' loop syntax.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

A really impressive example of an English-based language is Inform 7. It's a language for creating text adventures. Here's the full "source code" to a simple game:

    "Hello World" 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 closed locked door.    The insurance salesman is a man in the Living Room. The description is "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:        say "The salesman bores you with a discussion of life insurance policies. From his briefcase he pulls some paperwork which he hands to you.";        now the player carries the insurance paperwork.


Which, to me, is pretty good. That code is not that much longer than it would be to write the same thing in a typical programming language.

I don't think English-based languages are great for *every* kind of programming, but it sure seems to work great for Inform's domain.
Quote:Original post by SpamBurger
I was thinking of creating a programming language that looks a lot like English, making it easy to learn.


I think you've confused "easy to learn" with "easy to read for non-programmers".

Quote:
Create a variable called password.
Output the text "Please enter the password:" and a newline.
Accept input from the user and store it in the variable password.


Your example makes me think the syntax would be very hard to learn ("do I need a preposition here or don't I?", or "is this dangling participle going to cause a compiler error?") unless your language had many legal forms for the same thing. As others have pointed out, ambiguities would be difficult to avoid (what does "it" refer to in line 3?)

Notice that I said that your example may be easy to read for non-programmers. Identical code in C would be much faster and easier to read for programmers due to the verbosity and ambiguity of your example.

In short, I agree with others that this is a bad idea, even if it were feasible technically.

Cheers,
Matt




this is giving me horrible flashbacks of lingo, which was Macromedia's attempt at something similar in Director. nooooooooo!
The main thing you would need to do is make a special kind of parser...

It reads the paragraphs/sentences provided by the "coder" and parses them to a more basic, common format. It then, using some algorithm, finds what each statement is trying to tell it. If it cannot find it, it let's the user know. After that, you create a list of "intentions," or concepts that the user wants. Make a C++ equivalent of it, and compile it. Or, just make your own compiling system for all of the intentions in the paragraph.

This would require that the user be fairly specific about what he wants, and a bit less ambiguous, but if you develop it enough, you might get something...

You could make an AI that you feed what you want to, and just have him code it all. ;)
We should do this the Microsoft way: "WAHOOOO!!! IT COMPILES! SHIP IT!"

This topic is closed to new replies.

Advertisement