Need a little help with c++

Hello everyone, I'm a computer science student who has done a lot of work with Java (what my school teaches) and I'm quite good with it. However every time I look in to things that use java all I read is "java sucks" and "never use java". so now that my classes are done involving java I decided to pick up another language to broaden my skill set and find tools that people wont attack me for using.

Now I am very familiar with Javafx for Gui development and can work with it well, however when researching c++ I found that there is no built in Gui tools. Now I am aware that I have to use a third party library to build a Gui, but is there a library out there that is on par with javafx in terms of cross system compatibility and ease of use? Another problem that I have is I prefer to work in vim and not in an IDE, however while looking at this problem i noticed that all of the gui tools for c++ have their own IDE, am i required to use their ide or can I just download the library like a jar file and run it with the code? I am sorry if this is an overly noob question, but trying to find comparative information about c++ vs java is just leading me to people attacking java and that is frustrating me.

For a cross-platform and open source GUI toolkit for C++, I highly recommend taking a look at QT.

1 Like

but does QT require me to use their own IDE, or can I still use vim?

I'm not aware of a single C++ library that requires you to use an IDE. In general, IDEs are just fancy text editors with autocomplete and compiler support built in.

1 Like

wow, looking at the qt license, it is really restrictive. I have to open source all of the work that I do with it!?

Nope, QT is licensed under the Lesser GNU Public License which states that you may link against the library without open-sourcing your software. You only have to opensource your modifications to QT if you make any and plan on distributing QT.

sorry but I am new to c++, how would I link against a library?

In C/C++, to use any sort of library, you have to instruct your compiler to link against the library at compile time. This is normally done with a flag like -lz (which links against another library named zlib). I'm not sure what the necessary flags are for QT but they shouldn't be hard to find. In the case of the license, you can interpret linking against a library as "using a library".

got it, ill give QT a go. thanks for the help.

No worries.

Use tools for what they are good at:

  • Java's best selling point (imo) is its cross-platform ease. C++ is cross platform until you include a platform dependent library, and it requires some forethought to get a good dev ops cycle going. It has strong standard library support, E.G. GUIs.
  • C++ by comparison; gives you more control over hardware and memory. It also provides unique, modern, and powerful tools such as template metaprogramming. It has vast library support, however, the standard template library (STL) that you get by default is not aimed at solving problems such as GUIs.

There are many other things to talk about with regards to both languages, but this description should suffice for my point: Don't learn C++ by jumping into QT. C++ can be used for GUIs, but you'll likely find it tedious and more complex when compared to Java. To boot, I would argue that QT encourages poor memory management in newer C++ programmers since you probably won't be aware of its memory ownership concepts.

You would be better off learning what C++ has to offer before deciding what to do with it. E.G:

  • Learn about pointers, references, const (cv) qualifiers, lvalues and rvalues.
  • Learn the basics of templates and how they are far from being the same thing as generics.
  • Become familiar with the STL.

I could keep going, but that's a lot to research and play with already.

The way to go about this is up to you; there are plenty of tutorials and books available, or you can think of simple projects and just try things out. There are also plenty of incredibly good videos on C++ nowadays.

As for editing C++; I use Atom right now, but there are plenty of die-hard vim users that write C++. I don't know what OS you use, but if you simply Google how to compile C++ on the command line you'll find your way around it.

Lastly, use something like project Euler or SPOJ's list of classical problems to find good entry problems to try and solve with C++. When tackling new languages I've found that to be a rewarding approach. http://www.spoj.com/problems/classical/


As an aside, I would argue that you should not learn a language because people indicated that 'Java sucks' and 'C++ is my lord and saviour!'. I don't use Java because I don't require it for anything that I do. I use ECMAScript for cross-platform GUI stuff, C++ for memory constrained or GPU oriented applications, and C# for desktop applications. Java does suck; because I don't need it for anything. C by the same reasoning sucks. People will never stop comparing apples to oranges.

Have a look at these resources on licensing

https://www.qt.io/qt-licensing-terms/

You can dynamically link to the library fine. Or statically link to is so long as the end user has the ability to re-link it to another version of the library.

The licensing may sound essentially restrictive, but the goal is to preserve the freedom of the code for the user. If you statically linked the code and they couldn't see or edit/change the GPL code you're removing they're rights they have over the code.

It would be exactly the same the other way around, if someone violated a proprietary license.

2 Likes

Thank you, this makes me feel better, looking at a lot of the C++ stuff out there if actually felt rather daunting to look at. I'm definitely going to take a step back and give c++ a proper amount of study before jumping in to the more complicated aspects of it.

wow, this actually explains a lot, thanks for linking me to this. I was misunderstanding what they were saying on the QT website. thank you.

2 Likes

No problem, open libre licensing can be a bit confusion at first. It depends on the perspective you look at them as well.

On C++, make sure you learn modern C++ from the get go. Its a lot easier than the older stuff. The new standards provide a lot of new functions to get stuff done without you needing to reinvent the wheel or use much lower level code to do the same thing. Though the ability to roll you own is still there.

1 Like

do you know any good resources that you could recommend?

Books seem to be the recommended resource as they go into more detail of why things happen where tutorials and such online tend not to or are out of date.

This seems to be the main recommendation http://amzn.eu/2k2YKqJ
and one im going through atm.

Here is a full list of books https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

And these two resources are useful (though i admit a lot is over my head atm)


1 Like

awesome! thanks for this.

2 Likes

This series of videos goes into explicit detail on things like template argument deduction for modern C++: https://channel9.msdn.com/Series/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-/C9-Lectures-Introduction-to-STL-with-Stephan-T-Lavavej

It works from the C++ standard to answer 'what if' questions, so if you download the standard and follow along then you can learn how to read the standard that way. Reading the standard isn't neccessary, but it is the most concise document that defines C++.

1 Like

cool, Ill check this out. thanks.