有人能解释一下脚本语言和程序设计语言的区别吗? 你也可以举一些例子。我谷歌了很多,但我总是从Stack Overflow找到最好的答案。


当前回答

在世界还很年轻的时候,在PC世界中,你可以从。exe或。bat中选择,描述很简单。Unix系统一直都有shell脚本(/bin/sh, /bin/csh, /bin/ksh等)和编译语言(C/ c++ /Fortran)。

To differentiate roles and responsibilities, the compiled languages (often referred to as 3rd Generation Languages) were seen a 'programming' languages and 'scripting' languages were seen as those that invoked an interpreter (often referred to as 4th Generation Languages). Scripting languages were often used as 'glue' to connect between multiple commands/compiled programs so that the user didn't have to worry about a set of steps in order to carry out their task - they developed a single file, that delineated what steps they wanted to accomplish, and this became a 'script' for anyone to follow.

Various people/groups wrote new interpreters to solve a specific problem domain. awk is one of the better-known ones, and it was used mostly for pattern matching and applying a series of data transforms on input. It worked well, but had a limited problem domain. The expansion of that domain was all but impossible because the source code was unavailable. Perl (Larry Wall, principle author/architect) tool scripting to the next level - and developed an interpreter that not only allowed the user to run system commands, manipulate input and output data, supported typeless variables, but also to access Unix system level APIs as functions from within the scripts themselves. It was probably one of the first widely used high-level scripting languages. It is with Perl (IMHO) that scripting languages crossed the arbitrary line and added the capabilities of programming languages.

你的问题是关于Python的。因为python解释器是针对包含python代码的文本文件运行的,而且python代码可以在任何有python解释器的地方运行,所以我认为它是一种脚本语言(与Perl相同)。您不需要为每个不同的OS/CPU架构重新编译用户python命令文件(就像使用C/ c++ /Fortran一样),这使得它更易于移植和使用。

这个答案要归功于杰罗德·海曼(Jerrold Heyman)。 原帖:https://www.researchgate.net/post/Is_Python_a_Programming_language_or_Scripting_Language

其他回答

在世界还很年轻的时候,在PC世界中,你可以从。exe或。bat中选择,描述很简单。Unix系统一直都有shell脚本(/bin/sh, /bin/csh, /bin/ksh等)和编译语言(C/ c++ /Fortran)。

To differentiate roles and responsibilities, the compiled languages (often referred to as 3rd Generation Languages) were seen a 'programming' languages and 'scripting' languages were seen as those that invoked an interpreter (often referred to as 4th Generation Languages). Scripting languages were often used as 'glue' to connect between multiple commands/compiled programs so that the user didn't have to worry about a set of steps in order to carry out their task - they developed a single file, that delineated what steps they wanted to accomplish, and this became a 'script' for anyone to follow.

Various people/groups wrote new interpreters to solve a specific problem domain. awk is one of the better-known ones, and it was used mostly for pattern matching and applying a series of data transforms on input. It worked well, but had a limited problem domain. The expansion of that domain was all but impossible because the source code was unavailable. Perl (Larry Wall, principle author/architect) tool scripting to the next level - and developed an interpreter that not only allowed the user to run system commands, manipulate input and output data, supported typeless variables, but also to access Unix system level APIs as functions from within the scripts themselves. It was probably one of the first widely used high-level scripting languages. It is with Perl (IMHO) that scripting languages crossed the arbitrary line and added the capabilities of programming languages.

你的问题是关于Python的。因为python解释器是针对包含python代码的文本文件运行的,而且python代码可以在任何有python解释器的地方运行,所以我认为它是一种脚本语言(与Perl相同)。您不需要为每个不同的OS/CPU架构重新编译用户python命令文件(就像使用C/ c++ /Fortran一样),这使得它更易于移植和使用。

这个答案要归功于杰罗德·海曼(Jerrold Heyman)。 原帖:https://www.researchgate.net/post/Is_Python_a_Programming_language_or_Scripting_Language

我认为你所说的“差异”实际上是真实差异的结果。

实际的区别在于所编写代码的目标。谁来运行这段代码。

脚本语言用于编写针对软件系统的代码。它将对软件系统进行自动化操作。脚本将是目标软件系统的指令序列。

编程语言的目标是计算系统,可以是真实的也可以是虚拟机。指令是由机器执行的。

当然,真正的机器只理解二进制代码,因此您需要编译编程语言的代码。但这是针对机器而不是程序的结果。

另一方面,脚本的目标软件系统可以编译代码或解释它。由软件系统决定。

如果我们说真正的区别是它是否被编译,那么我们就有一个问题,因为Javascript在V8中运行时是编译的,而在Rhino中运行时不是。

