Applescript 什么编程语言最像英语?

Applescript 什么编程语言最像英语?,applescript,programming-languages,nlp,Applescript,Programming Languages,Nlp,我主要是一名Python程序员,它通常被描述为“可执行的伪代码”。我使用了一点AppleScript,它似乎是我见过的最像英语的编程语言,因为几乎运算符都可以是单词,而且它可以让你在任何地方使用“the”(例如,我刚刚想到的这个愚蠢的例子: 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

我主要是一名Python程序员,它通常被描述为“可执行的伪代码”。我使用了一点AppleScript,它似乎是我见过的最像英语的编程语言,因为几乎运算符都可以是单词,而且它可以让你在任何地方使用“the”(例如,我刚刚想到的这个愚蠢的例子:

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
是一个有效的AppleScript程序。有没有比这些更像英语的编程语言?

VB.NET(尽管你的AppleScript示例胜过VB.NET)、SQL或COBOL(这种风格的源代码)。Lolcode是“语言”-类似,但我很高兴英语不喜欢它

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

SQL

Lolcode

ON CATURDAY
    IM IN YR BED
        I IZ SLEEPIN!!10
        VISIBLE "Z!"
    KTHX
KTHXBYE

COBOL一直被认为是相当“自然的语言”。以下是摘自:


当然,“自然语言”并不总是(通常?)编程语言中的一个优点,精确性是一天的顺序(而自然语言几乎总是模棱两可的-添加编程语言所需的精确性只会使它变得冗长)

冒着成为一个愤怒的指挥家的风险:我声称,对于编程语言来说,像自然语言一样的语言是一个不好的目标。具体地说,自然语言表达的目标是影响世界,让其他人想亲吻你而不是打你;这与编程语言表达的目标非常不同e、 这是一个定义明确的领域中的明确陈述,计算机或其他人可以对其进行评估。一个更好的问题可能是:哪种编程语言最难意外地击中自己的脚


…当然,这根本不是你要问的。

ShakesPeare编程语言如何。以下是“hello world”源代码的一部分,出自:


似乎代码高亮显示在这里不起作用。//p>你听说过吗。这是一种自然的编程语言。即使你可以在Supernova中创建一个窗口,只需说一句“我想要窗口”,窗口标题是“你好”。可能是通用的Lisp?Lisp中的宏允许你将抽象定义为“新词”。这与伪代码或英语非常接近(因为在我们的思想或讨论中描述程序时,我们使用了许多特定语言机制的抽象)

一个有趣的例子是回指宏,Paul Graham在其关于Lisp的书中描述了回指宏。回指宏是一个将某些表达式绑定到其体内的符号“it”的宏,因此我们可以很容易地引用它:

(aif (get-data) (do-something it)) 
在这一行中,get data是函数,它返回某个对象或nil。如果它返回数据,它们将绑定到“it”变量,这是由“do something”函数处理的。如果返回的数据为nil,则不满足条件,并且不执行子句


还有许多其他的回指宏的例子,比如绑定循环变量的for循环等等。事实上,你甚至可以用宏为你生成回指宏。

莎士比亚的答案让我想起了,这是一种用于编写交互式小说的严肃编程语言。它可能是最接近英语的语言存在并具有明确语义的英语

以下是来自维基百科的示例:

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

该示例使用了用户可以使用的大量对象库。但该语言本身实际上是图灵完整的,您可以使用其中的任何行为来定义对象。

我不喜欢插入我自己的东西(当然不是真的),但它的语法非常像英语:

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

    RETURN "return value!"
END FUNCTION

如果你在应用规则时不一致,有很多奇怪的边缘情况和尖角,会伤害学习者,那么很少有编程语言比C++更像英语。

< P>在复习完所有的答案后,我确信Apple脚本实际上是最自然的语言。

< P>我想讨论一下Dijkst在哪里。ra-like编程精度是必需的,而不是不需要的。在需要细节的低级别编程中,精度也是必需的。由于编程原语是更高级别的,也许没有那么多…

Dijkstra会同意:是的,我同意。我只是想知道有多少人能够做到这一点。自从最初的link已经死了,这里是一个存档的文件,可以为您节省一些输入:重复:实际上,将前两个变量声明更改为“将firstNumber设置为1”和“将secondNumber设置为2”,并删除任何那些“讨厌的”数学符号。啊,很好的一点。我太习惯了普通的编程语言,我很难想出一个例子。我修复了它。我找不到一种足够像英语的编程语言,所以我创建了一个名为的英语到Python编译器。它会自动将英语句子翻译成工作Python代码。自然语言编程语言在我看来是一种巨大的空间浪费。当COBOL出现时,它可能被认为是一种美德。写COBOL有点像写英语,但背后有一位非常严格的英语老师,每当你放错逗号(或点)时,他都会打到你的手指上。英语怎么样?除了使用英语单词外,你的代码样本似乎没有使用英语语法,甚至没有超过2个单词的短语。如果这是一个允许你用英语编写LISP的宏,请给出一个类似英语版本的LISP示例。正是这样的东西让我觉得LISP用户实际上不是人类Gabe:好吧,这个问题的意图有点模棱两可。为什么你希望编程语言更像自然语言,有不同的原因。一个原因是你想对你的程序进行更简单的推理。将抽象定义为文字可以帮助你做到这一点。Gabe:换句话说,我不这么认为像理解英语语法一样理解“自然语言”,这就是我提到的原因
               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]
(aif (get-data) (do-something it)) 
"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.
BEGIN FUNCTION (variable AS INTEGER) AS STRING
    PRINT "Hello!"

    RETURN "return value!"
END FUNCTION