3

I would like to know whether a Java based (using Pi4j library and Swing) or Python based GUI (using Tkinter) is more suitable for Pi in terms of execution speed. Following things need to be implemented

  1. Creating a server/client application where Pi will act as a client
  2. Accessing GPIO pins
  3. A stand alone GUI application (Swing for Java and Tkinter for Python)

1 Answer 1

5

You won't see a big difference either way; GUI applications are actually not CPU intensive. Or at least, the GUI part of them is not; they may or may not be doing other things that are. To qualify that a bit further, if the application involves image processing or rendering special types of graphical documents (.pdf, etc.) to the screen, that's sort of an aspect of the GUI and that could be processor intensive. But most GUI applications don't do this.

In other words, if what you are doing is a standard control interface -- buttons, text entries, menus, scrolling lists, etc. etc. -- its GUI aspect does not require significant CPU resources and choosing swing over python here or vice versa will not make any difference to performance.

However, memory is a concern on the pi and GUI applications can use a lot of that. You might want to consider what other things you are most likely to be using at the same time. If those are java based, then java is a better choice because it will be loaded already; likewise with python. Note python has a much smaller footprint to start with.

Also, you are probably using a desktop with a lot of GTK in it, so anything which uses those libraries will save memory too. I believe java swing does not, it uses its own stuff. I am sure there is a python GTK lib, however (that will share memory with the native ones used by most applications) -- but Tk(inter) will be separate again (although relatively small I think).

Python and Java both have raspberry pi specific libraries for GPIO control -- although you don't actually have to use these, since the native sysfs GPIO interface (i.e. /sys/class/gpio) is language agnostic and drop dead simple to begin with.

1
  • I need to read some data from the GPIO pins and communicate with the server through REST framework, so both Java and Python based GUI will almost be the same, I guess......
    – Ron Thomas
    Commented Oct 31, 2014 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.