开发者

Viability of Ruby for Cross-Platform Development With Native Toolkits?

Let's say that I was writing a closed sourced commercial piece of software which was to be deployed in the following situations: Windows Desktop App built on .Net, ActiveX control, Windows Netscape plugin, Mac Desktop App built on Cocoa, Mac Netscape plugin, Java applet hosted in browser. Would it be viable in terms of code sharing to write my model and controller classes in shared Ruby source files and use MacRuby, IronRuby and JRuby to integrate into the various runtimes? My view classes would presumably be written to use WPF on Windows, Cocoa on the Mac and whatever was appropriate on Java (SWT?).

From my point of view, the most important thing here is long term maintenance of the codebase, and it seems as though Ruby is as close to being a first class language on the three platforms I have to target: .Net, Cocoa and Java, as any language. Am I mistaken in this?

Second in importance is to avoid any viral license requirements on our code. I see wh开发者_如何学Goere JRuby is released under various licenses; am I right to assume I can distribute binaries and the licenses do not apply to any Ruby files I write for my own application (as opposed to modifications of their framework.)

Has Ruby been used in any well known desktop applications? Has this been done before?


Hmmm....if the question is "How can I create a maintainable product using Ruby and make it available to all of these end points (web, desktop, and java-based mobile)?"

Then in my humble opinion, using ruby AND the three flavors (jRuby, IronRuby and MacRuby) would result in many more maintenance problems than not. You'd have to understand or at least employ experienced developers on all three platforms, and you'd spend a lot of time creating really abstract code, unless you plan to use ruby just for database access.

You're probably better off sticking with one of the platforms (Java & jRuby is probably the most portable option) and using its various packaging options to distribute the product.


It's possible, although I'd be a little wary of the approach you've outlined: IronRuby isn't 1.0 yet, for example.

Are you expecting much OS-specific work beyond the UI? If not then I'd start by looking at WxRuby, which is a (fairly thin) wrapper of the cross-platform WxWidgets library. Don't work too hard looking for good documentation of the Ruby wrapper, btw - painful experience has taught me to look at the example code, which is actually very comprehensive.

Other platform specific stuff should probably be abstracted/encapsulated away behind some sort of wrapper/facade/api/proxy (pick your pattern).

You say "closed source" - did you have a strategy for that in a Ruby context? While there are at least a couple of tools (ruby2exe and RubyScript2exe) that I've seen, I don't know how hidden your Ruby code will actually be. Does it need to be a standalone, deployed executable at all, or could it be browser-based? That would solve all the cross-platform issues (although you might be running face-first into cross-browser ones instead).

There's some more discussion (including Python, which is another alternative) in this SO question


Would it be viable in terms of code sharing to write my model and controller classes in shared Ruby source files and use MacRuby, IronRuby and JRuby to integrate into the various runtimes?

You would be able to share Ruby code between the three different implementations; they all are very-compatible Ruby implementations. Keep in mind that JRuby and IronRuby target Ruby 1.8.6 features, JRuby also is beginning to work on 1.9 features, and MacRuby only support 1.9.

You'd need platform-specific pieces that are not shared between the three implementations, since only JRuby can talk to SWT, IronRuby to WPF, etc.

seems as though Ruby is as close to being a first class language on the three platforms I have to target: .Net, Cocoa and Java, as any language

The three Ruby implementations are well-established, supported by a ever-growing community, and backed by well-established companies. While Ruby isn't the primary-pushed language on any of the platforms, none of the implementations have major limitations that make using Ruby impossible, though you may need to resort to a small amount of C#/Java/Objective-C for some things.

am I right to assume I can distribute binaries and the licenses do not apply to any Ruby files I write for my own application (as opposed to modifications of their framework.)

Well, you need to read the licenses yourself to make that decision, or ask a lawyer you know. That being said, as long as none of the licenses are "viral", like GPL, you should be free to distribute your application with the binaries and licenses of the Ruby implementations in-tact, and decide whatever license you application will use, as well as whether or not you charge money. But again, if you're concerned about the legality, ask a lawyer.

Has Ruby been used in any well known desktop applications? Has this been done before?

I don't know of any widely-used desktop applications that use Ruby, but I do know of a couple applications which use IronPython on Windows, such as Blaze and Resolver One; their methods for deploying would be the same for IronRuby.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