Ruby是脚本语言还是解释语言? [英] Is Ruby a scripting language or an interpreted language?

查看:931
本文介绍了Ruby是脚本语言还是解释语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚注意到,在Ruby的Wikipedia页面中,该语言被定义为解释语言.
我了解我的背景中可能缺少一些东西.
我一直都知道不需要编译器的解释语言和需要在执行程序之前先进行编译的编译语言之间的区别,但是脚本语言的特征是什么?
Ruby是否可以定义为脚本语言?

谢谢您,请原谅我没事

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

推荐答案

事物不仅是黑白的.至少它们也大小不一,响亮而安静,蓝色和橙色,灰色和灰色,长短,对与错,等等.

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:

  • 解释/编译取决于语言的实现,而不取决于语言(这不只是理论,确实有相当多的语言同时具有解释器和编译器)
  • 有些语言实现(很多,包括大多数Ruby实现)都是编译器,但是仅"编译为字节码并解释该字节码.
  • 也有一些实现在解释和编译到本机代码(JIT编译器)之间切换.

您看到,现实是一个复杂的野兽;)如上所述,Ruby是经常编译的.然后至少在某些情况下会解释该编译的输出-还有一些JIT编译的实现(Rubinius和IIRC JRuby会在一段时间后编译为Java字节码).参考实现已经很长时间了,而IIRC仍然是.那么Ruby是解释还是编译的?除非您定义它,否则这两个术语都没有意义;)

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 ;)

但是回到问题:脚本语言"也不是该语言的属性,它取决于该语言的使用方式,即该语言是否用于脚本任务.如果您要查找定义,则"脚本语言"上的Wikipedia页面可能会有所帮助(只是不要让它们将您与实现细节的注释混淆,例如通常会解释脚本).确实有一些程序使用Ruby来执行脚本任务,并且毫无疑问,有许多独立的Ruby程序很可能会被视为脚本(Web抓取,系统管理等).

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称为脚本语言.当然,这并不意味着在Rails Web应用程序上使用ruby只是一个脚本.

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是脚本语言还是解释语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