Ruby是否与Java一样跨平台?

时间:2022-02-10 12:20:58

You can compile a Java application and run it in any machine where the Java virtual machine is located, independently of the underlying hardware.

您可以编译Java应用程序并在Java虚拟机所在的任何计算机上运行它,而与底层硬件无关。

Since Ruby on Rails was built upon Ruby, I'm concerned if building software in Ruby in any environment is the same or not. There exists versions of Ruby for Windows, Linux and Mac at least.

由于Ruby on Rails是基于Ruby构建的,因此我担心在任何环境中使用Ruby构建软件是否相同。至少存在适用于Windows,Linux和Mac的Ruby版本。

So, could you do the same with a Ruby application and with a Java application? In other words, how cross-platform is Ruby?

那么,你可以用Ruby应用程序和Java应用程序做同样的事情吗?换句话说,跨平台如何是Ruby?

EDIT: I mean Ruby by itself, not Ruby running in another virtual machine like in jRuby. Should I expect more cross-platform gotchas development in Ruby than in Java or are both almost the same?

编辑:我的意思是Ruby本身,而不是像jRuby中的另一个虚拟机中运行的Ruby。我是否期望在Ruby中开发比Java更多的跨平台陷阱或两者几乎相同?

5 个解决方案

#1


13  

Ruby is a scripting language and it is interpreted at the run time by the Ruby interpreter , The Ruby code is interpreted and converted to machine level language i.e Assembly code . Talking about the platform Independence you can run ruby code in any of the the platform like Linux ,Windows or Mac if you have platform dependent Ruby Interpreter installed.

Ruby是一种脚本语言,它在运行时由Ruby解释器解释,Ruby代码被解释并转换为机器级语言,即汇编代码。谈论平*立性,如果您安装了平台相关的Ruby解释器,您可以在任何平台(如Linux,Windows或Mac)中运行ruby代码。

Where as in Java , it is Compiled and converted to an intermediate byte class and this byte class is interpreted by platform dependent JVM (Java Virtual Machine ) .

在Java中,它被编译并转换为中间字节类,并且此字节类由平台相关的JVM(Java虚拟机)解释。

In that way you can think you Ruby source file as byte class which can be run on any platform ,with one difference byte class is already compiled but ruby source file will be compiled at the Run time .

通过这种方式,您可以将Ruby源文件视为可以在任何平台上运行的字节类,只有一个差异字节类已经编译,但ruby源文件将在运行时编译。

#2


5  

Ruby binds fairly closely to the underlying platform. This is especially the case when it comes to process/threading mechanisms, and various forms of IPC. These are more significant challenges to overcome, compared to "trivial" ones as directory seperator, and so forth. I'm pretty sure that there isn't parity between, say, the Windows Ruby runtime and the Linux Ruby runtime.

Ruby与底层平台紧密相关。当涉及到进程/线程机制和各种形式的IPC时尤其如此。与作为目录分隔符的“微不足道的”相比,这些是要克服的更重要的挑战,等等。我很确定Windows Ruby运行时和Linux Ruby运行时之间没有平价。

With Java, the IPC/process/thread model is the same on all platforms that runs the JVM.

使用Java,IPC /进程/线程模型在运行JVM的所有平台上都是相同的。

#3


3  

As long as you don't touch hardware or threading, Ruby should work on the three major operating systems. For web development, Ruby will mostly work the same everywhere. For more advanced applications, no, because it does not offer the abstractions of the JVM (that you probably have in mind).

只要您不接触硬件或线程,Ruby就应该在三个主要操作系统上工作。对于Web开发,Ruby将在大多数地方工作。对于更高级的应用程序,不,因为它不提供JVM的抽象(您可能已经考虑过)。

#4


2  

Java is cross platform. Ruby is not. It very much feels like an afterthought of, "oh we have windows users, let's try and get it working".

Java是跨平台的。 Ruby不是。这听起来像是一个事后的想法,“哦,我们有Windows用户,让​​我们尝试让它工作”。

In Java I have experienced less than 10 cross platform issues in years of heavy use. The areas that this was in, were obviously areas that would be tricky. System/File system specifics.

在Java中,经过多年的大量使用,我遇到了不到10个跨平台问题。它所在的区域显然是非常棘手的区域。系统/文件系统细节。

In ruby, I've experienced problems even when doing the first rails tutorial as have others (https://github.com/twbs/bootstrap-sass/issues/696) . I wouldn't consider ruby cross platform. The platform relies on a whole host of dependencies, which anytime one of them uses anything platform specific the whole thing breaks. i.e. see this error: ExecJS::RuntimeError on Windows trying to follow rubytutorial

