I just noticed that in the wikipedia page of Ruby, this language is defined as interpreted language.
I understood that probably there's something missing in my background.
I have always known the difference between an interpreted language that doesn't need a compiler and a compiled language (who require to be compiled before the execution of programs), but what characterize a scripting language ?
Is Ruby definable as a scripting language ?
Thank you and forgive me for the black out
我刚刚注意到在Ruby的*页面中,这种语言被定义为解释语言。我明白可能在我的背景中缺少一些东西。我一直都知道不需要编译器的解释语言和编译语言(需要在程序执行之前编译)之间的区别,但是脚本语言的特征是什么? Ruby是否可以作为脚本语言定义?谢谢你,请原谅我
3 个解决方案
#1
40
Things aren't just black and white. At the very least, they're also big and small, loud and quiet, blue and orange, grey and gray, long and short, right and wrong, etc.
事情不仅仅是黑与白。至少,它们既大又小,又大又安静,蓝色和橙色,灰色和灰色,长短,对与错等。
Interpreted/compiled is just one way to categorize languages, and it's completely independent from (among countless other things) whether you call the same language a "scripting language" or not. To top it off, it's also a broken classification:
解释/编译只是对语言进行分类的一种方式,它完全独立于(无数其他事物中)是否将同一种语言称为“脚本语言”。最重要的是,它也是一个破碎的分类:
- Interpreted/compiled depends on the language implementation, not on the language (this is not just theory, there are indeed quite a few languages for which both interpreters and compilers exist)
- 解释/编译取决于语言实现,而不是语言(这不仅仅是理论,确实有很多语言,解释器和编译器都存在)
- There are language implementations (lots of them, including most Ruby implementations) that are compilers, but "only" compile to bytecode and interpret that bytecode.
- 有些语言实现(很多,包括大多数Ruby实现)都是编译器,但“只”编译为字节码并解释该字节码。
- There are also implementations that switch between interpreting and compiling to native code (JIT compilers).
- 还有一些实现可以在解释和编译之间切换到本机代码(JIT编译器)。
You see, reality is a complex beast ;) Ruby is, as mentioned above, frequently compiled. The output of that compilation is then interpreted, at least in some cases - there are also implementations that JIT-compile (Rubinius, and IIRC JRuby compiles to Java bytecode after a while). The reference implementation has been a compiler for a long time, and IIRC still is. So is Ruby interpreted or compiled? Neither term is meaningful unless you define it ;)
你看,现实是一个复杂的野兽;)如上所述,Ruby经常被编译。然后解释该编译的输出,至少在某些情况下 - 还有JIT编译的实现(Rubinius和IIRC JRuby在一段时间后编译为Java字节码)。参考实现已经成为编译器很长一段时间了,IIRC仍然是。 Ruby是解释还是编译?除非你定义它,否则这两个术语都没有意义;)
But back to the question: "Scripting language" isn't a property of the language either, it depends on how the language is used - namely, whether the language is used for scripting tasks. If you're looking for a definition, the Wikipedia page on "Scripting language" may help (just don't let them confuse you with the notes on implementation details such as that scripts are usually interpreted). There are indeed a few programs that use Ruby for scripting tasks, and there are doubtless numerous free-standing Ruby programs that would likely qualify as scripts (web scraping, system administration, etc).
但回到这个问题:“脚本语言”也不是语言的属性,它取决于语言的使用方式 - 即语言是否用于编写脚本任务。如果您正在寻找定义,那么“脚本语言”上的*页面可能有所帮助(只是不要让他们将实际细节上的注释混淆,例如通常会解释脚本)。确实有一些程序使用Ruby来编写脚本任务,毫无疑问,许多独立的Ruby程序可能有资格作为脚本(Web抓取,系统管理等)。
So yes, I guess one can call Ruby a scripting language. Of course that doesn't mean a ruby on rails web app is just a script.
所以,是的,我猜一个人可以称Ruby为脚本语言。当然,这并不意味着rails web app上的ruby只是一个脚本。
#2
4
Yes.
是。
Detailed response:
详细回复:
A scripting language is typically used to control applications that are often not written in this language. For example, shell scripts etc. can call arbitrary console applications.
脚本语言通常用于控制通常不使用该语言编写的应用程序。例如,shell脚本等可以调用任意控制台应用程序。
Ruby is a general purpose dynamic language that is frequently used for scripting.
Ruby是一种通用的动态语言,经常用于编写脚本。
You can make arbitrary system calls using backtick notation like below.
您可以使用如下所示的反引号表示法进行任意系统调用。
`<system command>`
There are also many excellent Ruby gems such as Watir and RAutomation for automating web and native GUIs.
还有许多优秀的Ruby宝石,如Watir和RAutomation,用于自动化Web和本机GUI。
For definition of scripting language, see here.
有关脚本语言的定义,请参见此处。
#3
3
The term 'scripting language' is very broad, and it can include both interpreted and compiled languages. Ruby in particular, might compiled or interpreted depending on what particular implementation we're using - for instance, JRuby gets compiled to bytecode, whereas CRuby (Ruby's reference implementation) is interpreted
术语“脚本语言”非常广泛,它可以包括解释语言和编译语言。特别是Ruby,可能会根据我们正在使用的特定实现进行编译或解释 - 例如,JRuby被编译为字节码,而CRuby(Ruby的参考实现)被解释
#1
40
Things aren't just black and white. At the very least, they're also big and small, loud and quiet, blue and orange, grey and gray, long and short, right and wrong, etc.
事情不仅仅是黑与白。至少,它们既大又小,又大又安静,蓝色和橙色,灰色和灰色,长短,对与错等。
Interpreted/compiled is just one way to categorize languages, and it's completely independent from (among countless other things) whether you call the same language a "scripting language" or not. To top it off, it's also a broken classification:
解释/编译只是对语言进行分类的一种方式,它完全独立于(无数其他事物中)是否将同一种语言称为“脚本语言”。最重要的是,它也是一个破碎的分类:
- Interpreted/compiled depends on the language implementation, not on the language (this is not just theory, there are indeed quite a few languages for which both interpreters and compilers exist)
- 解释/编译取决于语言实现,而不是语言(这不仅仅是理论,确实有很多语言,解释器和编译器都存在)
- There are language implementations (lots of them, including most Ruby implementations) that are compilers, but "only" compile to bytecode and interpret that bytecode.
- 有些语言实现(很多,包括大多数Ruby实现)都是编译器,但“只”编译为字节码并解释该字节码。
- There are also implementations that switch between interpreting and compiling to native code (JIT compilers).
- 还有一些实现可以在解释和编译之间切换到本机代码(JIT编译器)。
You see, reality is a complex beast ;) Ruby is, as mentioned above, frequently compiled. The output of that compilation is then interpreted, at least in some cases - there are also implementations that JIT-compile (Rubinius, and IIRC JRuby compiles to Java bytecode after a while). The reference implementation has been a compiler for a long time, and IIRC still is. So is Ruby interpreted or compiled? Neither term is meaningful unless you define it ;)
你看,现实是一个复杂的野兽;)如上所述,Ruby经常被编译。然后解释该编译的输出,至少在某些情况下 - 还有JIT编译的实现(Rubinius和IIRC JRuby在一段时间后编译为Java字节码)。参考实现已经成为编译器很长一段时间了,IIRC仍然是。 Ruby是解释还是编译?除非你定义它,否则这两个术语都没有意义;)
But back to the question: "Scripting language" isn't a property of the language either, it depends on how the language is used - namely, whether the language is used for scripting tasks. If you're looking for a definition, the Wikipedia page on "Scripting language" may help (just don't let them confuse you with the notes on implementation details such as that scripts are usually interpreted). There are indeed a few programs that use Ruby for scripting tasks, and there are doubtless numerous free-standing Ruby programs that would likely qualify as scripts (web scraping, system administration, etc).
但回到这个问题:“脚本语言”也不是语言的属性,它取决于语言的使用方式 - 即语言是否用于编写脚本任务。如果您正在寻找定义,那么“脚本语言”上的*页面可能有所帮助(只是不要让他们将实际细节上的注释混淆,例如通常会解释脚本)。确实有一些程序使用Ruby来编写脚本任务,毫无疑问,许多独立的Ruby程序可能有资格作为脚本(Web抓取,系统管理等)。
So yes, I guess one can call Ruby a scripting language. Of course that doesn't mean a ruby on rails web app is just a script.
所以,是的,我猜一个人可以称Ruby为脚本语言。当然,这并不意味着rails web app上的ruby只是一个脚本。
#2
4
Yes.
是。
Detailed response:
详细回复:
A scripting language is typically used to control applications that are often not written in this language. For example, shell scripts etc. can call arbitrary console applications.
脚本语言通常用于控制通常不使用该语言编写的应用程序。例如,shell脚本等可以调用任意控制台应用程序。
Ruby is a general purpose dynamic language that is frequently used for scripting.
Ruby是一种通用的动态语言,经常用于编写脚本。
You can make arbitrary system calls using backtick notation like below.
您可以使用如下所示的反引号表示法进行任意系统调用。
`<system command>`
There are also many excellent Ruby gems such as Watir and RAutomation for automating web and native GUIs.
还有许多优秀的Ruby宝石,如Watir和RAutomation,用于自动化Web和本机GUI。
For definition of scripting language, see here.
有关脚本语言的定义,请参见此处。
#3
3
The term 'scripting language' is very broad, and it can include both interpreted and compiled languages. Ruby in particular, might compiled or interpreted depending on what particular implementation we're using - for instance, JRuby gets compiled to bytecode, whereas CRuby (Ruby's reference implementation) is interpreted
术语“脚本语言”非常广泛,它可以包括解释语言和编译语言。特别是Ruby,可能会根据我们正在使用的特定实现进行编译或解释 - 例如,JRuby被编译为字节码,而CRuby(Ruby的参考实现)被解释