Java or Mono for basic GUI rPi apps?

General programming chat and advice for beginners

24 posts
by EdwinJ85 » Thu May 24, 2012 8:48 pm
Hi guys, I am a relatively inexperienced coder but I want to help make a couple of GUI apps for the pi. I've boiled it down to Java or Mono, both of which will run on the pi as long as you don't try to use their IDE's on the pi itself.

Which would you say is better? As far as I can tell neither of them are included in debian as standard and you have to install their runtimes manually. I work with .net everyday and am a lot better with it than Java, which I am just trying out now. Compiling and executing a .jar is way harder than just double clicking an .exe in windows!

You guys are the pros, what would you recommend? I have tried C/C++ and failed every time. I also cant work on the command line, it's too hard, I'd need to write with an IDE on my windows machine and port the compiled product over to the pi to run. As for cross compiling across SSH, that would make me cry tears of blood. That's far too hard for my level.

I'd happily consider python, but can it create GUI apps without making the user install a load of GUI frameworks and can it call other processes? I know nothing about it. I'd still need some sort of IDE with it, without breakpoints and decent error messages I won't last 5 seconds with a langauge.

Thanks!
Getting doom to run is my "Hello World".
Posts: 208
Joined: Wed Feb 01, 2012 4:44 pm
by andyl » Thu May 24, 2012 11:24 pm
EdwinJ85 wrote:Hi guys, I am a relatively inexperienced coder but I want to help make a couple of GUI apps for the pi. I've boiled it down to Java or Mono, both of which will run on the pi as long as you don't try to use their IDE's on the pi itself.

Which would you say is better? As far as I can tell neither of them are included in debian as standard and you have to install their runtimes manually.


I would say neither. I would say use python and an appropriate graphics library - maybe PySide or PyQt (I don't actually know if these run on the Pi yet - mine is in the post to me).

Mono isn't very well accepted in the linux world. Both Mono and Java would be a bit sluggish for the pi. They both use fairly large amounts of memory for their libraries. Not particularly a problem on a full desktop, but on a memory constrained device I would be doing all I could to reduce any fat.

I'd happily consider python, but can it create GUI apps without making the user install a load of GUI frameworks and can it call other processes?


Well just the one library for a GUI library. At the moment no-one knows what is exactly going to be in the final cut of the distribution - so something like pyside or pyqt might be in the final image.

Calling external programs is very, very easy.

You would either be able to create a .deb package file so that it installs just like normal software and will pull in the right dependencies or just have a simple install script. As you have said you are probably worse off with mono or java.

I know nothing about it. I'd still need some sort of IDE with it, without breakpoints and decent error messages I won't last 5 seconds with a langauge.


Loads of IDEs. However python is a very easy language to get started with. Easier than Java IMO, and easier than C#.

Thanks![/quote]
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by error404 » Fri May 25, 2012 12:26 am
Qt. I know it's not on your list, but it pretty effectively protects you from the details of C/C++, has an excellent (IMO) framework and GUI library design, and good, easy to use tools for UI design and whatnot. It's quite a bit different conceptually than either Java or .NET, but I personally think it's a better design. With the newest versions you can not write any traditional code at all using Qt Quick.

Best of all it compiles to native code and uses the Qt library which you're likely going to want for some other things anyway.

If you have to choose between Java and Mono I would probably prefer Mono; there's less license and other confusion around the runtime and I prefer C# to Java. Also the library is easier to use and more practical. But I don't think either is particularly suitable to the Pi. If you're willing to sacrifice performance and memory usage for ease of development I'd second andyl and suggest Python. It doesn't have quite the tools available that any of the others do though, and for someone that's afraid of the command line, that's probably more relevant than anything else.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by EdwinJ85 » Fri May 25, 2012 8:50 am
I'm seeing that Python is getting the most votes, and as it comes with the Pi's standard distro it seems to make the most sense. It's just a case of choosing the correct GUI library, I don't fancy rewriting things if a different library ships!

As an aside, I also prefer C# to Java but the whole point of getting a Raspberry pi is to get out of my comfort zone and try something non windows. I'm not sure mono is the best choice as unlike the .NET compact framework it hasn't been designed with low memory in mind. The Java Micro Edition runs on very low memory phones and blu ray players (http://en.wikipedia.org/wiki/Java_Platf ... ro_Edition) so I thought that it would work alright on the Pi, better than Mono.

As it is so big on low memory android devices (although very different I know, no swing library and Dalvik does all sorts of new tricks) I thought it would work well on the Pi. I still think you are right about Python but IF I fail with that I need a fall back, at the moment the plan is to try these things in order:

1) Python
2) Java
3) Mono
4) Cry

