使用“天然”的产品是否更好?语言来写代码?
我最近看到一种名为 supernova 的编程语言,他们在网页中说:
Supernova 编程语言是 现代脚本语言和
第一个提出的概念 用直接虚构进行编程 使用
进行描述纯人类语言的清晰子集。
。你可以编写这样的代码:
i want window and the window title is Hello World.
i want button and button caption is Close.
and button name is btn1.
btn1 mouse click. instructions are
you close window
end of instructions
我的问题不是关于语言本身,而是我们是否需要这样的语言,它们是否使编写代码变得更容易?
I recently saw a programming language called supernova and they said in the web page :
The Supernova Programming language is
a modern scripting language and theFirst one presents the concept of
programming with direct Fiction
Description usingClear subset of pure Human Language.
and you can write code like:
i want window and the window title is Hello World.
i want button and button caption is Close.
and button name is btn1.
btn1 mouse click. instructions are
you close window
end of instructions
my question is not about the language itself but it is that are we need such languages and did they make writing code easier or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
该代码可能看起来像自然语言,但它实际上只是具有不同关键字的常规计算机代码。在您的示例中,
我想要
可能与new
同义。这不像你可以直接使用自然语言并说给我一个窗口
(如果你可以,事情会变得更加丑陋......)。让我们仔细看看您的代码和语言含义:
i Want
表示new
,and
表示参数列表的开头。<类型名称> <会员名称> is
在正在创建的对象上设置实例变量member_name
。请注意,您必须将type_name
写入两次。.
结束一条语句。但是,您可以通过使用and
开始下一个语句来“链接”对象上的方法调用。另外,如何引用名为Close
的变量而不是字符串"Close"
?哎呀,我们甚至在普通英语中也遇到了这个问题:“说出你的名字”和“说出“你的名字””之间有什么区别?mouse click
是一个包含空格的标识符,应该是mouseClick
。instructions are
定义了一个 lambda(请参阅is
与are
关键字混淆造成麻烦了吗?)。您关闭窗口
调用window.close()
。指令结束
是 lambda 的结束。所有这些都比需要的时间长。还记得这一切吗?这些只是我对语法的猜测,可能是完全错误的。看起来还是很简单?如果是这样,请尝试编写一个更大的程序,而不违反任何这些规则,以及定义条件逻辑、循环、类、泛型等内容所需的附加规则,继承,或者任何你需要的东西。您所做的就是将常规编程语言中的符号更改为“自然语言”等效项,这些符号更难记住、不必要地冗长且更加模糊。
试试这个翻译:
看看每一行如何映射到前面示例中的对应行,但更直接地说明意图?自然语言可能有利于人类执行,但很难用于精确的规范。
你越努力让英语轻松、清晰地传达这些想法,它就越像我们已经拥有的编程语言。简而言之,编程语言在不失去清晰度和简单性的情况下尽可能接近自然语言。 :D
The code may look like natural language, but it's really just regular computer code with different keywords. In your example,
I want
is probably synonymous withnew
. It's not like you can use natural language directly and saymake me a window
instead (and if you could, things would get even uglier...).Lets take a close look at your code and the language implications:
i want
meansnew
,and
denotes beginning of the argument list.the <type_name> <member_name> is
sets instance variablemember_name
on the object being created. Note that you have to write thetype_name
twice..
ends a statement. However, you can 'chain' method calls on an object by starting the next statement withand
. Also, how do you refer to a variable namedClose
instead of the string"Close"
? Heck, we even have this problem in regular English: what the difference between 'Say your name' and 'Say "your name"'?mouse click
is an identifier containing a space, should bemouseClick
.instructions are
defines a lambda (see theis
vs.are
keyword confusion causing trouble yet?).you close window
callswindow.close()
.end of instructions
is end of a lambda. All of these are longer than they need to be.Remember all that? And those are only my guesses at the syntax, which could be completely wrong. Still seem simple? If so, try writing a larger program without breaking any of those rules, AND the additional rules you'll need to define things like conditional logic, loops, classes, generics, inheritance, or whatever else you'll need. All you're doing is changing the symbols in regular programming languages to 'natural language' equivalents that are harder to remember, unnecessarily verbose, and more ambiguous.
Try this translation:
See how each line maps to its counterpart in the previous example, but states the intent more directly? Natural language may be good for execution by humans, but it is terribly difficult to use for precise specifications.
The more you try to make English communicate these ideas easily and clearly, the more it's going to look like programming languages we already have. In short, programming languages are as close to natural language as we can get without losing clarity and simplicity. :D
由于编程的根本困难在于让你的思想足够有序以告诉计算机该做什么,因此使语言变得更“自然”不太可能使其更容易被非程序员使用;语言本身从来就不是真正的问题。更重要的是,所有这些额外的混乱的自然语言对任何程序员(名副其实)所做的事情都没有帮助,那么为什么要添加它呢?
或者我们能否拥有一种真正的自然语言编程语言,包含“嗯”、“呃”和“哦,我真的不知道”? :-)
Since the fundamental difficulty of programming is getting your thoughts ordered enough to tell the computer what to do, making the language more “natural” is highly unlikely to make it more accessible to non-programmers; the language itself was never the real problem in the first place. What's more, all that extra clutter of natural language doesn't help any programmers (worth the name) with what they're doing either, so why add it?
Or can we have a real natural language programming language, complete with “Um”, “Er”, and “Oh, I don't really know”? :-)
Edsger W. Dijkstra,论“自然语言编程”的愚蠢。我没什么可补充的。
Edsger W. Dijkstra, On the foolishness of "natural language programming". I have nothing to add.
您在上面向我们展示的编程语言极其冗长(因为它看起来甚至比 COBOL 还要冗长)。
这带来了几个问题:
The programming language you have showed us above is extremely verbose (as it seems even more than COBOL).
This comes with several problems:
它们是否更好只是个人观点,但这看起来像是 COBOL 和 BASIC 的某种变异杂交,这绝对是非常糟糕的。
所以我认为,不。我认为仍然使用可读动词/形容词/名称的中肯语言更好(C++、C#、PHP 等是我的首选语言)。
有些语言开始变得过于高级和/或冗长,使得实际逻辑变得如此抽象,以至于很难知道什么是做什么的。有些过于低级和简短,迫使您明确说明您想要完成的所有事情。可读性和简洁性以及功能和灵活性之间的平衡对于开发来说是最好的。
Whether they're better or not is opinion, but that looks like some mutated cross of COBOL and BASIC, which is most definitely epically bad.
So in my opinion, no. I think somewhat to-the-point languages that still use readable verbs/adjectives/names are better (C++, C#, PHP, etc are my preferred languages).
Some languages start to get too high-level and/or verbose, making the actual logic so abstracted it's hard to know what does what. Some are too low-level and brief, forcing you to explicitly state everything you want done. A balance between readability and brevity, with power and flexibility, is what is best for development.
我会勇敢地在这里提出稍微不同的意见。
除了问题中提出的内容之外,我还没有看到过这种语言的任何内容,但是看看它,我不得不说它对于非程序员来说可能更具可读性。另一方面,对于程序员来说,这不会损害可读性,但也没有帮助,因为我们习惯了阅读代码。
在实际开发方面,我认为必须输入这么多额外的位是很可怕的,特别是如果您像我们程序员一样习惯于简洁的关键字和结构。
但让我们想象一下在遥远的未来,语音识别实际上是准确的。我认为像这样的语言通过与计算机对话会更容易编码,我不想指定每个括号等。不必这样做将有助于保持你的思路。
结论:
I'll be brave and offer a slightly different opinion here.
I haven't seen anything of this language other than what has been presented in the question, but looking at that I'd have to say it probably is much more readable for a non-programmer. For a programmer on the other hand it won't hurt readability, but it won't help either because we're used to reading code.
On the actual development side of things, I think it would be horrible to have to type so many extra bits especially if you're used to succinct keywords and constructions like us programmers.
But let's imagine a far away future where speech recognition is actually accurate. I think a language like this would be far easier to code by talking to your computer, I'd hate to have to specify every parenthesis and such. Not having to do that would help keep your train of thought.
In conclusion:
在我看来,使用这种“人类语言”并没有真正有用的优势,因为你仍然需要语法和特殊单词。你必须学习它们,因为这是必要的,所以学习“编程语言”不会更困难,它有很多优点,因为它是面向机器的结构而不是人类的思维方式。
如果你想编写好的程序,你需要思考机器的工作方式,而编程语言绝对比人类语言更能表达这种思维方式。
In my opinion there is no really useful advantage in using that kind of "human language", because you still need a syntax and special words. You have to learn both of them, and because that's necessary it would be not much more difficult to learn a "programming language", which gives lots of advantages because it is oriented at the machine's structure and not at the human's way of thinking.
You will need to think the way the machine works if you want to write good programs, and a programming language is definitely more powerful to express that way of thinking than human language.
这些语言的一个问题是:假设您用这种语言编写应用程序的重要部分,然后需要不同的人来维护、扩展或以其他方式更改代码。
你要找谁来做这件事?街上没有人会知道这一点,而其他人将会有一个陡峭的学习曲线。
我们还假设您有一个关于如何完成语言任务的问题,您会转向哪里?
One problem with these languages is: Say you write significant portions of your app in this language and then need different people to maintain,extend or otherwise change the code.
Who are you going to get to do this ? Nobody off the street is going to know it and others are going to have a steep learning curve.
Let's also assume you have a question on how to accomplish a task the language, where do you turn ?
那么完美的编程语言将是英语的精确副本。您可以告诉计算机做一些事情,就像您点一杯咖啡或给班级布置作业一样。然而,这种语言的实现极其困难(需要先进的人工智能)。
Well the perfect programming language would be an exact copy of the English Language. You could just tell your computer to do some stuff in the same way you might order a coffee or give homework to your class. However, such a language would be extremely difficult to implement (an advanced A.I would be necessary).