views:

112

answers:

3

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 where 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?

+1  A: 

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.

btelles
As I was trying to say, it is not within my authority or power of persuasion to not support all three platforms simultaneously. It is either write 3 parallel codebases in Java, C# and Objective-C (perhaps in C# with Mono), or try to find a common denominator language, which at a first guess was vanilla Ruby. I've zero experience with Ruby (in an ideal universe, I'd like to do everything in Cocoa), but it seemed plausible Ruby could become a lingua franca.
Glenn Howes
Also, is vanilla Ruby any more divergent in the three flavors than C++ is between Visual C++ and GCC? I've written tens of thousands of lines of vanilla C++ and almost all of them can be made to compile to the same behavior on Windows and OS X, with a few annoying exceptions most of which (thank goodness) end up as compile errors.
Glenn Howes
Gotchya...mmm...I can't say I know enough about developing for the .Net platform to get the job done, although last I heard the IronRuby implementation was incomplete. But your idea seems plausible for Java, Cocoa and the web.
btelles
+1  A: 

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

Mike Woodhouse
Thanks for the response. Again, as I had said in the question, this software would be delivered in a variety of forms, some browser based and some shrink wrapped desktop based on a variety of platforms.So you are saying that since Ruby is a scripting language, you can't easily deliver it without source. I had not thought about that. Good point.
Glenn Howes
+1  A: 

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.

Jimmy Schementi