r/cpp • • Aug 25 '21

Experience C++ developers: do you enjoy using C++ (even for personal/hobby projects?)

Do you actually enjoy using C++, or do you only use it for work, or purely for performance? This question is aimed at people with years of experience, who've worked on large projects in C++. I see people who dislike the language, but use it purely for performance reasons. This sort of discourages me from learning it. I don't want programming to feel like work.

204 Upvotes

327 comments sorted by

View all comments

Show parent comments

43

u/braxtons12 Aug 25 '21

That's not what they mean. Classes are absolutely fine when what you need actually is a class. Java programmers (and to a somewhat lesser extent C#) tend to make EVERYTHING a fully fledged class or interface (or a pair of both) so you end up with things like public interface AbstractThingyFactorySingletonFactory and public class ThingyFactorySingletonFactory when all you really needed was auto get_thingy_factory() -> ThingyFactory or even better yet just auto make_thingy() -> Thingy

4

u/pjmlp Aug 26 '21

Have a look at MFC, Qt, VCL, wxWidgets, all created before 1996.

0

u/braxtons12 Aug 26 '21

Care to explain how that is relevant to my comment?

2

u/pjmlp Aug 26 '21

Bittering on Java and C# programmers for what was a C++ widely adopted pattern before those languages were invented.

People complain about Java and C# being too OOP, when it was C++ that brought OOP to the masses.

1

u/braxtons12 Aug 26 '21

I've never worked with code working in MFC, VCL, or WxWidgets before, so I can't comment for what is common when using those frameworks/toolkits.

BUT I've never seen Qt-related code, or honestly even any C++ at all for that matter actually, that looks remotely like the java/c# example I gave. I have however seen and/or been encouraged to write plenty of Java and/or C# that looks exactly like the example, or worse.

Also, like I and others have said, there is nothing inherently wrong with OOP. I won't even complain about factory singletons. We're not complaining about OOP, we're complaining about OOP that is unnecessarily excessive,like when you have ridiculous things like the example, of a factory that implement a factory interface to create more factories that create a thing.

0

u/pjmlp Aug 26 '21

Exactly the kind of stuff described in Gang of Four book with examples in C++.

1

u/braxtons12 Aug 26 '21

Yeah you're completely missing the point or trolling, because I guarantee you can't show me an example from the GoF book that looks remotely like the example I gave or am discussing.

Again, no one is saying OOP is bad, they're saying OOP to the extreme is bad.

1

u/pjmlp Aug 26 '21

Well, I don't have the book around me, but factory factory is certainly there.

Also, enjoy reading

https://docs.microsoft.com/en-us/cpp/mfc/hierarchy-chart?view=msvc-160

https://docs.microsoft.com/en-us/cpp/atl/atl-class-overview?view=msvc-160

1

u/braxtons12 Aug 26 '21

I have the book, it's not.

And, so typical UI framework class hierarchies? Yet again, there is a difference between OOP where reasonable and OOP in excess or taken to the extreme. Not sure why you don't understand that.

1

u/pjmlp Aug 27 '21

Whatever dude, apparently you don't get that Java and C# enterprise code only adopted what C++ enterprise devs where doing before they came into the scene.

I can also refer to CORBA, DCOM, MTS, Booch design methodology, and a couple of other C++ stuff pre-1996, but still won't be excessive enough to fit your view of the world, because only Java and C# are to blame.

Over and out.

1

u/Ameisen vemips, avr, rendering, systems Aug 26 '21

auto make_thingy() -> Thingy

I don't think I've ever going to like that syntax.

4

u/braxtons12 Aug 26 '21

I would prefer if we didn't have to put the auto out front and could just have the trailing return, but 🤷‍♂️

Personally I find trailing return type to be faster to read, because more often than not I care more about the name and arguments than what the exact return type is.