Live data from Hacker News

Has C++ jumped the shark?

johndcook.com

31–40 of 69 posts

Re: Has C++ jumped the shark?

#31

Earlier quoted context omitted.

C++ takes a very simplistic view of runtime performance, however. Generics are implemented using templates; which instantiates the code for every type you use. Naively, this preserves the performance of simply writing the same code for each type (which is what you did before templates). However, that might not be the best performing way to implement generics at runtime. (Edit: Small change to make meaning clearer)

Huh? Templates in C++ are pay-for-what-you-use; only those instantiations required by your code are generated. Note also the ability to extern templates added in C++0x, which allow you to collapse common instantiations to a single object file.

How do those features impact runtime performance?

One example of templates affecting runtime performance is poor use of the instruction cache due to code duplication in every instantiation of a template.

Re: Has C++ jumped the shark?

#32
C++ has a fundamental problem: that of being a real language that added OO features and static polymorphism in great haste; unwise decisions during the early stages of C++ cannot be unmade after their negative consequences are apparent.

There's some "good stuff" in C++1x, but of necessity, it's all additive, not subtractive. So the language gets bigger and more complicated.

I've never met an adept C++ programmer who didn't aggressively cut the language down to a subset. The sad thing is that I've met good C++ programmers - and seen good C++ libraries and frameworks - whose subsets are quite distinct; they are 'divided by a common language', like the old cliche goes.

Re: Has C++ jumped the shark?

#33
post #19
post #14

Earlier quoted context omitted.

But you can already have "simple C++", just specify for your project which parts of the language you want/don't want to use, and enforce it. This I think is a good coding practice, and for example Google also have its own C++ Style guide ( http://google-styleguide.googlecode.com/svn/trunk/cppguide.x... ). For example, you can specify that you will not use exceptions, template meta-programming, default parameters, etc…

Several years after I swore I would never work in C++ again, I agreed to do C++ in order to get a job with a company I was really interested in joining. I ended up working on a project that used C++ with lots of rules and restrictions, and it was not too bad except for lots of boilerplate. I would like to see something better come along that has some of the low-level power of C, but also supports sophisticated high-l…

Maybe try D? An­drei Alexan­dres­cu likes it, and he knows C++ really well.

Re: Has C++ jumped the shark?

#34
post #31

Earlier quoted context omitted.

Huh? Templates in C++ are pay-for-what-you-use; only those instantiations required by your code are generated. Note also the ability to extern templates added in C++0x, which allow you to collapse common instantiations to a single object file.

How do those features impact runtime performance? One example of templates affecting runtime performance is poor use of the instruction cache due to code duplication in every instantiation of a template.

If you are instantiating equivalent functions (sorting foo* vs sorting bar* ) then the linker will merge their binaries -no dupes there. If you are generating different functions (sorting foo vs foo* ) then you are asking for different functions -no dupes there either. If you want to keep everything down to one function, qsort() didn't disappear when they added std::sort() and it is pretty close to what a dynamic language sort would do under the hood.

Re: Has C++ jumped the shark?

#35

Earlier quoted context omitted.

C++ takes a very simplistic view of runtime performance, however. Generics are implemented using templates; which instantiates the code for every type you use. Naively, this preserves the performance of simply writing the same code for each type (which is what you did before templates). However, that might not be the best performing way to implement generics at runtime. (Edit: Small change to make meaning clearer)

Huh? Templates in C++ are pay-for-what-you-use; only those instantiations required by your code are generated. Note also the ability to extern templates added in C++0x, which allow you to collapse common instantiations to a single object file.

C++0B maybe?

Re: Has C++ jumped the shark?

#36
post #22

Earlier quoted context omitted.

There is bloat and there is bloat. I'm currently playing with a 200-line file that is mostly a wrapper around a subset of boost::polygon (basically it's a single-type specialization wrapped in a simpler API). With gcc 4.4.5 and -O2, this one small file takes 22 seconds (!) to compile and produces a 14MB output file. I guess that's... tolerable. But it isn't "lean" in any meaningful sense.

Try stripping debug symbols. As to compile time, the pimpl pattern is your friend here.

I don't know who your audience is. I understand that most (about 2/3) of that data is symbol information. The complaint was obviously that a 200 line file generates 8MB of symbols and takes longer to compile than the rest of the project put together. And the existence of this 200 line file is precicely a pimpl attempt to isolate the C++ brain damage as much as possible.

Your point seems to just be agreement with mine: C++ bloat is tolerable. It's still bloat.

Re: Has C++ jumped the shark?

#37
post #20

Languages are tools. Da Vinci with a mop and a bucket of mud would be a better painter than me. In fact I recently saw a video where Kelly Slater surfed a door and a coffee table as impressively as most weekend warriors surf on $700 custom shaped boards. Focus on your skill not the tools. Surfing is more about timing, fitness and knowledge of waves than it is about the board. Likewise coding is more about RAM, CPUs,…

a video where Kelly Slater surfed a door and a coffee table as impressively as most weekend warriors surf on $700 custom shaped boards. I saw a table tennis player all excited about his new carbon fiber paddle. Then one of the club champs picked up the box the new paddle had come in and, using the box as a paddle, proceeded to defeat the player with the carbon paddle.

[deleted]

Re: Has C++ jumped the shark?

#38
post #12
post #4

I've written in C++ professionally almost 12 years (17 years counting College), and in my opinion it is a shame how the language has not evolved properly. Unsolved things: - Unified C++ ABI call for making shared libraries without worrying about compiler manufacturer or version. - Massive bloat. Take a look to the Boost libraries and cry. - Poor debugging tools for templates (debugging templates it is crazy, and the…

"Massive bloat. Take a look to the Boost libraries and cry." Aside from your tears, what is the evidence that boost is bloated? Too slow? Too much source code? Too many files? I've been using Boost for nearly a decade. It does a ton of useful stuff (from template metaprogramming to fast matrix algebra), it's loosely coupled, and it's insanely fast. Given it's scope, it's the least bloated library of which I know. C++…

Try compiling boost from MacPorts, and wait an hour, and few gigabytes later... Really - it's that big!

Re: Has C++ jumped the shark?

#39
post #19
post #14

Earlier quoted context omitted.

But you can already have "simple C++", just specify for your project which parts of the language you want/don't want to use, and enforce it. This I think is a good coding practice, and for example Google also have its own C++ Style guide ( http://google-styleguide.googlecode.com/svn/trunk/cppguide.x... ). For example, you can specify that you will not use exceptions, template meta-programming, default parameters, etc…

Several years after I swore I would never work in C++ again, I agreed to do C++ in order to get a job with a company I was really interested in joining. I ended up working on a project that used C++ with lots of rules and restrictions, and it was not too bad except for lots of boilerplate. I would like to see something better come along that has some of the low-level power of C, but also supports sophisticated high-l…

> I would like to see something better come along that has some of the low-level power of C, but also supports sophisticated high-level abstractions

Objective C this very well. It adds classes and protocols. Closures can be implemented with blocks. Everything else is the same as in C.

Re: Has C++ jumped the shark?

#40

Since the browser most people are reading this in is written using C++, I'd say the answer is no.

It's still the most useful language but you do get the feeling that everytime some new paradigm is claimed for another language C++ goes "I can do that - and I will do that in a way that doesn't break C code from 1979 - however weird that makes the language"
Post reply on HN