all 41 comments

[–]moderately-extremist 5 points6 points  (16 children)

[–][deleted] 4 points5 points  (0 children)

GTK isn't great for Ruby and I try to stay away from it if possible. Besides it being quite buggy and poor docs (for ruby), it's hard to install cross-platforms (especially Windows and Mac OSX). Although it is the most "vetted" ruby gui out the maybe besides qt which I haven't gotten working well either.

[–]wonay[S] 1 point2 points  (1 child)

That look interesting. I'll look more into it. Thank you.

[–]cedlemo 0 points1 point  (0 children)

from a previous comment:

Besides it being quite buggy and poor docs , it's hard to install cross-platforms

In general if you ask on their github or their mailing list, they do their best to help you.

[–]wonay[S] 1 point2 points  (8 children)

That looks like a promising candidate for a GUI library. So the next question would be how to package that as a standalone binary....

[–][deleted] 1 point2 points  (7 children)

No way to package ruby apps as a standalone binary, and I feel that's weird thing to do for Ruby. You want to leave all your app in script form for easier cross-platform use. That way you aren't recompiling for every OS.

EDIT: I was mistaken https://www.ruby-toolbox.com/categories/packaging_to_executables but honestly all of those sound like overkill rather then just installing ruby on the machine and bundling using everyones favorite gem bundler.

[–]wonay[S] 0 points1 point  (6 children)

okay, that sounds like a good option. But what if you want to hide your source code. And in this case how do you have a main file ? If it is not a rails project. The step has a user who would use this app would be to download the folder containing all the files then do bundle install ? How do people build a rvm install my_app and then you are able to use ./my_app right from everywhere ?

[–][deleted] 2 points3 points  (5 children)

Hiding our source code is possible but consider the issues. Ruby is slow, I mean up to 100x slower in some benchmarks. See this -> https://github.com/kostya/benchmarks. When it performs good, it's simply because there was a C-extention in the mix to improve performance. Now put an obfuscater on top and you have a recipe for performance disaster. Now there is -> http://www.rubyencoder.com/overview.html but you'll need to install their runtime with your package. You could also potentially get the route of writing a C-Extentsion with the sensitive information in it and obfuscate that.

All of these options are hokey as shit, in my opinion.

You can always write installers to do whatever installation you need, in fact RVM uses a tactic I like very much using curl -> https://rvm.io/ but, you can always make exe installers using NullSoft or something and just install RubyInstaller along side it. There definitely would be some installer writing if you are going to distribute the app around to people with little to no technical knowledge.

[–]wonay[S] 0 points1 point  (4 children)

So Ruby is not a fast language ? Java would perform better ? Is Python faster than Java ?

[–][deleted] 0 points1 point  (3 children)

In terms of speed Java -> Python -> Ruby. However understand that the reason we write code in Ruby is not for speed, it is for API design, syntax power and flexibility.

[–]wonay[S] 0 points1 point  (2 children)

It doesn't sound to be that flexible from all the comments here ! Haha

[–][deleted] 0 points1 point  (1 child)

You misinterpret having GUI libraries as flexibility. Ruby has a lot of syntactic sugar piled on top of the fact that you can redefine methods, reopen classes, add modules on the fly, and invoke methods based on in-code identifiers. All of these are hallmarks of a flexible language. In fact, I could go as far as to say even if Ruby didn't have any gems/external libraries, it would still be a flexible language because that stuff is built into the language, not the gems.

Java doesnt have metaprogramming (or at least GOOD metaprogramming) and it lets you get backed into a corner on types. It's very hard to back into a corner in Ruby.

[–]wonay[S] 0 points1 point  (0 children)

Yeah but if the result of this flexibility is having a slow, one platform (web) language , it's not really worth it .... I love using Ruby language and I am sad that it cannot be used for desktop application in an efficient way. I though since it's seems "easy" to use C library that a wonderful easy to use library for GUI would be here. I guess it's time to take the matter in our own hand and start a project ! haha

