Ruby 可以用来开发简单的 Windows 应用程序吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1654815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can Ruby be used to develop simple Windows applications?
提问by RKh
I've been developing Windows based applications for a long time and most of my present clients still desire a desktop or client/server Windows application. Is it possible to use Ruby for such applications as opposed to its primary purpose of being a Web-programming language?
我一直在开发基于 Windows 的应用程序很长一段时间,我现在的大多数客户仍然需要桌面或客户端/服务器 Windows 应用程序。是否可以将 Ruby 用于此类应用程序而不是其作为 Web 编程语言的主要目的?
回答by Ken Liu
Ruby is not primarily a web programming language even though Ruby on Rails is certainly suited for web development. Ruby is a general purpose scripting language.
尽管 Ruby on Rails 当然适合 Web 开发,但 Ruby 并不是主要的 Web 编程语言。Ruby 是一种通用的脚本语言。
The FXRubyand WxRubyframeworks are the most fully featured GUI frameworks for Ruby. You can write the apps in Ruby and then generate a Windows executable. The frameworks are cross-platform, so you could also run the apps written in these on other platforms, like Linux or Mac OS X.
该FXRuby和WxRuby框架是Ruby的功能最全的GUI框架。您可以用 Ruby 编写应用程序,然后生成 Windows 可执行文件。这些框架是跨平台的,因此您也可以在其他平台(如 Linux 或 Mac OS X)上运行用这些框架编写的应用程序。
There are also a few other less popular approaches like QtRuby and Shoes, and you can even use IronRuby(a CLR Ruby implementation) to write a .Net application.
还有其他一些不太流行的方法,例如 QtRuby 和 Shoes,您甚至可以使用IronRuby(一种 CLR Ruby 实现)来编写 .Net 应用程序。
回答by bk1e
Ruby is a general purpose object oriented scripting language. Ruby on Rails is a web application framework. Ruby predates Rails by about ten years. Don't confuse the two.
Ruby 是一种通用的面向对象的脚本语言。Ruby on Rails 是一个 Web 应用程序框架。Ruby 比 Rails 早了大约十年。不要混淆两者。
回答by Thomas Owens
Yes, you can. Ruby is a full scripting language. You might want to start with the Ruby language homepageto see the capabilities and libraries that are available.
是的你可以。Ruby 是一种完整的脚本语言。您可能希望从Ruby 语言主页开始查看可用的功能和库。
However, just because you can doesn't mean that you should. Before jumping in and using Ruby for a project, see if Ruby can give you things that other languages can't or if there are any disadvantages to using Ruby.
然而,仅仅因为你可以并不意味着你应该。在开始为一个项目使用 Ruby 之前,先看看 Ruby 是否可以提供其他语言无法提供的东西,或者使用 Ruby 是否有任何缺点。
回答by amireh
I know this thread is old, but for future reference to anyone who's looking into options for using Ruby for a GUI app, don't use QtRuby. I had developed a project for school in about a week, fully functional and pretty, only to find out that I could not release it. There was simply no way to package and distribute the application without having your users simulate your exact environment (install all the gem dependencies, build Qt development libraries etc). I tried using:
我知道这个线程很旧,但是为了将来给正在研究将 Ruby 用于 GUI 应用程序的选项的任何人参考,不要使用QtRuby。我在大约一周内为学校开发了一个项目,功能齐全且漂亮,却发现我无法发布它。如果不让您的用户模拟您的确切环境(安装所有 gem 依赖项、构建 Qt 开发库等),就无法打包和分发应用程序。我尝试使用:
- Crate: supposedly cross-platform, but I found only 1 usage example that's written in 2008 out of ~2 hours of googling, and the example basically covers a very specific subset of applications (some ssl/https authentication gem or w/e...)
- Ocra: this looks like a candidate, but it's windows-only and didn't meet my requirements, as I had to target the three primary platforms
- tar2rubyscript+ rubyscript2exe: I had spent most of my time trying to get this to work because I've come across many who claimed that this is the way to go for distributing GUI apps built in ruby (albeit using other toolkits, Tk/GTK/wxRuby) but it didn't work either; I was endlessly faced with a cryptic error that basically breaks Qt::UiLoader functionality, in other words, you can't load .ui sheets you create with QtDesigner so...
- Crate:据说是跨平台的,但我在大约 2 小时的谷歌搜索中发现只有 1 个在 2008 年编写的使用示例,并且该示例基本上涵盖了一个非常特定的应用程序子集(一些 ssl/https 身份验证 gem 或 w/e.. .)
- Ocra:这看起来像一个候选,但它仅适用于 Windows 并且不符合我的要求,因为我必须针对三个主要平台
- tar2rubyscript+ rubyscript2exe:我花了大部分时间试图让它工作,因为我遇到过很多人声称这是分发内置 ruby 的 GUI 应用程序的方式(尽管使用其他工具包,Tk/GTK/ wxRuby) 但它也不起作用;我无休止地面临着一个基本上破坏 Qt::UiLoader 功能的神秘错误,换句话说,您无法加载使用 QtDesigner 创建的 .ui 表,所以...
Yes I'm angry and frustrated honestly, because I don't see the point of creating software that you just can't releasefor anyone to use. Now I'm left with a deadline coming up in a week, and I just hope I make it in time porting the app to C++.
是的,老实说,我很生气也很沮丧,因为我不认为创建不能发布给任何人使用的软件有什么意义。现在我的最后期限将在一周后到来,我只希望我能及时将应用程序移植到 C++。
So my answer is, don't use QtRuby. At least for now.
所以我的回答是,不要使用 QtRuby。最起码到现在。
回答by plainprogrammer
Ruby can be used for developing GUI applications, whether Windows specific or cross-platform.
Ruby 可用于开发 GUI 应用程序,无论是 Windows 特定的还是跨平台的。
For Windows targetted you should look at the work going on with IronRubysince they have good integration with the .NET framework overall and with Silverlight, in the event you want to do apps that can bridge web and desktop. At this point IronRuby can be used to develop for Windows Presentation Foundation (WPF)or WinForms.
对于面向 Windows 的 Windows,您应该查看IronRuby正在进行的工作,因为它们与 .NET 框架整体和 Silverlight 具有良好的集成,如果您想要开发可以连接 Web 和桌面的应用程序。此时 IronRuby 可用于为Windows Presentation Foundation (WPF)或WinForms 进行开发。
For cross-platform you have Ruby bindings for QT, FOXand others.
回答by deau
On a mac, you can use the Ruby Cocoa lib to create (what appear to be) native applications. If you want something more cross platform then you might consider a wrapper like shoes or qt.
在 Mac 上,您可以使用 Ruby Cocoa 库来创建(看起来是)本机应用程序。如果您想要更多跨平台的东西,那么您可以考虑使用诸如鞋子或 qt 之类的包装器。
The Qt toolkitseems the most popular way to do it. The website is http://www.darshancomputing.com/qt4-qtruby-tutorial/
在Qt工具包似乎是最流行的方式来做到这一点。网址是http://www.darshancomputing.com/qt4-qtruby-tutorial/
I'm currently writing a little app in a wrapper called Shoes. This seems to make it as simple as pie to create windowed apps in ruby. http://shoes.heroku.com/is the website.
我目前正在一个名为Shoes的包装器中编写一个小应用程序。这似乎使在 ruby 中创建窗口应用程序变得像馅饼一样简单。 http://shoes.heroku.com/是网站。
At the moment Shoes looks suitable only for small personal apps. I say this because it's author recently went AWOL and it's not clear whether it will be developed further. I'm using it to write a game log parser to generate statistics from a flight sim. It's ticking along nicely.
目前,Shoes 看起来只适合小型个人应用。我这样说是因为它的作者最近离开了,目前还不清楚它是否会进一步开发。我用它来编写一个游戏日志解析器来从一个飞行模拟生成统计数据。进展顺利。