Skip to main content
GameDev.net gamedev.net
🔒 Locked

OMG C++ sucks !

Started by RedDrake Sep 20, 2010 at 7:38 PM 49 replies 17.8k views
Original Post
RedDrake
RedDrake
OK, I haven't really touched c++ for the last few years on anything more serious than a library compile, mostly because I switched over to C# for my projects and my last job wasn't programming.
So the idea I had a few weeks ago was to start a opensource project that would provide a odata interface on top of a NoSQL database MongoDB. The Entity model seems a perfect fit for Document database in functionality.
I chose C++ because MongoDB API for C++ is native (project is written in c++) while C# ones (multiple implementations) weren't very stable last time I tried them and I didn't want to go trough the ASP.NET because FastCGI seemed faster/more portable. Plus I liked the idea of using boost spirit for writing query parsers and using templates, fastcgi and c++ in general would probably grant performance advantages.

So I created a empty project, added a precompiled header included the external libraries (boost spirit/pointer/filesystem/etc., stl, pugixml, mongo api) and OMFG it took forever to compile, I'm too lazy to actually measure, but it's still measured in seconds :), for a empty project, and the precompiled header took even longer to compile. But that's irrelevant compared to the suck of the code completion, and VS kept eating more and more ram, until it outgrew a Firefox 2 process on a bad day. I have AMD5050e (x2) and 2gig of DDR2, so the PC is not really that bad (it's far from the top PC but still compared to the crap certain people are using). VS is 2010 (the "new 6") express. Basically intellisense is so slow it's beyond useless. Then I got reminded of the idiotic C/C++ include system, no modules that is. I never forgot what I had to do but actually doing it after coding in C# for the last few years is painful at least. And the preprocessor crap like include guards - bleeding my eyes ! And don't you just love to predefine your classes all the time... Oh and missing the LINQ all the time shouldn't even be mentioned, boost lambda doesn't even come close in elegance.

So I'm going back to C# and .NET API's for Mongo. I might even reuse .NET oData/CSDL implementation components if I can, I need to look in to it. I'll use Mono to take care of the portability issue.

Anyway this rant has no significant point, other than to share my rude awakening regarding the actual usability of C++ compared to C# and potentially start a flame with someone who hasn't moved on, mostly cause I'm bored :).
More importantly I think it's funny how two years ago I would have swore that the cosmetic stuff in C# isn't worth it, how tools aren't that important, how the template meta programing is superior to reflection and a bunch of other arguments I wouldn't even dream of making right now. Thumbs up for C# and Microsoft !
Antheus
Antheus
Yea... C++ isn't C#...

Quote:
my rude awakening regarding the actual usability of C++ compared to C#

You might want to talk to Rubysts or Pythonistas regarding usability of C#.

At least with MongoDB you'll be web scale regardless of language.
Zipster
Zipster
Quote:
Original post by RedDrake
Anyway this rant has no significant point, other than to share my rude awakening regarding the actual usability of C++ compared to C# and potentially start a flame with someone who hasn't moved on, mostly cause I'm bored :)

So you openly admit you might start a flame war should the opportunity arise (which it undoubtedly will)...

ITBL.