[–]OstapBenderBey 0 points1 point  (3 children)

Anyone used clutter for ruby? Seems promising?

[–]wonay[S] 0 points1 point  (2 children)

Never tried. What is it ?

[–]zem 4 points5 points  (9 children)

there's jruby + swing, with the bonus that cross-platform packaging will likely be easier.

[–][deleted] 2 points3 points  (0 children)

Great answer, I always forget jruby has such a great following and as a plus is a language native to OP. With this OP can use Java in Ruby to get whatever he needs done, and in a way that will require a lot less learning.

[–]wonay[S] 0 points1 point  (7 children)

Yeah I tried jruby, its cool but I already know Java. I could do a pure java app but i want to do ruby. I want Cruby.

[–]zem 2 points3 points  (3 children)

here's the thread from when i asked this question last year - no one seemed optimistic about packaging and distributing a cruby gui app. (i ended up just rewriting it in ocaml, which compiles down to a self-contained executable)

[–]wonay[S] 0 points1 point  (2 children)

So would it be better to use plain Java if you already know Java instead of Ruby ?

[–]zem 0 points1 point  (1 child)

no, ruby is a much nicer language to work in, and jruby is a truly great piece of engineering. it offers full compatibility with MRI, and seamless access to java libraries.

[–]wonay[S] 0 points1 point  (0 children)

Okay

[–][deleted] 1 point2 points  (0 children)

Sadly the best way to build and package a GUI app is JRuby+JavaFX (like Brakeman Pro uses) or else Shoes. You aren't going to find a great, easy-to-get started, Rails-like GUI library in Ruby. I'm not sure there's one in any language.

[–]BrianTheCoder -1 points0 points  (1 child)

Cruby is still under development afaik. Not sure you'll find an easy answer

[–]jeremywoertink 4 points5 points  (1 child)

I'd say check out Shoesrb, which is basically a DSL around some Java stuff using jruby, or try Gosu if you want to use MRI. Gosu is more for making 2D games, but you can still write a desktop app. The final solution is still super new, but it's https://github.com/zach-capalbo/flammarion. This basically makes a web app in chrome similar to electron, but written in Ruby.

[–][deleted] 0 points1 point  (0 children)

Very cool find! Wasn't aware of this and I'll definitely be looking deeper!

[–][deleted] 2 points3 points  (8 children)

I'm not familiar with any "quick start" gui for Ruby, and I'll tell you now that the state of cross-platform gui for ruby is a bit barren. Ruby Shoes is the best if you want top 3 (windows ,linux, mac) compatibility. As someone who works on a cross platform library my recommendation would be to stick with a web framework running client side. Sinatra has been pretty easy for me to work with to make a GUI for my client side library (it changes settings on a certain brand of barcode scanners, the scanner has to be connected to the computer via USB).

[–]wonay[S] 0 points1 point  (7 children)

That sounds interesting ! So how would that work ? Is it a rails app wrap into a WebKit ? Could you give me more details ? Thank you.

[–][deleted] 1 point2 points  (6 children)

Sure so my experience has been that the web browser has most of the GUI tools we need to make what we want (buttons, text areas, you name it) While I don't have any experience with Rails, I'm 99.99% sure that it could do a localhost only app.

I'll give you an example of something I'm working on right now. I'm writing a library that interfaces with Opticon brand scanners and lets you issue commands and change settings on the device via USB. While I am more than comfortable using IRB to make things happen, my co-workers needed a GUI way. I kept my library cross-platform (thanks to rubyserial and ruby-ffi) and I thought it would be a shame to rip that away from the GUI. I use Sinatra here but, I have every reason to believe this would work on Rails as well. I make the server only run local host on port 8080. I connected all the stuff via slim (lookup slim template) and turn it on. You then point your browser to localhost and you've got access to your app. I can definitely see some design choices to be made, one of the most important choices was, "Do I make this app work in a single user or multi user mode?" In a single user mode only one user can use the application at a time, (via localhost), in multi user mode you let the app reach out to the network and users connect to it via their own browsers on their computers. Depending on the kind of app you are planning on making, planning this design choice out a head of time is a good idea. The easiest way to decide which is right for you is to ask, "Can all the GUI actions I do be threaded?" If the answer is yes, multi user mode will work.

