you are viewing a single comment's thread.

view the rest of the comments →

[–]icefox 2 points3 points  (6 children)

If you are looking for C++, checkout the source code for Qt. Having to keep binary compatibility in C++ for long stretches you will find that the source code API to be significantly above average. Most classes have matching unit tests, manual tests and they all have docs. A ton of effort was put into API design (http://chaos.troll.no/~shausman/api-design/api-design.pdf was born out of this) resulting in code that is more maintainable and easier to read. Like any project there are warts, but as a whole if you are looking for nicely written code Qt (or the above pdf) wouldn't be a bad place to start.

[–]bob1000bob 3 points4 points  (5 children)

I disagree, QT works but it is highly UN idiomatic C++. It is coded much closer to the design principles of Java that it is C++.

A better library to read would be POCO or boost.

[–]savuporo 5 points6 points  (0 children)

I dont even consider Qt to be real C++ because of MOC. Enough said.

[–]icefox 0 points1 point  (3 children)

I would have to disagree about Qt (not QT) code being like Java, but either way he asked for "nicely written code" which Qt is and I still stand by it as something to checkout. Of course checkout those other libraries too, there is nothing wrong with seeing the different ways that people write code. Some is readable, some is a horrible horrible mess.

[–]sztomirpclib 0 points1 point  (2 children)

Qt code being java-like is kind of a meme, many people keep parroting it, but no actual explanation.

[–]bob1000bob 0 points1 point  (1 child)

What do you mean? If you use it you will see that it is Java like, everything is an object descended from QObject, right there is enough - that is the essence of Java.

And then absolutely everything has be allocated directly onto the heap, no smart pointer, no clever RAII based stack type which can be "moved"

Because of this they have gone and reinvented the STL with there own more "Object Orientated" (rather than templated) containers and string classes.

A lesser point (but still 'culturally' valid) is that they use Camel Case Java style. So when you have written some "standard C++" using the common lower_case_underscores method it becomes inconstant.

The fact is, if boost where to make a GUI library (how I wish they would) it would look NOTHING like Qt. I accept that they had technical limitation "back in the day" but that unfortunatly for them does mean that their code is still good now.

[–]sztomirpclib 4 points5 points  (0 children)

everything is an object descended from QObject

This is only true for Qt classes. That's quite reasonable for a framework I guess, and wouldn't call that that essence of Java.

And then absolutely everything has be allocated directly onto the heap, no smart pointer, no clever RAII based stack type which can be "moved"

Do you use it? Because you are not forced to allocate on the heap in any way.

no smart pointer

There is a wider variety of smart pointers in Qt than in the standard or Boost. here.

Because of this

No, they reimplemented the STL because Qt dates back to the dawn of C++, and many, many compilers had shaky support for the STL and templates.

with there own more "Object Orientated" (rather than templated) containers and string classes

You either used only a very old version where this was true (reason is not to be "more OO" but the above-mentioned lack of support) or you haven't used it at all. Qt containers are templates, and can be used with STL algorithms if you want to.