Alex Rivera | Logout

Writing GUI in one language and main app in another

Asked 2011-06-13T13:20:13.137
20

Let's say I write an app in Haskell or Erlang (or any other, doesn't matter) and I want it to work with my gui in a more gui-friendly language (my opinion) let's say Python. How to glue those two? How would you communicate between those two parts of application? Making some kind of a server or something? Is this kind of solution popular? I've seen things like SMplayer which is a gui for mplayer and it works pretty good. What are your thoughts on this kind of design?

Edit
Report

3 Answers

1

If by gui friendly language you mean having Visual GUI Designer, then you still can do it in haskell. 2 major linux GUI frameworks, GTK and QT have visual designers and you can use the GUI files they produce from haskell.

Check out gtk2hs or qthaskell libraries.

answered 2011-06-13T19:19:17.347
1

Thrift supports Haskell, Erlang and Python:

Thrift is a software framework for scalable cross-language services development. It combines a software stack with a code generation engine to build services that work efficiently and seamlessly between C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, and OCaml.

answered 2011-06-14T23:21:16.567
0

It is going to depend on the exact language you want to use both for the GUI and for the logic. As David answered, you basically only have those two choices, and they both have advantages and disadvantages:

Putting everything in a single app is the best performance-wise, because when you will make the calls to the other language, it will not wait until the other process will get control, and then will not wait for your process to gain control again to receive the answer. This is also the easiest solution if you can embed a language in another language, then they will by definition run in the same process.

Using different processes can be good if you are all the time doing a lot of things in the "logic" process, but want the gui to still be responsive. (although this could be achieved with threads too, in a single process). Also, if you can't embed the languages, this will be the easiest solution. (for example using simple sockets for IPC, which exist in almost all the languages and are truly portable. (which is not as true for things like pipes or shared memory)

So it really depends on the languages you will choose.

answered 2011-06-13T14:11:18.737

Your Answer