I appreciate that I'm a bit silly for not knowing command line or hardcore langauges (C/C++) but it's harder to learn than a lot of people (who don't realise how much smarter they are than the average bear in these matters) give it credit and you have to walk before you can run. Believe me I have tried running first, and it doesn't work!
Getting doom to run is my "Hello World".
Posts: 208
Joined: Wed Feb 01, 2012 4:44 pm
by error404 » Fri May 25, 2012 9:45 am
If you can write code that works and grok the tools you're using to develop it, understanding a couple straightforward command line tools doesn't seem like a stretch at all. The few tools you need to get work done in the command line are much simpler than even a single namespace of the .NET library I'd say. Anyway, I digress.

Java actually probably works okay on the Pi, but there are a few things that are just a bit...hairy these days. The Java runtime situation on Linux has always been a bit of a mess of incompatible competitors, weird licensing issues and/or poor performance. I think some of that is better than it used to be, but may be more complicated on ARM. Also there aren't really any good graphics bindings to the standard Linux UI toolkits, and the Java standard stuff is crap. Most of these things are much better over in the Mono camp, and it's significantly more popular on Linux (and in general, really, look at things like Iron Python) than Java as a result. If you wanted to write command line programs I'd say it doesn't really matter which runtime you target, but .NET seems to me like it'd be better for GUI work.

If you already know C#, I'd really say again that you give Qt a look, I think you'll feel relatively at home with it. Python is quite a departure from that style of development, especially when it comes to GUIs.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by andyl » Fri May 25, 2012 9:50 am
EdwinJ85 wrote:I'm seeing that Python is getting the most votes, and as it comes with the Pi's standard distro it seems to make the most sense. It's just a case of choosing the correct GUI library, I don't fancy rewriting things if a different library ships!


Well the GUI libraries will be there. Qt has been talked about for months. The Python interfaces may not. However there are ways to cope with that. But no need to worry about that just yet.

As an aside, I also prefer C# to Java but the whole point of getting a Raspberry pi is to get out of my comfort zone and try something non windows. I'm not sure mono is the best choice as unlike the .NET compact framework it hasn't been designed with low memory in mind. The Java Micro Edition runs on very low memory phones and blu ray players (http://en.wikipedia.org/wiki/Java_Platf ... ro_Edition) so I thought that it would work alright on the Pi, better than Mono.


JavaME isn't a full Java stack, it is very cut down. AFAIK there doesn't exist a native JavaME environment for Linux (and maybe Windows). When you develop JavaME and test locally things run in an emulator, they do not look, feel, or act like native programs.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by EdwinJ85 » Fri May 25, 2012 1:10 pm
Hmmm, so Python and Java are shaky options eh? It's a shame, I was really looking forward to an excuse to pick up Java, it looks quite fun. I think Mono is out now because MS are only providing the newest versions of Visual Studio Express (VS11) for Metro app development now and I much prefer visual studio for C# than monodevelop. It will be impossible to distribute metro apps for free anyway, so C# might be dying in the long run on Windows 8. That said, would I be able to wrap up mono in the installer for my app? I just want people to be able to run things with the minimum of fuss, if people have to install an app AND a framework to run it they tend not to bother.

If Python does get cut off from QT will I have to rewrite things in C++? I don't mind learning a new language as long as it's possible for me to learn it (C++ would be too hard) and I don't get burned on it later. If I made something on the Pi in a month but it wouldn't run in a year that would suck.

Thanks for all the input guys, you are being incredibly helpful. Would anybody have some links to how to learn python/qt on windows? I imagine it will involve having to use linux but as long as I can run it off a USB stick without installing it on my HD I should be ok. I could always learn QT c++ if you think I could handle it, but I don't think I could. Pointers are a lot of extra work, as are memory leaks.
Getting doom to run is my "Hello World".
Posts: 208
Joined: Wed Feb 01, 2012 4:44 pm
by andyl » Fri May 25, 2012 2:30 pm
EdwinJ85 wrote:Hmmm, so Python and Java are shaky options eh? It's a shame, I was really looking forward to an excuse to pick up Java, it looks quite fun. I think Mono is out now because MS are only providing the newest versions of Visual Studio Express (VS11) for Metro app development now and I much prefer visual studio for C# than monodevelop. It will be impossible to distribute metro apps for free anyway, so C# might be dying in the long run on Windows 8. That said, would I be able to wrap up mono in the installer for my app? I just want people to be able to run things with the minimum of fuss, if people have to install an app AND a framework to run it they tend not to bother.

If Python does get cut off from QT will I have to rewrite things in C++? I don't mind learning a new language as long as it's possible for me to learn it (C++ would be too hard) and I don't get burned on it later. If I made something on the Pi in a month but it wouldn't run in a year that would suck.

Thanks for all the input guys, you are being incredibly helpful. Would anybody have some links to how to learn python/qt on windows? I imagine it will involve having to use linux but as long as I can run it off a USB stick without installing it on my HD I should be ok. I could always learn QT c++ if you think I could handle it, but I don't think I could. Pointers are a lot of extra work, as are memory leaks.


1) at no point did I say that Python was a shaky option. It is the preferred option. In fact you have multiple choices for the graphics - in the Unix world choice is good. Another option would be SDL - namely use PyGame.

