
Creating a Linux Desktop App with Ruby - lazaru_s
https://iridakos.com/tutorials/2018/01/25/creating-a-gtk-todo-application-with-ruby
======
mherrmann
For people interested in Python / Qt, I had a related Show HN this week.

[https://github.com/mherrmann/fbs](https://github.com/mherrmann/fbs)

Discussion:
[https://news.ycombinator.com/item?id=16318677](https://news.ycombinator.com/item?id=16318677)

~~~
bringtheaction
From my reading of the following I your README, I think your understanding of
the GPL might be slightly wrong

> This project is licensed under the GPL. In simple terms, this means you can
> use it for free in open source projects that are also licensed under the
> GPL. If on the other hand you want to use the project for a proprietary app
> where you don't want to open source the code, then you need a commercial
> license. The price for one developer is EUR 79 if you purchase before Feb
> 11, 2018, EUR 99 after. One year of updates is included. To obtain a
> license, click here.

If I understand what you are saying, you say that to use the _output_ of your
program one needs to GPL everything, which is not usually how GPL is
interpreted.

For example I can use GIMP to create graphics that I can use without any form
of restrictions. The GPL applies to GIMP itself, not its outputs.

However, since your product builds executables then if the resulting installer
file was built from GPLed code then you are partially correct IMO -- users
would be required to distribute the installer source in compliance with GPL.
However, while I have not looked into how the build process works for your
product I have a hard time imagining that the GPL would require users to GPL
the installation target source, since those are a separate set of files.

IANAL

~~~
mherrmann
IANAL either but believe you are right with the GIMP example. However, my
project doesn't just produce an output similarly to how GIMP saves images. It
also requires you to link to some of my project's code at runtime. That is
where the need for a commercial license comes from.

------
tomc1985
Over the years I have seen some strange performance issues in GTK,
specifically PyGTK, that make me not want to use it any more, and was just
wondering if others have encountered these?

\- Highly variable window load and startup times

\- Random slowdowns

\- WebkitGTK has some serious memory leaks

Otherwise I'd consider GTK to be fantastic :/

~~~
aeroevan
These days pygobject seems to be the way to go

------
tremendo
There's also [http://visualruby.net/](http://visualruby.net/)

------
jsymolon
I was always fond of wxWidgets. Multi-platform, multi-language bindings.

[http://wxwidgets.org/](http://wxwidgets.org/)

~~~
petre
It still uses Gtk or Motif on Linux/Unix. Here's a diagram with all the
layers:

[http://wxd.sourceforge.net](http://wxd.sourceforge.net)

------
SoapSeller
For simple apps Shoes!([http://shoesrb.com/](http://shoesrb.com/)) is very
nice

~~~
funkaster
Oh wow... Didn't know Shoes was under active development. Nice to see the
community picked it up.

~~~
fhood
If it is under active development they should update their photos. It hardly
inspires confidence when all of their screen shots are from at least 4
versions of OSX ago.

~~~
jamesgeck0
I gather that most of the development effort is going into Shoes 4, which
doesn't have a stable release yet.

Edit: Huh. The Shoes 3 development blog is actually really active!
[https://walkabout.mvmanila.com/](https://walkabout.mvmanila.com/)

------
jetti
I'm not a Ruby guy at all so forgive me if I'm missing something here but what
would the benefit of using GTK+ be over using JRuby and utilizing JavaFX or
even Swing?

~~~
axaxs
Most linux desktops have GTK installed already, and ruby. So, you can create a
quite small performant GUI this way. JRE is falling out of fashion in my
experience as a default install. It's huge, slow to startup, and creates a
larger install size.

~~~
RussianCow
Also, GTK is the "native" GUI toolkit on most Linux distros, whereas a Java-
based one is almost guaranteed to look out of place.

~~~
pjmlp
Java uses GTK bindings on Linux.

~~~
djsumdog
I just ran my old swing app for years ago and it still displays using its own
toolkit.

I think you're thinking for SWT (the toolkit used by Eclipse) which will use
native components for each OS.

SWT is kinda difficult to use and last time I checked, all the Scala
bindings/wrappers were crap or non-existant, making it a non-starter for me.

~~~
pjmlp
Starting with Java 9,

JEP 283: Enable GTK 3 on Linux

[http://openjdk.java.net/jeps/283](http://openjdk.java.net/jeps/283)

Opening paragraph "Java on Linux currently uses GTK 2. This raises several
issues:"

The problem are the ones too lazy to call,

    
    
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    

[https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/...](https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html)

~~~
jessaustin
What problems would it cause if the runtime just called that automatically?

~~~
pjmlp
The usual traditional backwards compatibility story of Java, if I remember
correctly.

When it was introduced they didn't want to break the L&F of AWT applications,
then they also added multiple ways of enabling it.

So a good application should respect the system wide or user specific settings
if available, instead of just blindly use whatever L&F it feels like.

Also although many complain about how Swing looks like, the API is actually
quite powerfull and skinnable, even if it requires some graphic programming
skills to achieve it, for example see JGoodies or UltraMixer DJ.

------
dotdi
That's a great article, but it rather proves the point that the GTK API is a
PITA.

Still, you get a lot of benefit from Ruby's flexibility.

~~~
tomc1985
GTK's API is really quite nice, all things considered. I have never felt so
sane writing GUI code in a good long time

------
lf-non
Not to criticise the (very well written) article, but IMHO the best solution
for rapidly prototyping cross platform GUI applications in Ruby is Electron[1]
+ Hyperloop[2].

GTK applications look very outdated/out-of-place anywhere outside linux, and
especially on OS X.

While electron has its issues (large bundle size, memory footprint), it is a
really flexible solution for cross platform desktop applications. It will
still not have native appearance, but a modern L&F is quite easy to arrive at
using CSS and libraries like react-desktop.

Relying on the browser runtime ensures that most of the form widget
interactions work as users would expect them to on their own platform.

Opal[3] is a really good ruby to javascript compiler which can be used to
target electron. This is particularly promising given that the hyperloop [2]
ecosystem has significantly matured. Hyperloop provides a full fledged
component oriented client-side development framework powered by best of breed
frontend technologies/patterns like virtual DOM (through react integration
[4]) and flux stores.

\---

[1] [https://electronjs.org](https://electronjs.org)

[2] [https://github.com/ruby-hyperloop](https://github.com/ruby-hyperloop)

[3] [https://github.com/opal/opal](https://github.com/opal/opal)

[4] [https://github.com/ruby-hyperloop/hyper-react](https://github.com/ruby-
hyperloop/hyper-react)

~~~
jamesgeck0
Why bother with Electron? Qt is lightweight, has Ruby bindings, and looks
native on everything. Use Furoshiki to build distributable binaries for each
platform.

~~~
djsumdog
I started down the electron path and will probably back out. So many get-
started things in electron are just massive boiler-plate. Electron-vue is
awful boiler plate with so much pre-made crap I don't understand how any of it
fits together and some really simply stackoverflow questions have gone forever
without being answered:

[https://stackoverflow.com/questions/48337401/unable-to-
test-...](https://stackoverflow.com/questions/48337401/unable-to-test-better-
sqlite3-within-a-project-based-on-electron-vue-boilerplate)

Not to mention electron apps are massive (Slack is 90M+ for a fucking chat
client. Audium/Pidgin anyone?)

Electron is a huge step backwards really. I don't see why people praise it so
much.

~~~
mikewhy
So you picked an "awful boilerplate" where you "don't understand how any of it
fits together" and that's a failing of Electron?

~~~
djsumdog
They're all awful boilerplate. Almost every single toolkit or getting started
example I looked at involved cloning something of boilerplate, including
React, Vue, etc. I couldn't even find decent clean examples, and as I tried
putting them together, there was just a total lack of documentation and
frustrating amounts of searching and finding dead/unanswered fourm and
stackoverflow posts.