由于脚本语言已经进化得非常强大,所以它变得更加令人困惑。因此,它们不局限于创建小脚本来自动化另一个软件系统上的操作,您可以使用它们创建任何丰富的应用程序。

Python代码以解释器为目标,因此我们可以说它“脚本化”了解释器上的操作。但是,当你编写Python代码时,你不会将其视为编写解释器脚本,而是将其视为创建应用程序。解释器只是用于在更高级别上编写代码。所以对我来说,Python更像是一种编程语言,而不是脚本语言。

脚本语言是人们认为是脚本语言的编程语言。 这是一个没有明确边界的人为类别,而且每条提议的规则都有例外。

经典的规则用来说一种语言是一种脚本语言是表征,而不是定义。如果一种语言满足许多规则,那么它很有可能被认为是一种脚本语言。如果不是,很有可能不是。规则通常包括:

它适用于小型“脚本”,而不是大型程序。 它被嵌入到另一个应用程序中,用于该应用程序的小修改。 它是解释的,而不是编译的。 它是为新手程序员设计的,而不是专业人员。 它的名字以“script”结尾。

我还要补充说:

脚本语言是一种几乎所有错误都在运行时被检测到的编程语言。

也就是说,它可以是一种解释语言。

如果一种编程语言具有显著的“编译时”行为,即在不运行程序的情况下分析代码并报告错误,例如来自C、Java或c#的类型错误,那么它很可能不被认为是一种脚本语言。

传统上,很多脚本语言都是直接从源代码解释的,但更流行的脚本语言都有更高性能的实现,可以预编译代码,比如Python的.pyc文件,或者优化JavaScript引擎,在运行之前将其编译为本机代码。

如果该语言可以由解释器实现,解释器在运行时只查看源代码,那么它很可能被认为是脚本语言。它是否真的以这种方式实现并不重要,但如果可以,那么它也不需要对代码进行广泛的编译时错误检查。

如果该语言提供了一种有用的静态语义,可以帮助检测错误(除了语法错误),而不需要运行程序,那么它可能不是一种脚本语言。

总会有例外,通常是基于一种语言的传统,而不是任何实际的规则。 BASIC通常不被认为是一种“脚本语言”,尽管它几乎满足了任何人曾经使用过的作为脚本语言的所有标准。这就是为什么Visual Basic Script必须在名称中添加“脚本”,以区别于Visual Basic,后者是一种“真正的”用于大型程序的编程语言。

BASIC也是一种古老的编程语言,就像COBOL和Fortran一样,在人们期望从语言中获得静态分析之前,基本上在“脚本语言”出现之前。

要理解脚本语言和程序设计语言之间的区别,就必须理解脚本语言诞生的原因。

最初,有编写程序的语言,如excel, word,浏览器,游戏等。这些程序是用c和java等语言编写的。随着时间的推移,这些程序需要用户创建新功能的方法,因此它们必须为字节码提供接口,因此脚本语言诞生了。

脚本语言通常是不编译的,所以只要你写了一些有意义的东西就可以运行。因此,excel可以使用c++构建,但它公开了一种名为VBA的脚本语言供用户定义功能。类似地,浏览器可以用c++ /Java构建,但它们暴露了一种称为javascript的脚本语言(与Java没有任何关系)。游戏通常是用c++构建的,但会公开一种名为Lua的语言供用户定义自定义功能。

脚本语言通常位于某些编程语言之后。脚本语言通常很少访问计算机的本机功能,因为它们运行在原始编程语言的子集上。这里的一个例子是Javascript将无法访问您的文件系统。脚本语言通常比编程语言慢。

Although scripting languages may have less access and are slower, they can be very powerful tools. One factor attributing to a scripting languages success is the ease of updating. Do you remember the days of java applets on the web, this is an example of running a programming language (java) vs running a scripting language (javascript). At the time, computers were not as powerful and javascript wasn't as mature so Java applets dominated the scenes. But Java applets were annoying, they required the user to sort of load and compile the language. Fast forward to today, Java applets are almost extinct and Javascript dominates the scene. Javascript is extremely fast to load since most of the browser components have been installed already.

最后,脚本语言也被认为是编程语言(尽管有些人拒绝接受这一点)——我们在这里应该使用的术语是脚本语言与编译语言的对比。

如果我们从逻辑上看编程语言和脚本语言,这是99.09%相同的。因为我们使用相同的概念,如循环、控制条件、变量等等,所以我们可以说两者都是相同的,但它们之间只有一件事是不同的,那就是在C/ c++和其他编程语言中,我们在执行前编译代码。但在PHP, JavaScript和其他脚本语言中,我们不需要编译,我们直接在浏览器中执行。

谢谢 Nitish K. Jha