What programming language is the most English-like? [closed]
Asked Answered
V

11

10

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?

Venesection answered 18/6, 2010 at 5:27 Comment(5)
duplicate: #492471 #203250Mealie
Actually, change the first two variable declarations to "set firstNumber to 1" and "set secondNumber to 2" and do away with any of those "pesky" mathematical symbols altogether.Koloski
Ah, good point. I am so used to normal programming languages, I had a hard time coming up with an example. I fixed it.Venesection
I couldn't find a programming language that was sufficiently English-like, so I created an English-to-Python compiler called EngScript. It automatically translates English sentences into working Python code.Criminate
Natural-language programming languages seem to me a huge waste of space.Friedrich
V
2

After reviewing all the answers, I'm convinced that AppleScript actually is the most natural language like.

Venesection answered 27/7, 2012 at 0:14 Comment(0)
D
19

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

Demise answered 18/6, 2010 at 6:7 Comment(1)
Something this funny ought to be a comment, not an answer.Dykstra
S
13

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.

Squiggle answered 18/6, 2010 at 6:0 Comment(2)
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.Venesection
@Venesection The Wolfram language has a natural language input mode, which is exactly what we need: blog.wolfram.com/2010/11/16/…Criminate
O
8

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.

Outcrop answered 18/6, 2010 at 5:42 Comment(3)
Dijkstra would agree: userweb.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/…Keese
Yeah, I agree. I just was interested in how far anyone has managed to push this.Venesection
Since the original link is dead, here is the archived one to save you some typing: web.archive.org/web/20141224145103/http://www.cs.utexas.edu/…Burial
C
6

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

Conjunct answered 18/6, 2010 at 5:35 Comment(1)
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).Squiggle
U
4

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. :/

Ulaulah answered 18/6, 2010 at 5:44 Comment(0)
D
3

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
Demisemiquaver answered 18/6, 2010 at 5:31 Comment(1)
YOU HAZ A LOLCODE :P I LUV LOLCODE!!!!1!!1!!1111Winne
V
2

After reviewing all the answers, I'm convinced that AppleScript actually is the most natural language like.

Venesection answered 27/7, 2012 at 0:14 Comment(0)
S
1

Have you heard about Supernova. It's a natural programming language. Even you can create a window in Supernova by just saying I want window and the window title is hello.

Slurry answered 18/6, 2010 at 5:56 Comment(0)
G
0

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
Grannie answered 18/6, 2010 at 6:2 Comment(0)
M
0

I think a discussion of where Dijkstra-like programmatic precision is necessary vs where it is not would be interesting. In lower level programming where detail is needed, so is precision. As programming primitives are higher level, perhaps not so much ...

Matthaus answered 9/9, 2012 at 19:51 Comment(0)
S
-4

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.

Squiggle answered 18/6, 2010 at 5:58 Comment(5)
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.Higdon
It is stuff like this that makes me think Lisp users are not actually human beings, just creatures trying to pass as humans.Demise
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.Squiggle
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.Squiggle
J S: I love Lisp and the idea of anaphoric macros but this might not be the best way of convincing other programmers of our sanity ;)Schadenfreude

© 2022 - 2024 — McMap. All rights reserved.