Java vs. C++, UI-heavy programs

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

Re: Java vs. C++, UI-heavy programs

Post by k1net1k »

Nokurn wrote:In Qt Creator, you can make HTML5 apps with New Project -> Other Project -> HTML5 Application. You write your code in HTML5/JavaScript, and Qt generates a viewer program that uses WebKit.
Now that is pretty cool
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Java vs. C++, UI-heavy programs

Post by bbguimaraes »

The more I discover Qt's features, the more I feel bad for other libraries' developers.
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: Java vs. C++, UI-heavy programs

Post by Nokurn »

k1net1k wrote:
Nokurn wrote:In Qt Creator, you can make HTML5 apps with New Project -> Other Project -> HTML5 Application. You write your code in HTML5/JavaScript, and Qt generates a viewer program that uses WebKit.
Now that is pretty cool
Yeah. It's like a cross-platform .hta that doesn't use Trident. I also find it pretty awesome that you can make web apps, deploy them on the web, and then "port" them to a self-contained desktop or mobile app that doesn't necessarily require an Internet connection to use.

I still wouldn't use it for a game's content editor, though. :P
User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

Re: Java vs. C++, UI-heavy programs

Post by k1net1k »

yeah, my HTML5 suggestion should have had <sarcasm> tags included
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Java vs. C++, UI-heavy programs

Post by MadPumpkin »

Java is a great language, and of course for this type of development you could get all the functionality you want, from either one. My first language to /read/ was Java sort of high level things. In my opinion C++ is far more multi-purpose. But people complain about speed in Java programs a lot, personally I find this to be a good thing, since what they don't realize is that you just have to boost the Java max memory and it will run fine. The reason why I find that to be a plus though is because it causes people to make optimizations as they go, without being obsessively slow about it. When it comes to C++ and Java I always find myself comparing the two to Windows and Mac in this way:

C++:Java
Windows is often considered to be more powerful than Mac
Windows is considered far more suited for game dev than Mac
Windows has a more scalable environment than Mac.

Mac is sexier and easier to navigate
Mac is far easier to learn because things are served to you on a platter
Mac is more commonly used for business because of it's faster use time

Some of those might be "eh" because I just thought up those examples off my head.

EDIT: Forgot my personal recommendation part! I don't use either method. I'm currently writting an externally renderable graphic based UI library in C++. This means that I'll be rendering through DirectX/OpenGL, the menus windows, etc. but have the power of something like Qt. If I had to pick one to write an editor in that ISN'T going to be used by the public: Java. If it's going to be commercially sold with a product or used often: C++ because it's better for larger applications.
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
Moosader
Game Developer
Game Developer
Posts: 1081
Joined: Wed May 07, 2008 12:29 am
Current Project: Find out at: http://www.youtube.com/coderrach
Favorite Gaming Platforms: PC, NES, SNES, PS2, PS1, DS, PSP, X360, WII
Programming Language of Choice: C++
Location: Kansas City
Contact:

Re: Java vs. C++, UI-heavy programs

Post by Moosader »

MadPumpkin wrote: EDIT: Forgot my personal recommendation part! I don't use either method. I'm currently writting an externally renderable graphic based UI library in C++. This means that I'll be rendering through DirectX/OpenGL, the menus windows, etc. but have the power of something like Qt. If I had to pick one to write an editor in that ISN'T going to be used by the public: Java. If it's going to be commercially sold with a product or used often: C++ because it's better for larger applications.
Well, my map editor isn't going to be commercial, but since my games are open source, there's no reason for me to not open-source the basic tools I create for it, as well.
I might try to look into qt some more and see how it works.

Anyone here use WPF? Can anyone give me a comparison between development for WPF vs. qt? WPF is like the only UI development I'm familiar with. <_>
Does qt essentially have a "markup" for the interface, which is separate from the C++ logic?
User avatar
Valfader
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 8
Joined: Mon Apr 09, 2012 10:12 am

Re: Java vs. C++, UI-heavy programs

Post by Valfader »

