什么是正式的编程语言?
编程语言是正式编程语言是什么意思?哪些语言是正式的编程语言?哪些是非正式编程语言?
我还没有找到很好的解释。
What does it mean that a programming language is a formal programming language? And which languages are formal programming languages? And which are informal programming languages?
I haven't found a good explanation yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
每种编程语言都是一种形式语言,因此对我来说,谈论“形式编程语言”没有多大意义。 (或者有人知道非正式的编程语言吗?)
正式语言是一种具有数学上精确的构造规则的语言。或者,更准确地说,它是某个字母表上的一组单词。例如,如果您采用由字母
a
、b
和c
组成的字母表,则该字母表的正式语言可以是集合 {<代码>a,aa
,aba
,ca
}。当然,这样的语言不会很有用——关键是,通过一套合适的构造规则,您可以创建诸如 C 或 PostScript 之类的语言。至于“构造规则”,它们可以是正式语法(请参阅语法 CSS),正则表达式(请参阅此华丽电子邮件地址的正则表达式(由 RFC 822 定义)、自动机或通用算法。
如果您觉得自己对这个问题还不太理解,请不要绝望,因为这不是一个很好的解释:-) 形式语言的概念背后有很多思考。我建议您尝试消化维基百科条目并寻找更多教程和书籍。这很有趣,你会学到很多关于编译器、正则表达式、图灵机和数字人类的其他奇迹的背景。
Every programming language is a formal language, so that it does not make much sense to me to speak of a “formal programming language.” (Or does somebody know an informal programming language?)
Formal language is a language with mathematically precise construction rules. Or, more precisely, it’s a set of words over some alphabet. For example, if you take alphabet consisting of the letters
a
,b
andc
, a formal language over this alphabet could be a set {a
,aa
,aba
,ca
}. Of course such a language would not be very useful – the point is that with a decent set of construction rules you can create a language such as C or PostScript.As for the “construction rules,” they could be a formal grammar (see grammar for CSS), a regular expression (see this gorgeous regex for e-mail addresses as defined by RFC 822), an automaton or a general algorithm.
If you feel you don’t understand the thing a tiny bit more, do not despair, for this is not a very good explanation :-) There’s a lot of thinking behind the concept of formal languages. I’d suggest that you try and digest the Wikipedia entry and look for more tutorials and books. It’s fun and you will learn a lot about the background of compilers, regular expressions, Turing machines and other wonders of digital mankind.
正式意味着明确定义。每种可用于定义可执行程序的编程语言都必须经过良好定义,以便机器能够理解它。
Formal means well defined. Every programming language that can be used to define executable programs has to be well defined so that machines can understand it.
它不是一种“正式语言”,而是一种正式的编程方法:Wikipedia。它不必是特定的语言,而是编写规范和验证代码的方式。
It's not a "formal language" it's a formal method of programming: Wikipedia. It needn't be a specific language but rather the way you write specification and verify the code.
这是摘自 wikipedia
“John C. Reynolds 强调形式规范语言与编程一样重要他还认为,影响计算机行为的文本甚至图形输入格式都是编程语言,尽管它们通常不是图灵完备的,并指出对编程语言概念的无知是错误的。输入格式存在许多缺陷的原因”
Thats an extract from wikipedia
"John C. Reynolds emphasizes that formal specification languages are just as much programming languages as are the languages intended for execution. He also argues that textual and even graphical input formats that affect the behavior of a computer are programming languages, despite the fact they are commonly not Turing-complete, and remarks that ignorance of programming language concepts is the reason for many flaws in input formats"
形式语言是只考虑格式良好性而不考虑其他的语言。这意味着充分必要条件是遵守其规则。
规则示例:
例如。如果我们将十进制数的语言定义为 {x |没有前导零的有限数字集}。 (简单地说,小数表示数字序列。)
因此,如果包含上述规则的语言是正式的,则应该遵守给定的规则。
但在实际使用中,如果该语言将 001 视为十进制数,我们可以断定该编程语言不是正式的,因为它不完全按照它定义的规则集。
通常语言解析器会检查这些规则。
因此,形式语言应该始终是格式良好的(严格遵循其自身的规则)
Formal languages are languages which only consider about the well-formedness nothing else. That means the sufficient and necessary condition is to adhere to its rules.
An example rule:
For eg. If we define language for decimal numbers as {x | finite set of digits without leading zeroes}. (simply put, decimals means a sequence of digits.)
So if the language containing above rule to be formal,it should adhere adhere to the given rule.
But in practical usage, if the language treats 001 as a decimal number we can conclude the programming language is not formal, Since its not exactly according to the rule set it defines.
Normally language parsers checks these rules.
So a formal language should always be well-formed (following its own rules strictly)
其他答案与计算机科学中形式编程语言的定义有关。然而,这个答案与社会(想要的)科学对正式编程语言的定义有关。
根据
dictionary.com
,“正式”的定义之一是符合通常的要求、习俗等;传统的
。正式的编程语言是一种被广泛使用并被谈论它的人接受的编程语言。因此,它是特定于领域和对话的。也许更好的措辞是“流行”,
传统”、“主流”或“广泛接受”的编程语言。例如,在商业和工业中,它指的是
SQL
、Java
、C#
、C++
、Python
和PHP
。非正式编程语言的示例有
SPL
(莎士比亚编程语言)、FORTRAN
和CoffeeScript
。更准确地说,一种语言比另一种语言更传统,因此更正式,而不是说一种语言是正式的,另一种语言是非正式的。毕竟,
Lisp
对于制作网站来说是一种非常非正式的编程语言,但对于开发人工智能研究来说却是一种非常正式的编程语言。The other answers are relating to the definition of formal programming language according to Computer Science. However, this answer is relating to the definition of formal programming language according to Social (wannabe) Science.
According to
dictionary.com
, one of the definitions for 'formal' isbeing in accordance with the usual requirements, customs, etc.; conventional
.A formal programming language is a programming language which is widely used and accepted by the person talking about it. Therefore, it is domain and conversation specific. Perhaps a better way of wording is 'popular',
traditional', 'mainstream' or 'widely-accepted' programming language. For example, in business and industry this refers to
SQL
,Java
,C#
,C++
,Python
andPHP
.Examples of informal programming languages are
SPL
(the Shakespeare Programming Language),FORTRAN
andCoffeeScript
. It is more accurate to say that one language is more conventional and thus formal than another than it is to say that one language is formal and another is informal.After all,
Lisp
would be a very informal programming language for making a website, but a very formal programming language for developing Artificial Intelligence research.