What programming language is most like natural language? [closed]
Solution 1:
There is a programming language called Inform that, in its most recent incarnation, Inform 7, looks a lot like natural language...in particular, written language.
Inform is very specifically for creating text adventure games, but there is no inherent reason that the concepts couldn't be extended into other realms.
Here's a small snippet of Inform 7 code, taken from the game Glass, by Emily Short.
Stage is a room.
The old lady is a woman in the Stage. Understand "mother" or
"stepmother" as the old lady. The old lady is active. The description
of the lady is "She looks plucked: thin neck with folds of skin
exposed, nose beaky, lips white. Perhaps when her fortunes are mended
her cosmetics too will improve."
The Prince is a man in the Stage. The description of the prince is
"He's tolerably attractive, in his flightless way. It's hard not to
pity him a little." The prince carries a glass slipper. The glass
slipper is wearable. Understand "shoe" or "heel" or "toe" or "foot"
as the slipper. The description of the slipper is "It is very small
for an adult woman's foot."
Complete code can be found here.
This is a small simple example...it can actually handle a surprisingly robust set of ideas.
It should be pointed out that the code isn't really a strange cypher where the constructs have hidden meanings...this code does more or less what you would expect. For example:
The old lady is a woman in the Stage. Understand "mother" or
"stepmother" as the old lady.
creates an object that happens to be a female person, names that object "old lady", and places that object within the room object called the "Stage". Then two aliases ("mother" and "stepmother" are created that also both reference the "old lady" object.
Of course, as the examples get increasingly complex, the necessary hoops to jump through also become more complex. English is, by its very nature, ambiguous, while computer code is most definitively not. So we'll never get a "perfect marriage".
Solution 2:
Depends on what circles you roll in, but LOLCODE could be considered like natural language ;)
Example loop:
HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
UP VAR!!1
VISIBLE VAR
IZ VAR BIGGER THAN 10? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE
On a serious note, VB is a pretty natural language. It's easy for non-programmer types to learn, so the syntax must be pretty easy to understand.
Solution 3:
The language Richard Pryor used to transfer millions of dollars with in Superman III was very close:
> TRANSFER $1,000,000 DOLLARS TO WEBSTER'S ACCOUNT.... NOW
;-)
EDIT: characters corrected ;-)
Solution 4:
COBOL reads a lot like English
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLOWORLD.
000300
000400*
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. RM-COBOL.
000800 OBJECT-COMPUTER. RM-COBOL.
000900
001000 DATA DIVISION.
001100 FILE SECTION.
001200
100000 PROCEDURE DIVISION.
100100
100200 MAIN-LOGIC SECTION.
100300 BEGIN.
100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
100500 DISPLAY "Hello world!" LINE 15 POSITION 10.
100600 STOP RUN.
100700 MAIN-LOGIC-EXIT.
100800 EXIT.
source
Solution 5:
Lisp (of course (if you know what I mean (LOL)))