Live data from Hacker News

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

linkedin.com

151–160 of 264 posts

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

#151
post #27

Earlier quoted context omitted.

Parallelism: yes, although OpenMP isn't nearly as accessible as e.g. Swift async closures. C++ only got proper language-native threading in C++11. for large scale programming the only sane model is a flat, cache coherent one Do google view their datacenters as a single flat cache-coherent memory space? No, they built mapreduce instead. That's the point of view I'm coming from: distributed systems engineering working…

"Parallelism: yes, although OpenMP isn't nearly as accessible as e.g. Swift async closures." I'm not familiar with them, do you have a pointer? Cilk does have powerful semantics and a very light weight syntax. "C++ only got proper language-native threading in C++11." Sure, but OpenMP and Cilk are significantly older. "Do google view their datacenters as a single flat cache-coherent memory space?" No, but I'm pretty s…

> I'm pretty sure they whish they could [view their datacenters as a single flat cache-coherent memory space]. Many HPC clusters do present a single memory image across thousands of machines.

No not really, at some point when you're dealing with PetaBytes of RAM and millions of cores, the Law of Physics kicks in, your RAM is spreading across a large physical area no matter how clever you are. If you want a flat memory space you have to guarantee an access to any memory address in less than X cycles otherwise you have a NUMA architecture[1]

While this is true that HPC clusters present a single memory image per cluster node (where one node = 8-32 processors (maybe 64)), the other nodes's memory has to be access with Message passing or other mechanisms.

You need a different programming model, MapReduce is too specific, that's why Google is trying things like their "DataFlow" platform.

[1]https://en.wikipedia.org/wiki/Non-uniform_memory_access#NUMA...

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

#152
One of the biggest users (some would say abusers) of template metaprogramming I know works on HFT software. He trades extremely long compile times for performance at runtime and finds that C++ allows him to do this and maintain a decent architecture (through what amounts to compile-time polymorphism as well as RAII).

For him, it's actually the older features of C++ that have no use. He doesn't use deep class inheritance and never touches virtual functions, for example.

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

#154
post #139

Earlier quoted context omitted.

> Because it's a C++11 header that doesn't exist in C++98. That is supposed to be a fault of C++11?

I don't understand your argument. An upstream project I use put a C++11 header in their public API's header. Now, I also have to build in C++11 language mode. If you're saying it's not the language standard's fault that CXX is slower, sure, but how or why should I differentiate between ISO C++ and g++/clang++ with libstd++/libc++?

I think what the GP was saying is: Ignore the new feature you're using from that upstream project for a minute. Did you try compiling your project with -std=c++11 before doing any other change? That is the only way you'd clearly see the difference of switching to C++11 in your project. Maybe it won't add any compilation time, it could even be faster...

And then you add the new feature and your compile time goes crazy, that's unfortunate indeed, but that's the price of not being penalized at run time with the [cool new C++11 feature the upstream project is using], you have to endure a longer compile time. But you can't blame C++11 for it, without it that feature wouldn't even exist!

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

#155

This article is not very general. Much of what it tries to convince us is not going to matter for most developers, and has the cost of suggesting modern features are not good for any developers. For example: >It is not rare to see Modern C++ applications taking 10 minutes to compile. With traditional C++, this number is counted in low seconds for a simple change. This is simply a bogus statement with respect to what…

“A Variadic Template A Day Keeps The Job Security In Play”

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

#156

Earlier quoted context omitted.

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.

I think I see what commenter meant. You have to physically be on the inside in the sense you need a direct, short connection to the network that cost ridiculous money along with HW and SW that costs ridiculous money. A prestigious position most stock traders couldn't compete with if they wanted to. Plus, you get to preempt all of them from this position without them even knowing it.

Insider trading is a term with a specific meaning, and that is not it.

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

#157
post #146

Earlier quoted context omitted.

> 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. Can you comment on the memory safety of modern C++? I am wondering if I should learn Rust or modern C++.

std::unique_ptr, move constructors, etc and you're pretty safe, but it's still not in the same league as Rust. In my opinion you should probably learn Rust unless you want to get a job writing C++ (e.g. game development).

I never quite understood why unique_ptr and move semantics are supposed to improve memory safety over new and delete. They reduce leaks, sure, since the compiler inserts free for you at a hopefully-useful place. But you still effectively have to decide when to free, and there is no protection against dangling iterators, references, or pointers. From a security point of view, use after free is far worse than leaking, since UAF can lead to remote code execution.

In fact, move semantics create a new type of hazard that wasn't in earlier versions of C++: dereference of a unique ptr after moving it.

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

#158
post #154
post #139

Earlier quoted context omitted.

I don't understand your argument. An upstream project I use put a C++11 header in their public API's header. Now, I also have to build in C++11 language mode. If you're saying it's not the language standard's fault that CXX is slower, sure, but how or why should I differentiate between ISO C++ and g++/clang++ with libstd++/libc++?

I think what the GP was saying is: Ignore the new feature you're using from that upstream project for a minute. Did you try compiling your project with -std=c++11 before doing any other change? That is the only way you'd clearly see the difference of switching to C++11 in your project. Maybe it won't add any compilation time, it could even be faster... And then you add the new feature and your compile time goes crazy…

This makes more sense, but why is it not C++11's fault if compiler writers have a hard time keeping the compile time overhead in reasonable bounds? Compiler writers actually do not enable some optimization passes or cap some passes at a certain search level because they know the algorithmic complexity would be unacceptable for most users, although the performance benefit is clear.

The planned C++ module system will most likely solve a large set of the pain points.

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

#159

I know why I don't like C++ anymore, it's just no fun.Its slow to compile, the errors are like 6 lines long full of template and class hierarchy that makes it hard to understand what exactly happened, and then of course there's the common coding shortcut of declaring everything auto. (What type is this list? I don't know, it's auto all the way down.) Then there's the whole thing about making constructors, but leaving…

My personal rules for using auto. Only use it iff: 1. the actual type is clearly visible on the right hand side. auto f = make_widget(); // it's a widget auto i = 123; // it's an int auto x = vec3(1.0, 0.0, 0.0); // it's a vector 2. the actual type doesn't really matter so much or is complicated to type out. auto it = vec.begin(); // it's an iterator auto it = // some template expression 3. the actual type is not kno…

These are good rules – as in liquor advertisements, it’s advisable to always accompany a declaration that uses `auto` with a rejoinder in the comments to Please Enjoy Responsibly

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

#160
post #4

Earlier quoted context omitted.

According to the writer's LinkedIn profile, he comes from the world of High Frequency Trading. That's an area where performance is so important, that it might make sense to design your own hardware. And you certainly don't want to distribute it to anyone... I do agree with the writer that with each release, C++ has become more and more complicated, seriously hurting the maintainability of C++ code.

I also agree that c++ is getting more and more complex over time. However if you build things from scratch and you cherry pick your language features, C++ can be quite pleasant.

It may be pleasant for you, but not so pleasant for the next developer who needs to maintain your code. Perhaps he likes picking different cherries than yours...
Post reply on HN