how to reduce amount of time to open ruby executable that contains a GUI?

188 Views Asked by At

I've been using ocra to convert my ruby files to a window executable, but I notice that it takes a very long time if I use ruby GUI like fxruby or green_shoes. Is there any way to reduce the amount of time it takes for the program to pop up? My current fxruby and green_shoes file is very simple, but it takes about a minute for the compiled exe file to run.

Here is my fxruby.rb file:

require 'fox16'

include Fox 

theApp = FXApp.new

theMainWindow = FXMainWindow.new(theApp, "Hello")
theButton = FXButton.new(theMainWindow, "Hello, world!")
theButton.connect(SEL_COMMAND) do |sender, selector, data|
    exit
end
theApp.create

theMainWindow.show

theApp.run

and here is my green_shoes.rb:

require 'green_shoes'

Shoes.app do
    button "OK!"
    button "Are you sure?"
end

Any strategies to get these to run faster? Or maybe another ruby GUI option that would be faster? thank you!!

1

There are 1 best solutions below

0
On

The load time probably mostly comes from the time that the Java VM needs to spin up for your application. I am not too well informed about the various optimization methods for the Java VM but a web search should earn you some approaches. However there is going to be an ultimative limit of how fast you can make your application start.

Another approach would be to use node-webkit (nw.js) as a frontend which essentially packs the webkit browser and then you could either compile your ruby code with opal (if you are feeling adventurous) or have it start a ruby process in the background that creates a server the frontend will connect to. I am trying this out in a python based project actually and so far it's interesting, however you should be aware that you would also need to learn stuff about HTML/CSS and eventually JS if you want your application to become really cool so this might not be what you want. I just feel that in general the nw.js approach is a bit faster for GUI stuff than the Java approach.

Actually there have also been QT and GTK bindings for Ruby but to my understanding they are mostly outdated (sadly). Otherwise QT might be the way to go for native crossplatform GUI development in Ruby.