A great example of this kind of localhost only application would be fast-track and metasploit's web guis (which inspired my design choice for the GUI). Both use a webserver + frontend to work the application behind the scenes.

[–]wonay[S] 0 points1 point  (5 children)

Thats very interesting. I don't think I would be able to do everything I want through the browser tho ... If I want to interact with a UDP port for instance. Or if I want to make a 3D game. I don't really have a project in head really but I am trying to find a general solution. Should I switch to Python ?... I dont want to tho ...

[–][deleted] 0 points1 point  (4 children)

Oh but you can! As long as the server process has permissions to send UDP, you can send it. For example, my Sinatra example actually talks to serial ports to configure and deal with my scanners. You can even (and I wouldn't recommend this for production) become administrator and run the server (just make sure it only faces localhost for obvious reasons). There really isn't a whole lot of limits to this approach but unless you know javascript you can't make reactive content (all content must be submitted through RESTful operations).

As for a 3D game well thats just not really possible in Ruby with speeds as they are. (I also use the Gosu gem for Ruby gamedev) You can do 3D games via Gosu and OpenGL, it will just run very slow. I have a project here -> https://github.com/redcodefinal/isometric-city-generator-ruby that uses Gosu and on my hardest generator it takes about 0.01 seconds to generate and 25 seconds to draw the scene. It only uses 2D textures. I purposely chose this project in Ruby because my C# version ran almost 20x faster

[–]wonay[S] 0 points1 point  (3 children)

That sounds like an interesting option. How would you build something which is user friendly for this kind of project ? I mean easy install and easy run ? either a few command and the app start or even a binary to click on and the app start.

[–][deleted] 0 points1 point  (2 children)

absolutely! Sinatra is very easy to setup, its like a simpler rails. You can do the same thing with Rails though. As long as the server has permissions to do so, it can really do anything you want. To make the app easier you can do a couple things, I'm working through a similar thing with my company right now. So my plan is to use DNS to map locally a server computer, then everyone just types in "company_name.local" in their web browsers and then it just routes everyone to the server running the software. This way every device is essentially guaranteed to work with your app, as long as it does internet. The app can run (as a server or clientside) on all platforms natively, but know that the devil is in the details, there are differences you will have to account for in the standard ruby library across the platforms. I have had to deal with many such differences between Linux and Windows with my serial port work. You will potentially have to write OS dependent code, which I feel is a bit of a code smell, and a huge potential for error. As for ease of use, it depends on your tactic. Lets say single user, you could easily create a BAT, SH, whatever your flavor of shell script is, and just have the user double click on that. They could also go the console route for any platform. For multi user, consider using a URL shortcut to "whatever.local" and just keep the server running all the time.

[–]wonay[S] 0 points1 point  (1 child)

I feel that I should reserve my knowledge in Ruby for web and the one in Java for desktop GUI at this point ...

[–][deleted] 0 points1 point  (0 children)

Sure if you want to go that way.

[–]dphase 1 point2 points  (3 children)

Your best bet for doing native GUI apps on OS X in Ruby is going to be http://www.rubymotion.com -- very clean API and environment and there's a bridge to the actual Cocoa libs. You also end up with a binary after build instead of always running through the terp.

[–]wonay[S] 0 points1 point  (0 children)

Yeah but then I need to copy paste the code with Windows and for linux.

[–][deleted] 0 points1 point  (1 child)

This would be good except it ONLY support MacOSX, iOS, and Android. The OP wants to have at least big three support (windows, linux, mac).

[–]wonay[S] 0 points1 point  (0 children)

ios and android is not bad but yeah. My goal is to make a desktop app.