why is C++ still being over-used?

Started by
257 comments, last by jbadams 15 years, 6 months ago
Yeah, actually writing about reality, and not something that may or may not happen in X years is so unprofessional ;)
Advertisement
Quote:Original post by Daivuk
Quote:Original post by DevFred
Quote:Original post by Daivuk
C is still the best language for begginer all the way. C is the simplest "decent" language to learn.
cout << "Hello World"

cout isn't C.


lol good point.
I meant printf of course :P


Ironic then that in your (otherwise amazing) BaboViolent 2 game, the use of printf caused a serious game bug that allows players to crash the entire server. (Hint: don't type "sayall %n" in the console!) [smile]
Quote:Original post by _swx_
Yeah, actually writing about reality, and not something that may or may not happen in X years is so unprofessional ;)


My post was raving indeed, but I spent quite some time dealing with JVMs in particular at rather low level, and having to deal with same hyped claims over and over still ticks me off.

Incredible advances have been made over the years, but biggest optimizations happened completely elsewhere ("optimize algorithms, not code").

Probably the single biggest performance improvement JVM has made was very simple. When you write string concatenation ("a" + "b" + "c" + "d"), it's now almost always done via StringBuffer. This optimization alone improved running time of many applications by a factor of 2-4 (it's byte-code optimization though performed by compiler, so projects need to be recompiled).

Second biggest optimization was in UI area, where OpenGL surfaces are now used by Swing as render buffers. Under Linux, this boosted repaint rates by anywhere from 1 to 50 times (this was run-time library optimization which again isn't related to VM), improvements are seen under other platforms as well.

But the often repeated myths regarding magic JIT continue to remain just that. The only sensible conclusion is that right now JIT optimizations matter much less than potential algorithmic ones, as above examples show.

For Java and JVM, lack of stack allocations is still a big problem. With plans to move to general purpose byte-code VM, Sun could open a lot of potential for truly scalable and performant VMs, much in the same way WebKit and SquirrelFish did recently in area of &#106avascript. When it comes to Java in particular, it's the Java's standard library that is a huge performance bottle-neck (for many different reasons, many of them related to legacy).
Quote:Original post by Antheus
For Java and JVM, lack of stack allocations is still a big problem.
Supposedly from 1.6 (IIRC), they can transform heap allocations to stack allocations automatically. I don't know how effective this is, but they're trying at least.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Normally I wouldn't even bother to post to language threads, but I'm making an exception here since this thread has gotten so much attention. Bluntly put, stating that a language is over-used for writing applications is like stating that power tools are over-used for building houses. Sure, we all have our favorite languages and our favorite features, but in the end all that matters is that the language you use works for you to get the job you're doing done. Period.

I work as a software developer dealing mainly with ASM/C/C++, but I also understand the merits of using other higher level languages when needed. I love C# for interface and tool design and even Java when it comes to easy cross-platform programming. My language of choice, however, is C++, and while it may be "easier" to do certain tasks with certain languages, sometimes those same tasks are easier for me to do with C++ simply because I have 10+yrs of experience with it rather than having to eat my company's time and money learning the syntactic nuances of another language.

For those new to programming, sure there are easier languages to start with. Admittedly, my first programming was LOGO (anyone remember the little turtle? FD 10, RT 90?), but in the end the best language to start with is the one that makes the most sense to you. You can learn the basic constructs of programming in any language, past that is just syntax. Programming is an art beyond language, so whether it's C, LISP, Java, or some custom built scripting language, the only measure for whether or not a language is correct to use is if it helps you, the programmer, get the job done the best YOU can.
---------------------------Visit my Blog at http://robwalkerdme.blogspot.com
Quote:Original post by phantom
Quote:Original post by sirGustav
I use C++ mainly since there isnt really any other language that I can find where
- raii forces you to use an aful lot of indentation
- const-declare variables
- good "visual-studio-like " IDE


So, why don't you use C# then which has all of the above?


C++ has raii, C# has IDisposable and the using-statement. The latter more or less forces you to indent your code, the former doesn't. Purely cosmetically, but I don't like it :)

About that second one...
void func() {  const int foo = bar();}

As far as I know it can't be done in C#.

I do most of my projects in C#, though, every time I go back to C++ I miss C#'s fast compilation and smart intellisense :)
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++.


I agree that Template Haskell is much more powerful, but Haskell has very serious problems with memory management (it wasnt designed for tight hardware requirements, after wall).

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.

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.

Garbage collector: see C++0x.
No reflection: I agree. Not sure if C++0x will introduce this. I hope so...
Type inference: well, there will be type deduction, which is good enough for many problems. Full type inference is beyond the scope of a statically typed language. (And, it can bite you; its not a silver bullet.)
Metaprogramming: even though it wasnt introduced intentionally, C# and Java do not even remotely have something comparable. Lisp gives C++ a run for its money here, of course.

Summarized I don't use C++ because its beautiful or anything; I use it because no other language is this widespread. has such a great range from low-level hardware access to high-level constructs, support for multiple paradigms, true generic programming support, and metaprogramming facilities. While I do like C#'s functional core, I sorely miss the power of C++ templates. Java's only interesting features are anonymous classes and runtime reflection (Java becomes limiting very quickly). Haskell and Lisp are uber-powerful, but also extremely uncommon (and tend to be very generous with memory usage). Python is too slow. OCaml is very interesting, and fast, but also a niche language. D is also interesting, but the devs dont seem to have any general direction, even though they could make use of their current position and turn D into a language designed primarily for generic & meta programming with C++'s low<->high level range (and minus the absolutely horrible template syntax).
~dv();
Quote:Original post by agi_shi
No one cares what the code looks like, no one will admire you for writing Beautiful Code.

Except the people having to maintain the code. Or more accurately, they care how easy it is to modify, test that their modifications work, and so forth. You know, how quickly they can work to create the project your customer cares about.

I forgot to mention C++'s horrendous compile times earlier. Multi-hour compile times are not at all unheard of for some C++ projects. This isn't exactly easy to modify, test, or debug.

Quote:Besides, that's what you've got Boost for - you want lambda? boost::lambda. You want run-time typing? boost::any.

Have you actually used these? No, wait, that's the wrong question. Have you actually used what these two libraries rip off?

If so, you'd realize these are very poor imitations of the real thing. Don't get me wrong, they're great libraries -- about as good as you can get for C++. And therein lies the problem.

C++0x will attempt to address these problems some. auto (static type inference). Actual lambda functions. Moving boost::bind and function into the SC++L.

Whenever the hell it actually gets supported.
A great philosopher once said: If there were a better language than C++ we would be all using it.
Quote:Original post by Feidias
A great philosopher once said: If there were a better language than C++ we would be all using it.


Given that not 'everyone' is using C++ it also can't be the "best" language out there; I mean, if it was we'd be using it for everything, right?

This topic is closed to new replies.

Advertisement