why is C++ still being over-used?

Started by
257 comments, last by jbadams 15 years, 6 months ago
What net testosterone? I see that stuff I wrote about all the time. It's nice how people on the internet always interpret the writings of others in an overly aggressive way.

Also, you grouped my comment about someone being some poster being ignorant with the rest of them. Did you read the post that was replying too? It was full of misinformation presented as fact by someone who didn't have a clue. He was either trying to bait people, or has been horribly misguided. There is no reason to spread all that misinformation.

You don't agree with my 'pros' assessment? Just recently I was going to try a free MMORPG by acclaim that was advertising on my board. I was halfway through downloading it when I hit the forum and it turns out for it to run, you have to disable UAC, so it irresponsibly write files all over the place, instead of in my user folder. Come on guys, give me a break. We've had a proper user folder to save this stuff for almost a decade and a half now.

So few games get the GAMES FOR WINDOWS seal because they can't follow the simple guidelines from MS which deal with having the app behave in certain ways, like supporting Alt-Tab instead of lazily disabling it, or saving in the proper folders.

I do believe that C++ gives too much power to too many people who are not smart enough to use it properly. Too many are shooting themselves in the foot, and it shouldn't be that way. If you have to be a complete expert in several areas to write both fast and safe code that won't hose your system, it's probably not a good mainstream language for every random person to be using.

The last decade has had an epidemic of poorly written software by people who meant well, but wrote bad code in a complicated language. The compiler let it fly because it assumed the person knew what he was doing.

---

It's often hard to have objective discussions about certain things, because there is always a segment of people who are way too attached to it, and feel the need to 'rescue' it. Heaven forbid that someone should try to objectively point out a flaw in something that they have put on a pedestal.
Advertisement
Quote:Original post by Daaark
Heaven forbid that someone should try to objectively point out a flaw in something that they have put on a pedestal.

If you had done so objectively I wouldn't have complained.

PS - Thanks for the vote of "confidence". Very mature.
Quote:
Quote:All user defined objects having type pointers that mightn't be needed, thus wasting memory.

C# has structs which are value types.

Not all the items on my list related to all modern programming languages. Here I was referring to Java, although that's not really such a modern language anymore. Of course Java also has many other ways to waste heap memory.
I probably should've listed the languages I was referring to beside the points, except I'd was scared I'd make mistakes :)




Quote:The most efficient JIT theoretically is slower than the most efficient fully-precompiled code.
I should have qualified this by saying that if the important loops in your code are larger than the code cache this may not be true. But with modern caches in PCs it should be true, as I'm pretty sure that cache is growing faster than the size of the important code that's taking up 90% of CPU cycles. Maybe you'll miss L1 a few more times, but I'd think JIT'd have problems staying in L1 also.

For the int foo<int>(int x) { .... } specialization there is an optimal solution for the given architecture, regardless of where in the program it's called, right? (I guess it's not for some exceptional cases). Theoretically a C++ compiler isn't prevented from finding the optimal solution. A JIT might also find the best solution, but it has to also perform code generation during runtime, hence it has a theoretically worse best case. (This is also ignoring compile-time inlining, and the fact that a JIT has far less time to optimize code).

I'm not sure if compliant C++ is allowed to do SMC, where it could for example write variables into for-loop machine-code as immediates - I guess A JIT could do this. But if C++ is allowed to do so then theoretically the best C++ compiler won't be any slower for these circumstances either.




As for array bounds checking, my primary concern isn't the cycles it takes to compare the size with the index, it's the memory used in storing the size. I've used deep binary trees where nodes have a node* child[2] member. With bounds checking you'd be wasting 1 integer per node right? Which in the case of my AVL tree demo (when I add an int to node) increases my memory usage by around 15%. Granted my AVL tree demo was only used to prove a point and isn't the best real-world solution, but you get the idea.

Also, small things like this will build up if we accept them. How about integer overflow checks? Checking that unallocated memory isn't read? That delete() is always called on valid pointers? Each of these might have only a small performance hit, but they'll all add up. And the above only help fallible coders :)
I'm all for testing my code with these options on, but on principle I think releases shouldn't be expected to do these.




Finally I can say that IMO the buggiest apps I see these days are usually done in modern languages - but perhaps this is because poorer programmers prefer them. This is also just a gut feeling.
Quote:Original post by yacwroy
Quote:The most efficient JIT theoretically is slower than the most efficient fully-precompiled code.
I should have qualified this by saying that if the important loops in your code are larger than the code cache this may not be true. But with modern caches in PCs it should be true, as I'm pretty sure that cache is growing faster than the size of the important code that's taking up 90% of CPU cycles. Maybe you'll miss L1 a few more times, but I'd think JIT'd have problems staying in L1 also.
That was completely nonsensical. Try again. And remember that the basic mode of operation for a JIT is to translate the target function to machine code, and then patch stub calls to the JIT to direct call the JITted code. It's a one time occurrence that removes the JIT engine from the picture after it's done. (Yes, re-optimization based on observed performance is conceivable. No, we don't actually have the technology yet.)
Quote:Finally I can say that IMO the buggiest apps I see these days are usually done in modern languages - but perhaps this is because poorer programmers prefer them. This is also just a gut feeling.
I believe this is because:
1) The newer languages are more productive and therefore many more applications are based on them
2) The newer languages enable far more of your average morons to build software.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Its a pity this turned into a C++ vs .NET debate (big surprise, huh?). Even worse that people are actually defending C++ with the argument of performance, something no starting programmer should really care much about. Sure, they should make things perform decent, but can't teach someone to optimize something when they hardly know what is going on.