2) another problem with mono is that if you develop on Windows you may be tempted to use parts of the .net framework which haven't been implemented by the mono project.

3) Python will not get "cut off" from QT. It is impossible. The libraries are community developed.

4) learning

4a) first learn a bit of python - lots of books already mentioned. Search and decide which suits your level of knowledge.

4b) then look at teaching yourself how to create a graphics UI.
A quick google found - http://talk.maemo.org/showthread.php?t=43663
There are also books to help - Rapid GUI Programming with Python and Qt - would look like it would be a help.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by EdwinJ85 » Fri May 25, 2012 3:11 pm
I guess I should start with Python then, command line stuff at first and when I am comfortable switch over to the GUI things. If tuns better than Java or Mono on the Pi and doesn't require an extra install that makes it better than both of them in my opinion as I intend to target Debian/Raspian with everything I make for now.

Can you recommend a good editor/interpreter for it on windows please? If not I can set up some linux emulation but I think that might be overkill. Thanks.
Getting doom to run is my "Hello World".
Posts: 208
Joined: Wed Feb 01, 2012 4:44 pm
by Narishma » Fri May 25, 2012 4:39 pm
EdwinJ85 wrote:I guess I should start with Python then, command line stuff at first and when I am comfortable switch over to the GUI things. If tuns better than Java or Mono on the Pi and doesn't require an extra install that makes it better than both of them in my opinion as I intend to target Debian/Raspian with everything I make for now.

Can you recommend a good editor/interpreter for it on windows please? If not I can set up some linux emulation but I think that might be overkill. Thanks.

You can use any editor you want. Just follow the advice of whatever book or tutorial you're using.
Posts: 150
Joined: Wed Nov 23, 2011 1:29 pm
by error404 » Fri May 25, 2012 7:52 pm
EdwinJ85 wrote:I think Mono is out now because MS are only providing the newest versions of Visual Studio Express (VS11) for Metro app development now and I much prefer visual studio for C# than monodevelop.

