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


当前回答

这些差异正变得越来越不重要。传统上,脚本语言扩展了现有的程序……我认为这就是“脚本”的主要定义,它指的是为现有实体编写一组执行指令。然而,脚本语言起源于专有的和口语化的语法,现在流行的大多数脚本语言都与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?

其他回答

在世界还很年轻的时候,在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

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

最初,有编写程序的语言,如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.

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

所有脚本语言都是编程语言。

语言并不被归类为脚本——这完全取决于执行环境。

如果环境是解释环境,则通常称为脚本环境。

除了脚本语言是解释性的,而编程语言是编译性的,还有一个不同之处,如下所示,我想这一点已经被忽略了。

脚本语言是一种编程语言,用于操作、定制和自动化现有系统的设施。在这样的系统中,通过用户界面已经可以获得有用的功能,而脚本语言是一种将该功能暴露给程序控制的机制。

而编程语言通常用于从头开始编写系统代码。

src ECMA

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

谢谢 Nitish K. Jha