Hacker Newsnew | comments | show | ask | jobs | submit login

I came up with my own technique for developing "GUI" without any fancier tool than standard programming languages and their frameworks.

I create a launcher called "weboot" that gets parameters like directory and URL resource to start on. It launches an http server process and sends a command to the browser via command-line (but could use other means) with a generated URL (because you don't want to be stuck on an already used port). Browser goes to: http://127.0.0.1:8066/some_resource

Now you have HTML+JavaScript for the frontend and your preferred web framework and tools on the backend. It all costs just as much as you use, so don't launch Apache, just a small http server will do. ;-)

The secret comes next. The frontend needs to ping the backend every several seconds to keep it from shutting down on purpose. The reason is that after the user closes the browser or the tab, the server process has done its job and should close automatically. It all works very well on Linux. I have created a small calculator and a tetris game to test this already and I pompously called them widgets. ;-)

I also have my own ideas for creating an IRC client based on this technique as I have created several versions of IRC clients over the years and even though XChat works great for me on Linux so I don't have a real urge to do that again, it's a trivial exercise in the same way the tetris game was. When I get my bugs list under control I might give it a go again.

So, the JavaScript side loops with something like:

setInterval(function(){ new AjaxRequest('/ping'); }, 5000);

These values are all tunable. I started with a ping every 5 seconds and the server closes in 12 seconds (two pings + some extra time), but I pulled those numbers out of thin air and in 12 seconds I can even reopen a tab fast enough to avoid the server dieing in case of trouble. ;-)

I like Ruby rather than Python, and I have used GTK+ with Ruby for a while myself, but the GTK+ development in Ruby has been a little under trouble as it seems as if no one who is good enough at C and Ruby has it as a high priority on their list of things to maintain, with more and more things moving to the web and so on...

Also, even the development of GTK+ itself and Gnome in general seem to be under a little trouble as more developers seek greener pasture elsewhere and new blood is rarer to come by to replace them. Things like QT, Swing, SWT (Eclipse's UI toolkit?), and even Gtk# (Mono) are generally on another planet than low level C required by GTK+.

Good luck.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: