views:

351

answers:

9

I'm mainly a Python programmer, and it is often described as being "executable pseudo-code". I have used a little bit of AppleScript, which seems to be the most English-like programming language I have ever seen, because almost operators can be words, and it lets you use "the" anywhere (for example, this stupid example I just came up with:

set the firstnumber to 1
set the secondnumber to 2
if the firstnumber is equal to the secondnumber then 
    set the sum to 5
end if

is a valid AppleScript program. Are there any programming languages that are even more English-like than these?

+2  A: 

VB.NET (though your AppleScript example beats VB.NET), SQL or COBOL (the source of this style). Lolcode is "language"-like but I'm glad English isn't like it.

VB.NET

If MsgBox("The process will be started", MsgBoxStyle.OkCancel, "Title") = DialogResult.OK Then 
   'ok was clicked
Else
  'cancel was clicked
 End If

COBOL

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
    RECORD CONTAINS 55 CHARACTERS
    DISPLAY 'Hello, world'.
    STOP RUN.

SQL

SELECT * 
    FROM Book
    WHERE price > 100.00
    ORDER BY title;

Lolcode

ON CATURDAY
    IM IN YR BED
        I IZ SLEEPIN!!10
        VISIBLE "Z!"
    KTHX
KTHXBYE
Graphain
+3  A: 

COBOL was always considered pretty "natural language". Here's an extract from the 99 bottles of beer page:

move spaces to buffer bb1                                 
move 1 to j                                               
divide i by 10 giving k remainder l                       
string bb8(k + 1) delimited space into bb1 pointer j      
if j > 1                                                  
   then move bb7(l + 1) to bb1(j + 1:)                    
   else move bb7(i + 1) to bb1                            
end-if

Of course, "natural language" is not always (often?) a virtue amoung programming languages, where preciseness is the order of the day (and natural language is almost always ambiguous - adding the preciseness required by a programming languages just makes it verbose).

Dean Harding
At the time when COBOL has appeared, it was probably considered a virtue. To write COBOL is kinda like writing English, but with a very strict English teacher behind your backs, which strikes you over your fingers whenever you misplace a comma (or dot).
J S
+5  A: 

At the risk of being a raging finger-wagger: I claim that natural-language-like is a bad goal for programming languages. Specifically, the goal of a natural language utterance is to influence the world so that other human beings want to kiss you rather than punch you; this is very different from the goal of a programming language utterance, which is intended as an unambiguous statement in a well-defined domain that a computer or another person can evaluate. A better question might be: which programming language makes it most difficult to accidentally shoot yourself in the foot?

... which is not at all what you asked, of course.

John Clements
Dijkstra would agree: http://userweb.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD667.html
stephan
Yeah, I agree. I just was interested in how far anyone has managed to push this.
asmeurer
+5  A: 

How about the Shakesspeare programming language. Here's a part of the "hello world" source, out of wikipedia:

               Act I: Hamlet's insults and flattery.
               Scene I: The insulting of Romeo.

[Enter Hamlet and Romeo]
Hamlet:
You lying stupid fatherless big smelly half-witted coward! You are as
stupid as the difference between a handsome rich brave hero and thyself!
Speak your mind!
You are as brave as the sum of your fat little stuffed misused dusty
old rotten codpiece and a beautiful fair warm peaceful sunny summer's
day. You are as healthy as the difference between the sum of the
sweetest reddest rose and my father and yourself! Speak your mind!
You are as cowardly as the sum of yourself and the difference
between a big mighty proud kingdom and a horse. Speak your mind.
Speak your mind!
[Exit Romeo]

Seems like code highlighting doesn't work here. :/

Wikser
+1  A: 

Didnt u heard about Supernova...

Its a Natural Programming Language..

even u can create window in that...

by just saying I want window and the window title is hello.

Vizay Soni
A: 

Maybe Common Lisp? Macros in Lisp allow you to define abstractions as "new words". That's as close to pseudocode or English as you want to get (because when describing program in our thoughts or discussions, we use a lot of abstractions from the mechanics of particular language).

An interesting example are anaphoric macros, which Paul Graham describes in his book On Lisp. Anaphoric macro is a macro that binds some expression to the symbol "it" inside it's body, so we can easily refer to it:

(aif (get-data) (do-something it)) 

In this line, the get-data is function which either returs some object or nil. If it returns the data, they are bind to "it" variable, which is the processed by "do-something" function. If the data returned are nil, the condition is not satisfied and the clause is not executed.

There are many other examples of anaphoric macros, like for loops, that bind the loop variable, and so on. In fact, you can even have macros that generate anaphoric macros for you.

J S
How is that English-like? Aside from using English words, your code sample doesn't appear to use English grammar, nor even phrases longer than 2 words. If that's a macro that allows you to write LISP in English, please give a sample of the English-like version of LISP.
Gabe
It is stuff like this that makes me think Lisp users are not actually human beings, just creatures trying to pass as humans.
JUST MY correct OPINION
Gabe: Well, the question is a bit ambiguous about the intent. There are different reasons why you would like programming language to be more like natural language. One is that you want to easier reason about your program. Defining abstractions as words can help you do that.
J S
Gabe: In other words, I don't understand "natural language-like" just like having English syntax. That's why I mentioned anaphoric macros, because in natural languages, you often refer to different objects by same symbol depending on context. But if you want an example of English-like syntax in Lisp, look at the loop macro.
J S
+6  A: 

The Shakespeare answer reminded me of Inform 7, which is a serious programming language for writing interactive fiction. It's probably the language most closest to English that exists and has a well-defined semantics.

Here is a sample from Wikipedia:

"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.

The sample uses an extensive library of objects which is available for user. But the language itself is in fact Turing complete, and you can define objects with any behaviour in it.

J S
Include a sample in your answer?
Graphain
+1 Quite English-like!
George Edison
Except I'm really looking for a language that lets you type what you want in the most English-like way possible, like AppleScript, not something that can look like one thing in English while doing else completely in code.
asmeurer
A: 

I hate to plug my own stuff (well not really) but 7Basic has a pretty english-like syntax:

BEGIN FUNCTION (variable AS INTEGER) AS STRING
    PRINT "Hello!"

    RETURN "return value!"
END FUNCTION
George Edison
+1  A: 

If you mean inconsistent in application of rules with lots of bizarre edge cases and sharp corners to injure the learner, there's very few programming languages more English-like than C++.

JUST MY correct OPINION
Something this funny ought to be a comment, not an answer.
Andrew Grimm