Frankly, who cares what MS does? You're writing software for a Linux box. Visual Studio is, and always has been, among the best IDEs available. You're unlikely to find much that's as good as it no matter what you choose to do. The MS tools are excellent, but if you want to develop for the Pi you're going to have to live with tools that are at least a lot different, if not much worse.

if people have to install an app AND a framework to run it they tend not to bother.

If you develop something good and useful and release it under an appropriate open source license, you can just package it for the distribution's package manger and pulling dependencies will happen automatically and nobody will care.

If Python does get cut off from QT will I have to rewrite things in C++? I don't mind learning a new language as long as it's possible for me to learn it (C++ would be too hard) and I don't get burned on it later. If I made something on the Pi in a month but it wouldn't run in a year that would suck.

You can write to Qt from any language with Qt bindings, but the Qt tools are really designed for use with C++ and the new Qt Quick (which is QML + Javascript instead, I guess kind of how XAML works on Windows, though I've never done that). Really though using a framework like Qt or .NET in C++ isn't very difficult. If you stay within the managed framework you don't have to worry about any of the hard stuff, the framework provides most everything you should need. Maybe you'll have to deal with interfacing more traditional C libraries if you need something outside the framework, but for the most part this should be pretty simple. You shouldn't give up before you've even started.

Python is a great choice too, I just hate writing GUI code and want tools to do that for me, and I don't think that exists for Python.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by andyl » Fri May 25, 2012 9:01 pm
error404 wrote:
EdwinJ85 wrote:I think Mono is out now because MS are only providing the newest versions of Visual Studio Express (VS11) for Metro app development now and I much prefer visual studio for C# than monodevelop.

Frankly, who cares what MS does? You're writing software for a Linux box. Visual Studio is, and always has been, among the best IDEs available. You're unlikely to find much that's as good as it no matter what you choose to do. The MS tools are excellent, but if you want to develop for the Pi you're going to have to live with tools that are at least a lot different, if not much worse.


Well IDE choice is very much a matter of taste. I would take Eclipse over Visual Studio to be honest. Although both are way too heavy for the Pi (even if the Pi could run Windows which it can't).

error404 wrote:Python is a great choice too, I just hate writing GUI code and want tools to do that for me, and I don't think that exists for Python.


You used to be able to use QT Designer to layout your screens and then pyuic to convert them to Python code.

http://wiki.python.org/moin/JonathanGar ... t_Designer - gives a brief example
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by jools » Sun May 27, 2012 6:34 am
I think the point that is being missed here is that it is perfectly possible to develop GUI apps on Visual Studio on a Windows machine and then put the .exe file on your Pi and run it using mono on the Pi. Or if you prefer you can use the mono-develop IDE on a bigger linux box to do your developing.
Posts: 24
Joined: Sun Feb 19, 2012 9:47 pm
by EdwinJ85 » Mon May 28, 2012 8:32 am
jools wrote:I think the point that is being missed here is that it is perfectly possible to develop GUI apps on Visual Studio on a Windows machine and then put the .exe file on your Pi and run it using mono on the Pi. Or if you prefer you can use the mono-develop IDE on a bigger linux box to do your developing.


That was one of my main plans, yes. This is why visual studio is even part of the discussion, I know it has no chance in hell of running on Linux, let alone the Pi.

I guess I could just write things in Mono and wrap the dependencies up in the installer (I wasn't sure if this was possible before) but would I be able to skip the mono install if it already existed on the machine? I have no experience of Linux, please forgive these noob questions!

It does feel like cheating a bit but C# is such a nice and easy langauge to learn. Qt with Javascript seems pretty simple too, I can avoid dreaded pointers and use another language I already know quite well. If only javascript had an IDE as good as visual studio! VS doesn't give it half the attention with intellisense and other things that it does with the main .NET langauges, which is a shame.
Getting doom to run is my "Hello World".
Posts: 208
Joined: Wed Feb 01, 2012 4:44 pm
by EdwinJ85 » Mon May 28, 2012 8:45 am
error404 wrote:
EdwinJ85 wrote:I think Mono is out now because MS are only providing the newest versions of Visual Studio Express (VS11) for Metro app development now and I much prefer visual studio for C# than monodevelop.

Frankly, who cares what MS does? You're writing software for a Linux box. Visual Studio is, and always has been, among the best IDEs available. You're unlikely to find much that's as good as it no matter what you choose to do. The MS tools are excellent, but if you want to develop for the Pi you're going to have to live with tools that are at least a lot different, if not much worse.

if people have to install an app AND a framework to run it they tend not to bother.

If you develop something good and useful and release it under an appropriate open source license, you can just package it for the distribution's package manger and pulling dependencies will happen automatically and nobody will care.

If Python does get cut off from QT will I have to rewrite things in C++? I don't mind learning a new language as long as it's possible for me to learn it (C++ would be too hard) and I don't get burned on it later. If I made something on the Pi in a month but it wouldn't run in a year that would suck.

You can write to Qt from any language with Qt bindings, but the Qt tools are really designed for use with C++ and the new Qt Quick (which is QML + Javascript instead, I guess kind of how XAML works on Windows, though I've never done that). Really though using a framework like Qt or .NET in C++ isn't very difficult. If you stay within the managed framework you don't have to worry about any of the hard stuff, the framework provides most everything you should need. Maybe you'll have to deal with interfacing more traditional C libraries if you need something outside the framework, but for the most part this should be pretty simple. You shouldn't give up before you've even started.

Python is a great choice too, I just hate writing GUI code and want tools to do that for me, and I don't think that exists for Python.


Hmm, you make a very good argument but I have always failed and failed hard with C and C++, the most technical thing I ever did with them is compile a version of chocolate doom in visual studio after adding the relevant SDL libs and references and playing it on my PC. Fun, but a bit pointless.

If I were to stick to the .net framework, surely I might as well use C#? I thought the whole reason C++ was so popular was because it didn't use as much memory as C# as you have to manage your own memory, which the .net framework removes, a gcnew string is the same as a c#/vb string right, and removed by the CLR garbage collection process when no longer used?

I'll go with what the consensus says to go for, because outside of C# and Javascript I am a terrible programmer! I am still thinking Mono developed on my PC and deployed to the Pi would make sense.
Getting doom to run is my "Hello World".
Posts: 208
Joined: Wed Feb 01, 2012 4:44 pm
by error404 » Mon May 28, 2012 6:49 pm
If I were to stick to the .net framework, surely I might as well use C#? I thought the whole reason C++ was so popular was because it didn't use as much memory as C# as you have to manage your own memory, which the .net framework removes, a gcnew string is the same as a c#/vb string right, and removed by the CLR garbage collection process when no longer used?

If you know it, then absolutely! Any .NET language will produce similar code so there's not really any advantage to using one over the others I don't think. It was just an example for you have an idea of how C++ can be easy-ified by a good library, which is what Qt provides.
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm
by mkeeley » Tue May 29, 2012 5:48 pm
Personally I can't stand Java, so out of it and c# it would be no contest. Had a look a time back at Python GUI under Windows and it was pretty horrible (the look not the programming) would probably be better under Linux but haven't investigated yet.
Posts: 29
Joined: Sun Feb 19, 2012 12:44 am
by EdwinJ85 » Fri Jun 01, 2012 9:37 am
I'd say Java as a language isn't so bad (from my limited hello world console/swing app experience) on it's own other than it lacks LINQ and methods are camelCase rather than UpperCase, but environment wise .NET piddles on it. Microsoft has their failures (IE anybody?) but Visual Studio is not one of them, it's one of the most impressive bits of software I have ever used.

Shame the masses have no clue it exists and that MS also provide several free versions of it. MS get a lot of stick, a lot of which they deserve but some it they definitely do not.
Getting doom to run is my "Hello World".
Posts: 208
Joined: Wed Feb 01, 2012 4:44 pm
by simongoth » Fri Jun 15, 2012 11:53 am
If you like VS and want to learn Python there is a plugin http://pytools.codeplex.com. WinSCP and Putty make using MS environment on Linux boxes hassle free - might ease the learning curve.
Posts: 1
Joined: Fri Jun 15, 2012 11:44 am
by fulburncams » Fri Jun 15, 2012 1:52 pm
Hi
I use Java with Netbeans (very nice IDE) running on Win 7 , download (using WinSCP) either JAR's direct or recompile the .java files into .class files using OpenJDK on RPi. Any low level stuff I am using JNI with hacked C shared library. Although I have run small GUI / Swing apps I intend to use the RPi to serve up applets ( at least initially) using Apache. NetBeans has the capability to connect remotely for C dev but have not managed this yet on teh RPI ( I need to get SAMBA working apparently - still struggling with Linux but getting there I think).
Re Mono and Python - never used , just started Python tutorial though.

Good Luck
Steve
User avatar
Posts: 70
Joined: Wed Nov 30, 2011 8:29 pm
by EdwinJ85 » Fri Jun 15, 2012 4:18 pm
I've got a mono 2.8 profile set up on my Windows VS 2010 express instance, but I might look into Java if I get a Galaxy S3 this weekend, which I am very, very tempted to do. Technically it's Linux based as well, just with a lot of custom code on top. My Pi has arrived, I am just awaiting a memory card which is taking FOREVER to arrive in the post.

Java on Android is very different to normal java though. Swing windows don't exist, everything compiles to a different form of byte code and .jar files don't exist. The very basics are the same, but you could say that about C and C#....

As for python, there is an add on for Notepad ++ I have been using for it. I haven't done much but I am impressed with how it responds to you as you code rather than requiring a compile - even Javascript needs to be saved into a .js file and interpreted by a browser before you get any results.
Getting doom to run is my "Hello World".
Posts: 208
Joined: Wed Feb 01, 2012 4:44 pm
by pauldy » Fri Jun 15, 2012 8:04 pm
I've been working with the pi for a few days now and C# with mono works fine. I wrote mine as a WinForms app then setup my own xinitrx that laucnhes the app full screen without a windows manager and it runs like a champ. The app is very responsive and it was dirt simpel to develop in visual studio then just sftp the exe to the pi and run it.
Posts: 20
Joined: Tue Jun 12, 2012 3:34 pm
by sksig » Sat Dec 08, 2012 2:07 am
pauldy wrote:I've been working with the pi for a few days now and C# with mono works fine. I wrote mine as a WinForms app then setup my own xinitrx that laucnhes the app full screen without a windows manager and it runs like a champ. The app is very responsive and it was dirt simpel to develop in visual studio then just sftp the exe to the pi and run it.

Hi Pauldy.

Im planning on creating a rpi app that uses database user login authentication. Then it sends certain data from gpio to the database. I have a little experience with visual studio and c++ and c#. Could you please explain the steps needed to get started? P.s. I have been searching online for a week now and tried various things with little luck.
Posts: 1
Joined: Sat Dec 08, 2012 1:54 am
by adammada99 » Sun Oct 27, 2013 3:11 pm
pauldy wrote:I've been working with the pi for a few days now and C# with mono works fine. I wrote mine as a WinForms app then setup my own xinitrx that laucnhes the app full screen without a windows manager and it runs like a champ. The app is very responsive and it was dirt simpel to develop in visual studio then just sftp the exe to the pi and run it.


Hello Pauldy, I'm also planning on creating an rPi GUI app that allows users to store information into a database. The database is created by using the rPi as a LAMP server. If you could also explain your process in creating the WinForms app using C#, and how you got it to run on the Raspberry Pi successfully, I feel that would help me greatly in getting started.
Posts: 1
Joined: Sun Oct 27, 2013 3:05 pm