什么是计算机编程语言? [英] What is a computer programming language?

查看:65
本文介绍了什么是计算机编程语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

冒着听起来幼稚的风险,我提出这个问题是为了更深入地了解编程语言的一般概念.我写这个问题是为了我自己的启迪和他人的启迪.

At the risk of sounding naive, I ask this question in search of a deeper understanding of the concept of programming languages in general. I write this question for my own edification and the edification of others.

什么是计算机编程语言的有用定义?它的基本和必要组件是什么?区分语言的关键特性是什么(函数式、命令式、声明式、面向对象、脚本等...)?

What is a useful definition of a computer programming language and what are its basic and necessary components? What are the key features that differentiate languages (functional, imperative, declarative, object oriented, scripting, etc...)?

思考这个问题的一种方式.想象一下,您正在查看现代台式机或笔记本电脑的硬件.假设不存在 C 语言或其任何变体.根据我们今天对个人计算机的期望,您会如何向其他人描述使计算机具有表现力和功能所需的所有东西?

One way to think about this question. Imagine you are looking at the hardware of a modern desktop or laptop computer. Assume, that the C language or any of its variants do not exist. How would you describe to others all the things needed to make the computer expressive and functional in terms of what we expect of personal computers today?

切线相关,允许其他语言存在的计算机语言是什么?例如,采用脚本语言,如 Javascript、Perl 或 PHP.我假设这些定义的一部分是最有可能在某个级别用 C 或 C++ 实现的解释器.是否可以在 Javascript 中为 Javascript 编写解释器?这是对完整语言的要求吗?Perl、PHP 等也一样?

Tangentially related, what is it about computer languages that allow other languages to exist? For example take a scripting language like Javascript, Perl, or PHP. I assume part of the definition of these is that there is an interpreter most likely implemented in C or C++ at some level. Is it possible to write an interpreter for Javascript in Javascript? Is this a requirement for a complete language? Same for Perl, PHP, etc?

我会对可以查找或进一步研究的概念列表感到满意.

I would be satisfied with a list of concepts that can be looked up or researched further.

推荐答案

与任何语言一样,编程语言只是一种表达和传达想法的交流工具.在这种情况下,我们正在将我们关于软件应该如何工作的想法转化为一种结构化和有条理的形式,以便计算机(以及在大多数情况下其他懂该语言的人)可以阅读和理解.

Like any language, programming languages are simply a communication tool for expressing and conveying ideas. In this case, we're translating our ideas of how software should work into a structured and methodical form that computers (as well as other humans who know the language, in most cases) can read and understand.

什么是计算机编程语言的有用定义?它的基本和必要组件是什么?

What is a useful definition of a computer programming language and what are its basic and necessary components?

我想说一种编程语言的定义特征如下:用这种语言编写的东西最终会被转换成可以执行的东西.因此,伪代码虽然可能具有编程语言的结构和严谨性,但实际上并不是一种编程语言.同样,UML 可以像编程语言一样以抽象的方式表达许多强大的思想,但它有不足之处,因为人们通常不会编写 UML 来执行.

I would say the defining characteristic of a programming language is as follows: things written in that language are intended to eventually be transformed into something that is executed. Thus, pseudocode, while perhaps having the structure and rigor of a programming language, is not actually a programming language. Likewise, UML can express many powerful ideas in an abstract manner just like a programming language can, but it falls short because people don't generally write UML to be executed.

根据我们今天对个人计算机的期望,您如何向其他人描述使计算机具有表现力和功能所需的所有东西?

How would you describe to others all the things needed to make the computer expressive and functional in terms of what we expect of personal computers today?

即使编程语言"这个词不是我与之交谈的小组的共享词汇的一部分,我认为对其他人来说很明显我们需要一种与计算机进行交流的方式.正如没有人期望汽车在没有与方向盘和踏板交互的形式的外部指令的情况下自动驾驶(现在!),没有人可以期望硬件在没有被告知要做什么的情况下运行.如上所述,编程语言是我们实现沟通的渠道.

Even if the word "programming language" wasn't part of the shared vocabulary of the group I was talking to, I think it would be obvious to the others that we'd need a way to communicate with the computer. Just as no one expects a car to drive itself (yet!) without external instructions in the form of interaction with the steering wheel and pedals, no one could expect the hardware to function without being told what to do. As noted above, a programming language is the conduit through which we can make that communication happen.

切线相关,允许其他语言存在的计算机语言是什么?

Tangentially related, what is it about computer languages that allow other languages to exist?

所有有用的编程语言都有一个称为图灵完备性的属性.如果图灵完备集中的一种语言可以做某事,那么它们中的任何一种都可以;据说它们在计算上是等价的.

All useful programming languages have a property called Turing completeness. If one language in the Turing-complete set can do something, then any of them can; they are said to be computationally equivalent.

然而,仅仅因为它们同样强大"并不意味着它们同样适合人类工作.这就是为什么许多人愿意牺牲您从编写汇编代码中获得的无与伦比的微观管理,以换取您在 Ruby、Python 或 C# 等高级语言中获得的表现力和功能.

However, just because they're equally "powerful" doesn't mean they're equally nice to work with for humans. This is why many people are willing to sacrifice the unparalleled micromanagement you get from writing assembly code in exchange for the expressiveness and power you get with higher-level languages, like Ruby, Python, or C#.

是否可以在 Javascript 中为 Javascript 编写解释器?这是对完整语言的要求吗?Perl、PHP 等也一样?

Is it possible to write an interpreter for Javascript in Javascript? Is this a requirement for a complete language? Same for Perl, PHP, etc?

由于有一个用 C 编写的 Javascript 解释器,因此必须可以用 Javascript 编写一个 Javascript 解释器,因为两者都是图灵完备的.然而,再次请注意,图灵完备性并未说明用一种语言与另一种语言做某事有多难——只说明是否有可能开始.您的 Javascript-interpreter-inside-Javascript 可能会非常低效,消耗大量内存,需要巨大的处理能力,并且是一个丑陋的黑客.但是图灵完备性保证可以做到!

Since there is a Javascript interpreter written in C, it follows that it must be possible to write a Javascript interpreter in Javascript, since both are Turing-complete. However, again, note that Turing-completeness says nothing about how hard it is to do something in one language versus another -- only whether it is possible to begin with. Your Javascript-interpreter-inside-Javascript might well be horrendously inefficient, consume absurd amounts of memory, require enormous processing power, and be a hideously ugly hack. But Turing-completeness guarantees it can be done!

这篇关于什么是计算机编程语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