Live data from Hacker News

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

linkedin.com

161–170 of 264 posts

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

#161

Earlier quoted context omitted.

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 ty…

Note that I'm not advocating bind over lambda. I'm saying that one shouldn't expect a boost in performance when switching from std::bind to lambda. Switching from std::function to a templatized "Callable" could give a boost in performance, but like I said, that's orthogonal to how the callable was created.

There really is quite a difference between what std::bind returns and a type-erasing class like std::function. For the latter, the type erasure may result in a virtual call that the optimizer has a hard time seeing through.

In practice, compilers are pretty good at optimizing bind. Here are some examples where lambda and bind generate identical code: https://godbolt.org/g/dQCSeG

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

#162

Earlier quoted context omitted.

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.

This argument always feels like "It's not a Pyramid Scheme! It's a Triangle Opportunity!"

People use the term not because it is an exact fit, but because it is the closest match we have and the intention is largely the same.

HFT being a lot about using computers to gain tiny information advantages (racing the speed of light between exchanges for example) to make perfectly safe arbitrages millions of times a day and effectively skim off of the top of the market.

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

#163

Earlier quoted context omitted.

Swift solves the "auto" issue pretty nicely - with the help of the IDE: let x = someFunction() Alt-click on x and it shows the type. Otherwise, as you say, the code becomes very confusing and I abstain from auto except in cases where the type is clearly obvious.

Visual Studio shows the type of auto on hover.

… also one of the forthcoming Clang projects is a static-analysis tool (á la `clang-format`) for replacing any `auto` decls with the actual typename, so you can write lazy code without appearing unscrupulous at code reviews

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

#164

Earlier quoted context omitted.

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

This argument always feels like "It's not a Pyramid Scheme! It's a Triangle Opportunity!" People use the term not because it is an exact fit, but because it is the closest match we have and the intention is largely the same. HFT being a lot about using computers to gain tiny information advantages (racing the speed of light between exchanges for example) to make perfectly safe arbitrages millions of times a day and e…

Exactly my intent. Well-worded. I'm not sure quite how to describe it how average person would understand. So, insider trading is one option to approximate it. Pyramid Scheme seems like another one in the rip-off aspect but doesn't fix the specifics as well. The traits to categorize are it's rigged, parasitic on others, requires enormous investment, and requires physical proximity that's fairly exclusive.

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

#165

Earlier quoted context omitted.

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.

Getting an information ahead of the rest of the crowd sort of fits under this specific meaning.

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

#166
post #105

Earlier quoted context omitted.

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.

Here's an experienced C programmer and fan telling you a list of ways Fortran is higher-level and superior to C for numeric programming: http://www.ibiblio.org/pub/languages/fortran/ch1-2.html

Most everything here is subjective, inaccurate, or outdated by C99, save Fortran's multi-dimensional array handling which is legitimately superior to C despite partial reconciliation by VLAs.

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

#167
post #146

Earlier quoted context omitted.

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,…

They do help somewhat by making ownership more explicit, i.e. they are hints that the programmer can use to do the kind of analysis that rust would do automatically.

Dereferencing a moved-from unique_ptr is UB, but many compilers do abort in their hardened modes.

edit: spelling

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

#168

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…

shrugs I still like to code in C++. Beats having to use JS ;)

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

#169
post #146

Earlier quoted context omitted.

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,…

> I never quite understood why unique_ptr and move semantics...

It's not those types, in particular, it's because C++11 allows you move your ownership model into the type system. And then, and this might sound familiar, writing code cognizant and explicit in its ownership semantics leads to safer, cleaner code.

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

#170

Earlier quoted context omitted.

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

This argument always feels like "It's not a Pyramid Scheme! It's a Triangle Opportunity!" People use the term not because it is an exact fit, but because it is the closest match we have and the intention is largely the same. HFT being a lot about using computers to gain tiny information advantages (racing the speed of light between exchanges for example) to make perfectly safe arbitrages millions of times a day and e…

> effectively skim off of the top of the market

The problem with this point of view is that it implies they are just taking, and not providing. HFT provides a more accurate market price by providing liquidity at small price differences. Whether what they provide justifies their cost is another question though.

Post reply on HN