Higher level languages, like C#, are fast. Sure, it can be slower. It also can be faster. Depends on how optimal the code you write is. When it comes to language debates, everyone seems to forget that getting a program in the least amount of time is often the most important aspect. No one really cares if your program runs slower, especially if it isn't even needed to run fast. Of course there are places where better performance is needed, and better performance is always preferred, but who gives a shit if your game runs on the target audience's computer at 500 FPS instead of a wimpy 300 FPS?

So what is better? Neither. Stop trying to dig a damn whole with a spoon and eat your soup with a shovel. And definitely stop trying to use the shovel for everything.

In case anyone forgot, which it seems most did by page 2, the topic was about newbies being influenced to use / supported with using C++ as their first language.

Quote:2) The newer languages enable far more of your average morons to build software.


Planet Source Code's VB6 section supports this completely... sadly enough.
NetGore - Open source multiplayer RPG engine
Incidentally, no one has yet mentioned that although both C++ and C# can be garbage collected, the performance characteristics of the two are drastically different, as are the perf characteristics of the allocators involved. As a result, depending on what you're doing and how you do it, C# code can be much, much faster -- or slower! -- than comparable C++ code.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Promit
Quote:Original post by yacwroy
Quote:The most efficient JIT theoretically is slower than the most efficient fully-precompiled code.
I should have qualified this by saying that if the important loops in your code are larger than the code cache this may not be true. But with modern caches in PCs it should be true, as I'm pretty sure that cache is growing faster than the size of the important code that's taking up 90% of CPU cycles. Maybe you'll miss L1 a few more times, but I'd think JIT'd have problems staying in L1 also.
That was completely nonsensical. Try again.


Ok it's quite misleading sorry. JITs are pretty unlikely to dispose of and repeatedly regenerate functions.

I was just thinking in the purely abstract theoretical sense that a JIT _could_ technically save you code space by only generating code when it's needed and disposing of it afterwards, thus saving space if you're that constrained. I doubt this would be done.
But it was a pretty poor explanation since it didn't make much sense outside the above context.

edit: posted too early.
Whats wrong with using boost::shared_ptr<>, boost::array<>, boost::shared_array<>.

The only grip I have with C++ is that the arrays don't have knowledge of their own size/length/count, as where C# does. Since there is really no way of getting the size of an array pointer. But you can on normal arrays by using sizeof(array) / sizeof(unsigned) etc.

C++0x is adding a ton of new useful features into C++. Like right now GCC's next main version 4.4.0 adds strongly typed enums just like C# has except its enum class Foo : unsigned int, etc. There is varadic templates, soon to be partial support of a GC which is displayed on the C++0x status of GCC. Actually, In my honest opinion and this is just an opinion cause I don't count as everyone. GCC's compiler is far better than MSVC's. I've used both and rather use GCC.

The other grip I have for C++ is that and I've ran into the problem. When a header has a global define like for clamp() in devIL for example. My vector2,3,4 class has a function called clamp(). And if I don't do #undef clamp before including my Vector headers, well at least on MSVC it doesn't give you no details of that happening. It has no scope of it. Which should be fixed in my opinion. I haven't tested it in GCC yet. Also had this same annoying problem with min/max of win32 which probably everyone ran into and go tired of doing #define NOMINMAX etc. And the header guards and the class Foo; crap also.

And until mono has better support for C# on all systems. I won't touch C# until then. There is no point.
Quote:Original post by dv
Well, I managed to write a fully generic A* implementation in C++. The only link to the outside world are C++ concepts, nothing more. Its awesome since code reuse is much easier and has zero runtime penalties. To me, generic programming is one of the true strengths of C++.

Amen to that.
I think the rest of C++ lags long behind modern languages, but its templates make possible generic programming without run-time compromise, which is a killer feature.

Quote:
C# allows no true generic programming, which is a BIG letdown for me. Using interfaces instead of concepts is not good since an interface is a much stronger coupling, while C++ concepts are essentially structural types resolved at compile-time. For example, I can just require that a type shall have an x() getter and an y() getter as well as a defined + operator. In C#, I MUST use a specific interface, since the interface is a nominative type, not a structural one.

Have you heard about F#? It has static type constraints allowing the kind of constraints you describe.

Quote:
No lambda functions: true, I miss them often. Phoenix, BLL are helpful, but the real thing needs to be implemented in the language directly. Which happened already in C++0x.

F# has that too (obviously).

Quote:
OCaml is very interesting, and fast, but also a niche language.

Then you should love F#. Basically it's OCaml integrated with .NET. It has Microsoft behind it, which means it may grow out of the functional programing niche.

If you try F#, be sure to try it in combination with Visual Studio. It's just amazing to see errors in your code as you type it, before you even try to compile it.
-- Top10 Racing Simulation needs more developers!http://www.top10-racing.org
I still don't get the whole "C++ is too hard!" thing. Maybe it's just me but I never found it difficult to learn to use. I certainly don't find it 'cumbersome' as I saw someone say earlier. I'll be honest and say that I don't have a lot of experience with other languages. On one hand that means I don't have much to compare with in terms of how hard it is to learn. But on the other hand people are always saying C++ is easiest when you know other languages well first. I knew... not much at all about VB6 when I started C++ and I found it great to use. It took me a little bit to get accustomed to little things like semicolons everywhere and putting a set of brackets after an 'if' but that just becomes habit pretty quickly. If I try to use VB6 I find myself sticking semicolons at the end of every line!

cheers,
metal

This topic is closed to new replies.

Advertisement