有人能解释一下脚本语言和程序设计语言的区别吗? 你也可以举一些例子。我谷歌了很多,但我总是从Stack Overflow找到最好的答案。
当前回答
编程语言: 编译为机器码并在底层操作系统的硬件上运行。
脚本语言: 是编程语言的非结构子集。这是一般的解释。 它基本上是“脚本”其他事情来做事情。主要的重点不是构建你自己的应用程序,而是让现有的应用程序以你想要的方式运行,例如浏览器的JavaScript, TCL等。
***但也有编程语言被转换为解释器的情况,反之亦然,比如使用C解释器,你可以使用C脚本。 脚本通常用于控制应用程序的行为,而编程语言则用于构建应用程序。 但要注意的是,这种界限正在日益模糊——作为Python的一个例子,它取决于你如何使用这种语言。
其他回答
除了脚本语言是解释性的,而编程语言是编译性的,还有一个不同之处,如下所示,我想这一点已经被忽略了。
脚本语言是一种编程语言,用于操作、定制和自动化现有系统的设施。在这样的系统中,通过用户界面已经可以获得有用的功能,而脚本语言是一种将该功能暴露给程序控制的机制。
而编程语言通常用于从头开始编写系统代码。
src ECMA
编程语言: 编译为机器码并在底层操作系统的硬件上运行。
脚本语言: 是编程语言的非结构子集。这是一般的解释。 它基本上是“脚本”其他事情来做事情。主要的重点不是构建你自己的应用程序,而是让现有的应用程序以你想要的方式运行,例如浏览器的JavaScript, TCL等。
***但也有编程语言被转换为解释器的情况,反之亦然,比如使用C解释器,你可以使用C脚本。 脚本通常用于控制应用程序的行为,而编程语言则用于构建应用程序。 但要注意的是,这种界限正在日益模糊——作为Python的一个例子,它取决于你如何使用这种语言。
这些差异正变得越来越不重要。传统上,脚本语言扩展了现有的程序……我认为这就是“脚本”的主要定义,它指的是为现有实体编写一组执行指令。然而,脚本语言起源于专有的和口语化的语法,现在流行的大多数脚本语言都与C有某种关系。
I think the "interpreted vs compiled" distinction is really a symptom of extending an existing program (with a built in interpreter), rather than an intrinsic difference. What programmers and laymen are more concerned about is, "what is the programmer doing?" The fact that one program is interpreted and another is compiled means very little in determining the difference in activity by the creator. You don't judge a playwright on whether his plays are more commonly read aloud or performed on stage, do you?
脚本语言是人们认为是脚本语言的编程语言。 这是一个没有明确边界的人为类别,而且每条提议的规则都有例外。
经典的规则用来说一种语言是一种脚本语言是表征,而不是定义。如果一种语言满足许多规则,那么它很有可能被认为是一种脚本语言。如果不是,很有可能不是。规则通常包括:
它适用于小型“脚本”,而不是大型程序。 它被嵌入到另一个应用程序中,用于该应用程序的小修改。 它是解释的,而不是编译的。 它是为新手程序员设计的,而不是专业人员。 它的名字以“script”结尾。
我还要补充说:
脚本语言是一种几乎所有错误都在运行时被检测到的编程语言。
也就是说,它可以是一种解释语言。
如果一种编程语言具有显著的“编译时”行为,即在不运行程序的情况下分析代码并报告错误,例如来自C、Java或c#的类型错误,那么它很可能不被认为是一种脚本语言。
传统上,很多脚本语言都是直接从源代码解释的,但更流行的脚本语言都有更高性能的实现,可以预编译代码,比如Python的.pyc文件,或者优化JavaScript引擎,在运行之前将其编译为本机代码。
如果该语言可以由解释器实现,解释器在运行时只查看源代码,那么它很可能被认为是脚本语言。它是否真的以这种方式实现并不重要,但如果可以,那么它也不需要对代码进行广泛的编译时错误检查。
如果该语言提供了一种有用的静态语义,可以帮助检测错误(除了语法错误),而不需要运行程序,那么它可能不是一种脚本语言。
总会有例外,通常是基于一种语言的传统,而不是任何实际的规则。 BASIC通常不被认为是一种“脚本语言”,尽管它几乎满足了任何人曾经使用过的作为脚本语言的所有标准。这就是为什么Visual Basic Script必须在名称中添加“脚本”,以区别于Visual Basic,后者是一种“真正的”用于大型程序的编程语言。
BASIC也是一种古老的编程语言,就像COBOL和Fortran一样,在人们期望从语言中获得静态分析之前,基本上在“脚本语言”出现之前。
在世界还很年轻的时候,在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