MadPumpkin wrote: Mac is sexier and easier to navigate
Mac is far easier to learn because things are served to you on a platter
Mac is more commonly used for business because of it's faster use time
In truth Mac is just a overpriced PC. As for the "sexy" part, you get what you pay for. If you spend as much money on a PC as you do on a Mac you will not only match it in "sexiness", but also surpass it in performance big time. Easier to navigate? Please! Just add some widgets and you have the same functionality on a PC. Mac is far easier to learn? Lies. Any machine you spend time learning about will seem to be easier. Hipster kids will usually favor the Mac because they love the glowing half-eaten apple logo on the back of their Macbooks while they're scrolling through their playlist in iTunes while drinking coffee at Starbucks.
Macs are not more commonly used for business (except maybe for graphical design). Take a quick look at stuff that matters (such as CERN) - every machine in there is a PC. Why do you think that is?

On topic: Java will get the job done. No question about that. The moment the application starts to gain scale you are forced to assign more memory to the app, or risk hickups/lag. I personally would never code in Java if I had the choice not to. Simply because I might want to expand on a program later on and I like the freedom of control C++ gives.
Image
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: Java vs. C++, UI-heavy programs

Post by Nokurn »

@Valfader: This is not the place to discuss your opinion on Macs.
MadPumpkin wrote:I'm currently writting an externally renderable graphic based UI library in C++. This means that I'll be rendering through DirectX/OpenGL, the menus windows, etc. but have the power of something like Qt.
Without the community, support, and extensive testing that Qt has.
Moosader wrote:Anyone here use WPF? Can anyone give me a comparison between development for WPF vs. qt? WPF is like the only UI development I'm familiar with. <_>
Does qt essentially have a "markup" for the interface, which is separate from the C++ logic?
They're pretty similar. Qt Creator/Designer uses an XML markup (.ui files) to describe forms, which is then converted to a .h containing a UI class at compile-time. The form class itself then uses this UI class to initialize itself and its widgets. So the UI files could be considered analogous to XAML files.

However, comparing Qt to WPF is like comparing Unity to OpenGL. WPF is interface-only; it has a very specific purpose (user interfaces) and doesn't do much other than that. Qt goes far deeper than just user interfaces. It's more comparable to the .NET framework as a whole.
User avatar
MadPumpkin
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 484
Joined: Fri Feb 13, 2009 4:48 pm
Current Project: Octopia
Favorite Gaming Platforms: PS1-3, Genesis, Dreamcast, SNES, PC
Programming Language of Choice: C/++,Java,Py,LUA,XML
Location: C:\\United States of America\Utah\West Valley City\Neighborhood\House\Computer Desk

Re: Java vs. C++, UI-heavy programs

Post by MadPumpkin »

Valfader wrote:In truth Mac is just a overpriced PC. As for the "sexy" part, you get what you pay for. If you spend as much money on a PC as you do on a Mac you will not only match it in "sexiness", but also surpass it in performance big time. Easier to navigate? Please! Just add some widgets and you have the same functionality on a PC. Mac is far easier to learn? Lies. Any machine you spend time learning about will seem to be easier. Hipster kids will usually favor the Mac because they love the glowing half-eaten apple logo on the back of their Macbooks while they're scrolling through their playlist in iTunes while drinking coffee at Starbucks.
Macs are not more commonly used for business (except maybe for graphical design). Take a quick look at stuff that matters (such as CERN) - every machine in there is a PC. Why do you think that is?
Lol that's not even the point xP. The point is that those things in my opinion apply to C++:Java
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
Image
Image
Image
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: Java vs. C++, UI-heavy programs

Post by Milch »

I'm using Java for my smaller GUI programs - Swing to be exact - (e.g. map-compiler interface), because C/C++ programs are to heavy to set up, and with Java everything is in place the moment you start coding (+ its basically cross platform without any effort)
Still, I would not use pure SWING for any bigger GUI programs - it misses really important features (like remembering window coordinates or the last used layout) - if you really want to make a big GUI program - I would either use the Eclipse RCP or the Netbeans one - these are basically really big feature packed GUI platforms, though, they take a lot of time learning before they are worthwhile using.

