Live data from Hacker News

Why I don't spend time with Modern C++ anymore

linkedin.com

121–130 of 264 posts

Re: Why I don't spend time with Modern C++ anymore

#121
post #57

In my experience, the opposite of what the author claims is true: modern C++ leads to code that's easier to understand, performs better and is easier to maintain. As an example, replacing boost::bind with lambdas allowed the compiler to inline functor calls and avoided virtual function calls in a large code base I've been working with, improving performance. Move semantics also boosted performance. Designing APIs wit…

Fully agree with what you're saying. Just a nitpick about bind (which I'm sure you're aware of, just for the sake of others). The return type of {boost,std}::bind is unspecified (it's basically just a "callable"). This means that bind doesn't have to do type erasure. On the other hand, {boost,std}::function has to do type erasure, which can boil down to a virtual function call. But that's orthogonal to where the call…

It's not type erasure per se, but it's somewhat functionally equivalent. When you pass a function pointer (or pointer to member function) to bind(), it has to store that pointer in a member variable and perform an indirect call in operator(). In theory this is something that a compiler should be able to optimize away, but in practice they very rarely actually do, so using bind() as the argument for a STL algorithm typically does not result in the whole thing getting inlined out of existence. Lambdas, OTOH, are super easy to inline out of existence and compilers actually do so most of the time.

Re: Why I don't spend time with Modern C++ anymore

#122
post #115

> Today the "Modern Technologist" has to rely on a new set of languages: Verilog, VHDL That was a complete surprise ending! :) I like surprise endings, and he makes a lot of good points, whether or not I agree with them. But, I totally wasn't expecting "I'm done with C++ because: hardware." I was expecting because web or because awesome new high performance functional scripting language . A lot of what he's talking a…

FPGA programming and C++ aren't exactly mutually exclusive, right?

I would say yes: you can't really run C++ on an FPGA. There are all sorts of tools which promise this (SystemC etc), but it requires you to stick to a careful subset of language constructs. You don't have a heap, for example.

Re: Why I don't spend time with Modern C++ anymore

#123
post #92

HFT is a pretty limited and extreme application case. From what I understand - everything is not enough for HFT - network cards, kernel drivers, cables, etc. You have milliseconds (edit: nanoseconds !) to receive, process and push your orders before someone else does it and gets the prize. It's an arms race between technologists for the purpose of making a small number of people rich. I doubt that these requirements…

HFT = Insider trading + Algorithm trading

No, it's just fast algorithmic trading, aka latency arbitrage. It's still quite risky and you don't have any special information anyone else doesn't have.

Re: Why I don't spend time with Modern C++ anymore

#124
post #57

In my experience, the opposite of what the author claims is true: modern C++ leads to code that's easier to understand, performs better and is easier to maintain. As an example, replacing boost::bind with lambdas allowed the compiler to inline functor calls and avoided virtual function calls in a large code base I've been working with, improving performance. Move semantics also boosted performance. Designing APIs wit…

> As an example, replacing boost::bind with lambdas allowed the compiler to inline functor calls and avoided virtual function calls in a large code base I've been working with, improving performance.

And not just runtime performance; IME replacing bind() with lambdas typically significantly improves build time performance significantly. C++03 with C++11 features emulated via library trickery has terrible compile times compared to having the same features built in to the compiler.

Re: Why I don't spend time with Modern C++ anymore

#125
post #115

> Today the "Modern Technologist" has to rely on a new set of languages: Verilog, VHDL That was a complete surprise ending! :) I like surprise endings, and he makes a lot of good points, whether or not I agree with them. But, I totally wasn't expecting "I'm done with C++ because: hardware." I was expecting because web or because awesome new high performance functional scripting language . A lot of what he's talking a…

"FPGA programming and C++ aren't exactly mutually exclusive, right?"

Currently they are exclusive. You can theoretically 'compile' some subset of C++ to an FPGA, but you very likely do not want to.

Of course C++ makes it a decent language to talk with a custom circuit in FPGA, but that's orthogonal.

edit: clarify

Re: Why I don't spend time with Modern C++ anymore

#126
The problem with modern C++ is that it wants to be everything. Now this behemoth is crushing under its own weight.

People who are not forced to use C++ should consider other languages which are way cleaner and even more performant. Code written in Ada and Nim for instance is much easier to maintain.

Re: Why I don't spend time with Modern C++ anymore

#127
post #105
post #93

Earlier quoted context omitted.

Well, we also have to thank C for the set back in optimizing compilers. Fran Allen. In Coders at Work (pp. 501-502): --- Begin Quote --- -Seibel-: When do you think was the last time that you programmed? -Allen-: Oh, it was quite a while ago. I kind of stopped when C came out. That was a big blow. We were making so much good progress on optimizations and transformations. We were getting rid of just one nice problem a…

That's some serious sour grapes by Allen. Her assertion that Fortran and COBOL are higher level than C is .. difficult to support given the reliance of both languages on GOTO. The assertion that compilers weren't taught any more is just silly.

Fortran is certainly higher level than C, given lack of aliasing and no decay of arrays into pointers.

Re: Why I don't spend time with Modern C++ anymore

#128
I agree with the author; I still long for the not-overly-complicated C++ back in the 00s I could write super-fast 3D rendering engine without much bloat. I find it very appalling when C++ went from a poster child of imperative programming to implementing monads in its libraries (mind you, monads are used to "simulate" imperative programming in functional programming). Something went wrong there...

Re: Why I don't spend time with Modern C++ anymore

#129

Earlier quoted context omitted.

(re 10 minute compile times) > This is simply a bogus statement I work on a C++ project and believe me, 10 minute compile times would be great :)

have you tried ccache? the 5x to 10x improvement isn't a bogus statement in my experience

ccache eliminates spurious rebuilds, but doesn't make compilation of things which actually need to be recompiled any faster. It's basically just a workaround for that Make only uses file mtimes and not the contents to decide what needs to be built.

Re: Why I don't spend time with Modern C++ anymore

#130
post #62

Earlier quoted context omitted.

C++noob here, but: Given that the members in your example are no pointers but actual substructures within your data structure, wouldn't that result in an infinite data structure? Therefore it sewms quite logical to me it's not allowed. Disallowing cyclical dependencies via pointer would make no sense though.

Right. C++ objects are values, not references to values like in almost all other languages. So C++ needs to know the sizes of everything to construct them. If you tried to write out the mathematical series describing the ultimate size you would need to allocate for A or B, you would end up with a value approaching infinity.

This is probably my favorite thing about C++. Values are so much easier to reason about than references.
Post reply on HN