But yes, if you think C# is usable, try Python. In another two years you might just be saying the same things about C# as you are about C++ :)
RedDrake
RedDrake
Nah, I use python as well (longer than C# in fact), but I just find static typing really helpful in complex scenarios/building the architecture and not just the functionality. IDK is this due to the habit, but static typing helps me break down the complexity in to loosely coupled peaces and formalize/abstract concepts. (my) Python mindset is more getting stuff done right now, with off the bat approaches, fix as you go. Which is good until I get stuck and/or need to rewind :).

And the tools (IDE/Debugger) are better.
Luckless
Luckless
Going from playing with Python in interactive mode, C++ is truly painful when it comes to compile times. (A page or two of code for a simple OGL examples needs about 5-10 seconds from the time I hit compile/run till I see pretty pictures,...)

Do you go get yourself a sandwich when doing a total compile on a large project or something?
Old Username: Talroth
If your signature on a web forum takes up more space than your average post, then you are doing things wrong.
Steve132
Steve132
Although there are some valid reasons C++ sucks, 65% of your complaints (forever to compile, precompiled headers sucking, code completion bad, ide using ram, intellisense being slow)

are actually about a particular implementation of C++ and its associated IDE as opposed to legitimate complaints about the language standard itself. I assure you that microsoft does NOT have a monopoly on C++ compilers or IDEs in the real-world.
RedDrake
RedDrake
I would say that the poor (dated) design of the language prevents them from implementing anything on the level of C# quality.
I've used GCC and Eclipse and Netbeans before, I remember thinking they were slow, code completion sucked even worse, in the days when I was using VC++ as a reference for fast/good. Maybe that changed ?
DaWanderer
DaWanderer
I do miss some of the template meta-programming from C++, but dear lord does it take so much less code to express the same thing (for all practical purposes) in C#. Every time I have to do something non-trivial in C++, I feel like I'm writing the compiler a damn novel and often getting one in return (see template error hell).
MaulingMonkey
MaulingMonkey
Quote:
Original post by Steve132
Although there are some valid reasons C++ sucks, 65% of your complaints (forever to compile, precompiled headers sucking, code completion bad, ide using ram, intellisense being slow)

are actually about a particular implementation of C++ and its associated IDE as opposed to legitimate complaints about the language standard itself. I assure you that microsoft does NOT have a monopoly on C++ compilers or IDEs in the real-world.

Language design can impact all these elements though. Choosing another C++ compiler isn't going to magically speed up your compile times: They're shitty in GCC and other compilers too.

Consider that the same IDE (Visual Studio) on a newer language (C#) manages to kick it's own ass in many of the categories mentioned (Compile times, intellisense). While these are obviously heavily affected by the implementation (e.g. VAX intellisense can kick visual studio's ass), to say the language in question plays no role in these factors (if only by affecting how easy/hard it is to implement correctly and efficiently) would be absurd. As such, I'd consider them to be quite legitimate complaints about the language standard itself, even if they are also complaints about the implementations. Shared blame, as it were.
Extrarius
Extrarius
Quote:
Original post by MaulingMonkey
Quote:
Original post by Steve132
Although there are some valid reasons C++ sucks, 65% of your complaints (forever to compile, precompiled headers sucking, code completion bad, ide using ram, intellisense being slow)

are actually about a particular implementation of C++ and its associated IDE as opposed to legitimate complaints about the language standard itself. I assure you that microsoft does NOT have a monopoly on C++ compilers or IDEs in the real-world.

Language design can impact all these elements though. Choosing another C++ compiler isn't going to magically speed up your compile times: They're shitty in GCC and other compilers too.

Consider that the same IDE (Visual Studio) on a newer language (C#) manages to kick it's own ass in many of the categories mentioned (Compile times, intellisense).[...]
See clang, which offers far faster compile times than GCC and (theoretically) a simple way to do quality intellisense for C++. While C++ may not be compile-time- and parser- friendly, there is still significant room for improvement in the tools.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Zipster
Zipster
Quote:
Original post by Konfusius
Quote:
Original post by Zipster
ITBL.


Ban.

/facepalm

For some reason my brain just really, really likes seeing 'T' and 'B' in that order...
Wan
Wan
Make sure you're using real butter when compiling. There's no substitute.
SeaBourne
SeaBourne
Why don't you use forward declaration and not use precompiled headers? I never used precompiled headers and I'm able to compile 200 source files in my project and doesn't take more than about 2 minutes to compile. Of course, I do have a i7 processor and using multiprocess compiling. I'm not sure if Visual Studio supports that, I think I had read that Visual Studio 2010 supports it but I could be wrong.

You should only include headers you need and don't use those one headers to include all stuff. You should only use those in the source file.
ApochPiQ
ApochPiQ
You know, I recognize that this is the Lounge and all, but seriously, knock it off with the "OK" posts. It was funny eight years ago in threads that made no sense, but in threads that actually have a point, it's just rude and annoying.


On topic: I hate C++ with a passion, which is why I'm making a better alternative. So far it's promising... but then again, I'm fairly biased [smile]
SimonForsman
SimonForsman
Quote:
Original post by Talroth
Going from playing with Python in interactive mode, C++ is truly painful when it comes to compile times. (A page or two of code for a simple OGL examples needs about 5-10 seconds from the time I hit compile/run till I see pretty pictures,...)

Do you go get yourself a sandwich when doing a total compile on a large project or something?


Its a feature, why do you think professionals all use C++.

http://xkcd.com/303/

:)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Hodgman
Hodgman
Quote:
Original post by ApochPiQ
knock it off with the "OK" posts in threads that actually have a point
Quote:
Original post by RedDrake
Anyway this rant has no significant point, other than to start a flame cause I'm bored
Ok.
Quote:
Original post by Talroth
Do you go get yourself a sandwich when doing a total compile on a large project or something?
I usually only have to do a total compile if the IDE/compiler screws something up, or if I've just joined a project half-way through, or if I'm a build-machine (wait, what) in which case it doesn't matter.
...but yes, in those instances I go make a coffee ;)
TheBuzzSaw
TheBuzzSaw
C++ would certainly benefit from improved syntax and a faster compiler, but the many attempts at "fixing" or "improving" the language tend to go the wrong way.

First off, I do not want a virtual machine between my program and the hardware. VMs are fine for many everyday things. General purpose business applications are fine running on a VM, but when it comes to real-time application development (primarily game development), a VM is simply not acceptable. I do not want a garbage collector running whenever it wants to; I'll manage my own memory, thank you very much. I'll take care of the low level optimizations. I don't want a VM rewiring my code on the fly. I just don't want a VM at all!

I would absolutely love it if C++ eventually adopted an elegant import system. I totally agree that #ifndef guard blocks are quite obnoxious, but considering that my IDE creates the two files and the guard block for me, I really don't care that much. It would be nice if there was a native C++ thread system, but I'll get by using OS-specific APIs.

There are simply too many harsh tradeoffs. C# adds a VM and locks me into one OS. Java adds a VM and performs poorly. C++ is a bit harder to code in, but I have much more granular control. Again, that control is unimportant when writing a business app, but I demand that control when dealing primarily with graphics.
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
ApochPiQ
ApochPiQ
Part of the goal of Epoch is to remain execution-environment agnostic; the language spec itself doesn't require a VM to underlie the running code (it just so happens that writing a compiler against a VM is far more efficient for bootstrapping a language than compiling down onto the bare metal). In fact one of my big goals with the project is to provide a highly controllable garbage collector (which can even be totally turned off should you so choose), rich support for bit-level twiddling and other stuff that generally goes into C/C++ code, and a method for modeling direct hardware interaction. You can think of it like a systems language with modern features.

Of course one of the big steps to gaining major acceptance will be to target an existing hardware architecture directly, probably through cross-compilation to something that already has a good machine code optimizer.
Luctus
Luctus
Quote:
Original post by Zipster
But yes, if you think C# is usable, try Python. In another two years you might just be saying the same things about C# as you are about C++ :)
Then after that, try a functional language for two years. [wink]

Quote:

First off, I do not want a compiler between my program and the execution. Compilers are fine for many everyday things. General purpose business applications are fine running compiled code, but when it comes to real-time application development (primarily game development), a compiler is simply not acceptable. I do not want a compiler generating operations how it wants to; I'll manage my own registers, thank you very much. I'll take care of the low level optimizations. I don't want a compiler rewiring my instructions before they're run. I just don't want a compiler at all!
Heh, is this what it would have looked like thirty years ago? [smile]

Quote:
Original post by ApochPiQ
Of course one of the big steps to gaining major acceptance will be to target an existing hardware architecture directly, probably through cross-compilation to something that already has a good machine code optimizer.
LLVM?
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.