(+ Java features awesome runtime-debugging I couldn't live without anymore :P)
Follow me on twitter!
User avatar
Valfader
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 8
Joined: Mon Apr 09, 2012 10:12 am

Re: Java vs. C++, UI-heavy programs

Post by Valfader »

@Nokurn: I've found your doppelganger - http://www.imdb.com/name/nm0167649/
Image
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Java vs. C++, UI-heavy programs

Post by Arce »

The more I discover Qt's features, the more I feel bad for other libraries' developers.
+1

Oh, god. Qt all the way! (we all knew I'd say this. ;p)

Aside from the language implications of choosing Java, did you hear that there won't be any Swing updates for Java 7? That leaves you with a built-in UI framework from the late 90's which just isn't on top of the times anymore. (http://www.infoq.com/news/2009/09/java7_m5)

And going back to your original post, you made this argument in favor of Java:
Java is also higher-level, and while I enjoy making my games with C++, I don't know if I have the patience to work with an application at that low of a level
The thing that you need to understand about Qt is that is IS a higher level "addon" to C++ in addition to a powerful GUI library. Qt introduces a framework class library, a form of auto garbage collection, easy work-arounds for RTTI as well as RTTI support, and a powerful notification system similar to delegates that prevent you from having to pass around pointers and references all the time. Oh, and there is "for each" loops. Trendy, eh? ;p

If your worry in using qt is "patience" then you will be pleasantly surprised!

Here is a quick article addressing the one true downside I have found to using Qt, and that relates to templates (not a good first read!):
http://qt-project.org/doc/qt-4.8/templates.html

The article ends by saying this, which is spot on.
C++ with the moc essentially gives us the flexibility of Objective-C or of a Java Runtime Environment, while maintaining C++'s unique performance and scalability advantages. It is what makes Qt the flexible and comfortable tool we have today.


It sounds like maybe you are a bit under informed about what Qt is, so I'll elaborate some. =)

The magic behind Qt all happens because of an extra step they have added to the compilation process, called the "moc." What this does is parse your code and enact lexical replacement in all classes that have the macro, Q_OBJECT. The primary reason for this extra step is to birth a powerful notification system, called "Signals and slots." I'll get to elaborating on this in a sec.

The second part of the puzzle is their framework class library. Similar to Java and C#, everything inherits from QObject. Together, this class library and extra compilation step add the following features to C++:

Code: Select all

@ a very powerful mechanism for seamless object communication called signals and slots
@ queryable and designable object properties
@ powerful events and event filters
@ contextual string translation for internationalization
@ sophisticated interval driven timers that make it possible to elegantly integrate many tasks in an event-driven GUI
@ hierarchical and queryable object trees that organize object ownership in a natural way
@ guarded pointers (QPointer) that are automatically set to 0 when the referenced object is destroyed, unlike normal C++ pointers which become dangling pointers when their objects are destroyed
@ a dynamic cast that works across library boundaries.

Oh goddammit, it's really not worth me explainig because Qt's docs will do it better. :P Before you decide against Qt, just make sure you have read the following about it:

http://qt-project.org/doc/qt-4.8/object.html
http://qt-project.org/doc/qt-4.8/signal ... -and-slots
http://qt-project.org/doc/qt-4.8/qvariant.html
http://qt-project.org/doc/qt-4.8/proper ... rty-system
http://qt-project.org/wiki/How-to-use-signals-and-slots


And, just for the hell of it, here's what code usually looks like in Qt:

Code: Select all

QPushButton *button = new QPushButton;
 QObject *object = button;

 button->setDown(true);
 object->setProperty("down", true);
Notice we don't delete either object--them being QObject derivatives make the calling widget the parent, and will automatically delete their children on destruction. Also, notice how we just pulled a dynamic "property" out of our asshole called "down" and assigned a value to it. Isn't that awesome? ;p


And now, to answer this question:
Does qt essentially have a "markup" for the interface, which is separate from the C++ logic?
Absolutely!...If you want it to.

The .ui files created by Qt's Designer application can be loaded at runtime for a dynamic UI. Here is information on the .ui file that is exported from Qt Designer, which is the UI tool:

http://qt-project.org/doc/qt-4.8/design ... -file.html
(it's basically an XML export).

OR, you can use a more powerful markup language, QML, that has built in JavaScript support:

http://doc.qt.nokia.com/4.7-snapshot/qd ... ction.html

Or you can just use C++ logic, which Falco prefers, since Qt's layout system is so freakin awesome! ( http://qt-project.org/doc/qt-4.8/layout ... youts.html ) . I _seriously_ suggest you check out this basiclayouts article to get a feel for what to expect from Qt before making your decision.

Not only this, but Qt's docs and Qt's IDE are SOOOOOOOOOOOOOO fucking good. Like, seriously. You'll have a hard time using anything else afterwards.

Here's where you'd "Get started" if you choose Qt: http://qt-project.org/doc/qt-4.8/gettingstartedqt.html

And, here is a full Qt application, just for demonstrative purposes:

Code: Select all

1      #include <QtGui>
  2
  3      int main(int argv, char **args)
  4      {
  5          QApplication app(argv, args);
  6
  7          QTextEdit *textEdit = new QTextEdit;
  8          QPushButton *quitButton = new QPushButton("&Quit");
  9
 10          QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
 11
 12          QVBoxLayout *layout = new QVBoxLayout;
 13          layout->addWidget(textEdit);
 14          layout->addWidget(quitButton);
 15
 16          QWidget window;
 17          window.setLayout(layout);
 18
 19          window.show();
 20
 21          return app.exec();
 22      }
With the X11 output being: Image
Would somebody be so kind as to grace me with the java equivalent code? =D

So if I haven't sold you yet...Tell me why not and I'm betting I can remedy it. =) Also, Qt's IRC channel is always flooding with guys who helped make Ubuntu's frontend and are always willing to help.
Last edited by Arce on Mon Apr 30, 2012 1:40 pm, edited 1 time in total.
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Java vs. C++, UI-heavy programs

Post by bbguimaraes »

I knew somewhere there was another Qt lover. ;) It was good when I was showing my Distributed Systems teacher our project, a game using sockets, and I said it was done with c++ (he is also a c/++ lover). His only question was "What did you use for the UI?".
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Java vs. C++, UI-heavy programs

Post by Arce »

Also, I've never used WPF. Google leads me to believe it's some sort of GUI framework using components from .net? "Windows presentation foundation" sounds like you're going to have to deal with managed C++ if you use this, or C#/vb. I personally am a fan of C#, but I would be hesitant in limiting myself to something windows specific. Mono has always been pretty clunky to me, and always a few generations behind .net.

Although you may not consider it plausible now, in the future you may want to share some code between your editor and engine. My main concern with using WPF is the fact that you will not be able to do this easily. You'd have to use wrappers to managed C++ classes...to me, it would be less of a headache to simply rewrite it all in the editor, which is to say not a very good option. In the ES toolkit, we share our asset i/o mechanism between the toolkit and engine and have little to no problems. If we were still working with our .net Toolkit prototype that Marauder made, this would not be so easy...

Also, I have seen several comparisons of QML to WPF. I personally haven't worked with QML, and have little interest in doing so...(feels like a bunch of overhead learning for little payoff) but if you are already comfortable in WPF I would maybe take a look at it. Of course, I'm biased as shit towards Qt, and it goes without saying that one will have an easier time working in something they are already comfortable with.
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Java vs. C++, UI-heavy programs

Post by Falco Girgis »

There's no contest between C++/QT and Java/C# anymore.

There was a time when I was paying my bills with C#, that I genuinely began considering the higher-level JIT languages better-suited for application development... Then I found QT, where I could harness the power of C, C++ (and shit, even inline assembly. It's natively compiled, why not?) and combine it with the flexibility, rapid development times, and feature richness of the QT framework.

I think that QT really gives C++ an extra edge in the desktop application arena. The JIT saying of "C++ is too low level and takes too long for application development" becomes bullshit.
Post Reply