在ruby中,即使在执行第一个rails教程时也遇到了问题(https://github.com/twbs/bootstrap-sass/issues/696)。我不会考虑ruby跨平台。该平台依赖于大量的依赖关系,这些依赖关系中的任何一个都可以使用任何特定于平台的东西。即看到此错误:Windows上的ExecJS :: RuntimeError试图遵循rubytutorial

I also inherited a largish ruby project and it relied on capistrano, webkit, bcrypt and these needed a dev build kit and native builds. It did not just work. See the people having trouble here: https://github.com/codahale/bcrypt-ruby/issues/116 It's funny, at one point they suggest someone follows a japanese post :)

我还继承了一个大的ruby项目,它依赖于capistrano,webkit,bcrypt,这些需要一个开发构建工具包和本机构建。它不仅起作用。看到有问题的人在这里:https://github.com/codahale/bcrypt-ruby/issues/116这很有趣,有一次他们建议有人关注日语帖子:)

#5


0  

If nothing else, you could run JRuby, a Ruby interpreter written in Java.

如果不出意外,您可以运行JRuby,一个用Java编写的Ruby解释器。

#1


13  

Ruby is a scripting language and it is interpreted at the run time by the Ruby interpreter , The Ruby code is interpreted and converted to machine level language i.e Assembly code . Talking about the platform Independence you can run ruby code in any of the the platform like Linux ,Windows or Mac if you have platform dependent Ruby Interpreter installed.

Ruby是一种脚本语言,它在运行时由Ruby解释器解释,Ruby代码被解释并转换为机器级语言,即汇编代码。谈论平*立性,如果您安装了平台相关的Ruby解释器,您可以在任何平台(如Linux,Windows或Mac)中运行ruby代码。

Where as in Java , it is Compiled and converted to an intermediate byte class and this byte class is interpreted by platform dependent JVM (Java Virtual Machine ) .

在Java中,它被编译并转换为中间字节类,并且此字节类由平台相关的JVM(Java虚拟机)解释。

In that way you can think you Ruby source file as byte class which can be run on any platform ,with one difference byte class is already compiled but ruby source file will be compiled at the Run time .

通过这种方式,您可以将Ruby源文件视为可以在任何平台上运行的字节类,只有一个差异字节类已经编译,但ruby源文件将在运行时编译。

#2


5  

Ruby binds fairly closely to the underlying platform. This is especially the case when it comes to process/threading mechanisms, and various forms of IPC. These are more significant challenges to overcome, compared to "trivial" ones as directory seperator, and so forth. I'm pretty sure that there isn't parity between, say, the Windows Ruby runtime and the Linux Ruby runtime.

Ruby与底层平台紧密相关。当涉及到进程/线程机制和各种形式的IPC时尤其如此。与作为目录分隔符的“微不足道的”相比,这些是要克服的更重要的挑战,等等。我很确定Windows Ruby运行时和Linux Ruby运行时之间没有平价。

With Java, the IPC/process/thread model is the same on all platforms that runs the JVM.

使用Java,IPC /进程/线程模型在运行JVM的所有平台上都是相同的。

#3


3  

As long as you don't touch hardware or threading, Ruby should work on the three major operating systems. For web development, Ruby will mostly work the same everywhere. For more advanced applications, no, because it does not offer the abstractions of the JVM (that you probably have in mind).

只要您不接触硬件或线程,Ruby就应该在三个主要操作系统上工作。对于Web开发,Ruby将在大多数地方工作。对于更高级的应用程序,不,因为它不提供JVM的抽象(您可能已经考虑过)。

#4


2  

Java is cross platform. Ruby is not. It very much feels like an afterthought of, "oh we have windows users, let's try and get it working".

Java是跨平台的。 Ruby不是。这听起来像是一个事后的想法,“哦,我们有Windows用户,让​​我们尝试让它工作”。

In Java I have experienced less than 10 cross platform issues in years of heavy use. The areas that this was in, were obviously areas that would be tricky. System/File system specifics.

在Java中,经过多年的大量使用,我遇到了不到10个跨平台问题。它所在的区域显然是非常棘手的区域。系统/文件系统细节。

In ruby, I've experienced problems even when doing the first rails tutorial as have others (https://github.com/twbs/bootstrap-sass/issues/696) . I wouldn't consider ruby cross platform. The platform relies on a whole host of dependencies, which anytime one of them uses anything platform specific the whole thing breaks. i.e. see this error: ExecJS::RuntimeError on Windows trying to follow rubytutorial

在ruby中,即使在执行第一个rails教程时也遇到了问题(https://github.com/twbs/bootstrap-sass/issues/696)。我不会考虑ruby跨平台。该平台依赖于大量的依赖关系,这些依赖关系中的任何一个都可以使用任何特定于平台的东西。即看到此错误:Windows上的ExecJS :: RuntimeError试图遵循rubytutorial

I also inherited a largish ruby project and it relied on capistrano, webkit, bcrypt and these needed a dev build kit and native builds. It did not just work. See the people having trouble here: https://github.com/codahale/bcrypt-ruby/issues/116 It's funny, at one point they suggest someone follows a japanese post :)

我还继承了一个大的ruby项目,它依赖于capistrano,webkit,bcrypt,这些需要一个开发构建工具包和本机构建。它不仅起作用。看到有问题的人在这里:https://github.com/codahale/bcrypt-ruby/issues/116这很有趣,有一次他们建议有人关注日语帖子:)

#5


0  

If nothing else, you could run JRuby, a Ruby interpreter written in Java.

如果不出意外,您可以运行JRuby,一个用Java编写的Ruby解释器。