有人能解释一下脚本语言和程序设计语言的区别吗? 你也可以举一些例子。我谷歌了很多,但我总是从Stack Overflow找到最好的答案。
当前回答
脚本语言是不需要显式编译步骤的编程语言。
例如,在正常情况下,必须先编译C程序才能运行它。但在正常情况下,在运行JavaScript程序之前不必编译它。所以JavaScript有时被称为“脚本”语言。
随着现代硬件和现代编译技术的发展,编译的速度越来越快,这条界限变得越来越模糊。例如,谷歌Chrome中的JavaScript引擎V8(在浏览器之外也经常使用)实际上是将JavaScript代码实时编译为机器代码,而不是解释它。(实际上,V8是一个优化的两阶段编译器。)
Also note that whether a language is a "scripting" language or not can be more about the environment than the language. There's no reason you can't write a C interpreter and use it as a scripting language (and people have). There's also no reason you can't compile JavaScript to machine code and store that in an executable file (and people have). The language Ruby is a good example of this: The original implementation was entirely interpreted (a "scripting" language), but there are now multiple compilers for it.
一些“脚本”语言的例子(例如,传统上使用的语言没有显式的编译步骤):
Lua JavaScript VBScript和VBA Perl
还有一小部分传统上用于显式编译步骤的代码:
C c++ D Java(但请注意Java被编译为字节码,然后在运行时解释和/或重新编译) 帕斯卡
...然后你就有了像Python这样的东西,它们在两个阵营中都有:Python被广泛使用,没有编译步骤,但主要实现(CPython)是通过动态编译字节码,然后在VM中运行字节码来实现的,它可以将字节码写入文件(。Pyc, .pyo),无需重新编译即可使用。
这只是极少数,如果你做一些研究,你会发现更多。
其他回答
脚本语言
脚本语言是在另一个程序中解释的。JavaScript被嵌入到浏览器中,并由该浏览器进行解释。
脚本语言示例
JavaScript Perl Python
脚本语言的优点:
简单——脚本语言比编程更容易编写 语言。 更少的代码行数
编程语言
像Java这样的编程语言是由另一个应用程序以同样的方式编译和解释的。
编程语言示例
C c++和 Java
更多的细节
http://www.yorku.ca/nmw/facs1939f13/javascript_all/js_scriptingVSprogramming.html http://www.killersites.com/blog/2005/scripting-vs-programming-is-there-a-difference/
要理解脚本语言和程序设计语言之间的区别,就必须理解脚本语言诞生的原因。
最初,有编写程序的语言,如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.
最后,脚本语言也被认为是编程语言(尽管有些人拒绝接受这一点)——我们在这里应该使用的术语是脚本语言与编译语言的对比。
脚本语言是不需要显式编译步骤的编程语言。
例如,在正常情况下,必须先编译C程序才能运行它。但在正常情况下,在运行JavaScript程序之前不必编译它。所以JavaScript有时被称为“脚本”语言。
随着现代硬件和现代编译技术的发展,编译的速度越来越快,这条界限变得越来越模糊。例如,谷歌Chrome中的JavaScript引擎V8(在浏览器之外也经常使用)实际上是将JavaScript代码实时编译为机器代码,而不是解释它。(实际上,V8是一个优化的两阶段编译器。)
Also note that whether a language is a "scripting" language or not can be more about the environment than the language. There's no reason you can't write a C interpreter and use it as a scripting language (and people have). There's also no reason you can't compile JavaScript to machine code and store that in an executable file (and people have). The language Ruby is a good example of this: The original implementation was entirely interpreted (a "scripting" language), but there are now multiple compilers for it.
一些“脚本”语言的例子(例如,传统上使用的语言没有显式的编译步骤):
Lua JavaScript VBScript和VBA Perl
还有一小部分传统上用于显式编译步骤的代码:
C c++ D Java(但请注意Java被编译为字节码,然后在运行时解释和/或重新编译) 帕斯卡
...然后你就有了像Python这样的东西,它们在两个阵营中都有:Python被广泛使用,没有编译步骤,但主要实现(CPython)是通过动态编译字节码,然后在VM中运行字节码来实现的,它可以将字节码写入文件(。Pyc, .pyo),无需重新编译即可使用。
这只是极少数,如果你做一些研究,你会发现更多。
所有脚本语言都是编程语言。
语言并不被归类为脚本——这完全取决于执行环境。
如果环境是解释环境,则通常称为脚本环境。
脚本语言是编程语言的一个子集。
脚本语言不会被用户编译成机器码(python、perl、shell等)。相反,另一个程序(称为解释器,运行程序并模拟其行为) 一些不是脚本的编程语言(C、c++、Haskell和其他“编译”语言)被编译成机器代码,然后运行。