Live data from Hacker News

C++: Is It Really a Cruel Joke? (2003)

webhome.phy.duke.edu

91–100 of 155 posts

Re: C++: Is It Really a Cruel Joke? (2003)

#91
post #47
post #30

Earlier quoted context omitted.

I read that book around 1998 and was an instant convert. C++ has a steep learning curve, and does not stop you from getting yourself into a lot of trouble, but it does stand up to Bjarne’s original promise about performance. IMHO the STL is one of mankind’s greatest accomplishments.

The STL doesn't always live up to the standard of "zero overhead abstractions." The list is not high performance, many implementations of hash tables never shrink (and used to have O(n) erase!), and deque is a bad joke (no chunk size control, plus laughable fixed chunk size on some common platforms). Many high performance projects use vector but few other containers. If the STL had a lesson to teach us it should have…

> Most high performance projects use vector and little else.

Right. And then it is actually a lot simpler to simply use pointer + size pairs [1] instead of std::vector. Changing to explicit allocation was the best decision I've made. I now find myself not longing for any C++ features anymore at all. I haven't needed anything besides a little allocation wrapper [2] and maybe a string-to-hash map since.

[1] Or n pointers + 1 size for parallel arrays, indicating that it's a bad idea to glue pointer + size in the first place.

[2] https://gist.github.com/jstimpfle/562b2c3e9fe537e378351bb9d5...

Re: C++: Is It Really a Cruel Joke? (2003)

#92

Earlier quoted context omitted.

Rust definitely is a good choice, if you can give up inheritance.

Wouldn’t classify Rust as OO though.

Why? It specifically chooses to drop one piece of OO, object inheritance, but it does have functional inheritance. It even has Deref which gives back a form of object inheritance.

It supports polymorphic functions like other OO languages.

While I find functional patterns more useful in Rust, that doesn’t prevent OO design where it’s desirable.

Re: C++: Is It Really a Cruel Joke? (2003)

#93
post #30

Dr. Stroustrup took a lot of pain to ensure the language was useful and did not break backward compatibility. He also always maintained that if you don't use a feature you shouldn't pay for it (in terms of performance). Eventually, it became even more popular and there is now a whole organisation behind the international standards for the language. The book "The Design and Evolution of C++" helps one understand why s…

I read that book around 1998 and was an instant convert. C++ has a steep learning curve, and does not stop you from getting yourself into a lot of trouble, but it does stand up to Bjarne’s original promise about performance. IMHO the STL is one of mankind’s greatest accomplishments.

I have recently got upto speed with c++17 features and I want to explore more C++. So far I have used Java and Python to build webapps. Are there libraries/framework that can replicate the MVC in C++ as well? I think I can extend functionalities from there.

Re: C++: Is It Really a Cruel Joke? (2003)

#94
post #50

Earlier quoted context omitted.

I stumbled into Nim recently and this thing "just works". Python-like syntax, performance like C. This is what C should have been, I'd say. https://nim-lang.org/

I would encourage you to use Cython instead of Nim if you're looking for Python-like syntax combined with C performance.

This is just my situation, but I gave up on Cython when I started moving forward with it (distributed graph algorithms). I found that I had more things to learn. With Nim, it took me half a day (after seeing the language for the first time) to get a basic numerical process going and another few days for distributed data communication involving messaging and postgres/mongo (Nim has a modern JavaScript (ES6) promise/async/await like concurrency model that is powerful and succinct like the language itself)

Re: C++: Is It Really a Cruel Joke? (2003)

#95
post #72
post #63

Earlier quoted context omitted.

Which OS? Linux and Darwin are still entirely C in the kernel, I believe. Windows is C++.

It seems that windows kernel is C also : https://www.reddit.com/r/cpp/comments/4oruo1/windows_10_code...

There was a post in that thread that I think confirms my suspicions - that most 'new' code outside the kernel is being written in C++/98 or 14.

Re: C++: Is It Really a Cruel Joke? (2003)

#96
post #47
post #30

Earlier quoted context omitted.

I read that book around 1998 and was an instant convert. C++ has a steep learning curve, and does not stop you from getting yourself into a lot of trouble, but it does stand up to Bjarne’s original promise about performance. IMHO the STL is one of mankind’s greatest accomplishments.

The STL doesn't always live up to the standard of "zero overhead abstractions." The list is not high performance, many implementations of hash tables never shrink (and used to have O(n) erase!), and deque is a bad joke (no chunk size control, plus laughable fixed chunk size on some common platforms). Many high performance projects use vector but few other containers. If the STL had a lesson to teach us it should have…

Endeavors that really need high performance tend to use other standard library implementations. I think EA has their own, for example.

Re: C++: Is It Really a Cruel Joke? (2003)

#97

Earlier quoted context omitted.

Only if it need to have backward compatibility. Rust doesn’t so it can be vastly simpler.

I love Rust. Especially for emudev and embedded development (fields I would traditionally use C or C++). However, it still performs worse than C++ in most cases [1]. [1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

A number of those C++ benchmarks are "cheating" by using SIMD intrinsics, which was only stabilized in Rust about two weeks ago.

Re: C++: Is It Really a Cruel Joke? (2003)

#98
post #47
post #30

Earlier quoted context omitted.

I read that book around 1998 and was an instant convert. C++ has a steep learning curve, and does not stop you from getting yourself into a lot of trouble, but it does stand up to Bjarne’s original promise about performance. IMHO the STL is one of mankind’s greatest accomplishments.

The STL doesn't always live up to the standard of "zero overhead abstractions." The list is not high performance, many implementations of hash tables never shrink (and used to have O(n) erase!), and deque is a bad joke (no chunk size control, plus laughable fixed chunk size on some common platforms). Many high performance projects use vector but few other containers. If the STL had a lesson to teach us it should have…

"zero overhead abstractions" is a principle of the language, not the library. The STL containers are clearly designed to be on the "safer" side than the performant side. You are right that, perhaps, we've extracted the wrong lesson from the STL but your version ("iterators everywhere, including for your own algorithms and container types") is still definitely the right message.

As an example, STL unordered-maps have fairly strict requirements around iterator invalidation and that results in indirection that do affect performance. It's pretty easy to make a "faster" unordered_map that tosses that requirement (as many do).

Re: C++: Is It Really a Cruel Joke? (2003)

#99
post #72
post #63

Earlier quoted context omitted.

Which OS? Linux and Darwin are still entirely C in the kernel, I believe. Windows is C++.

It seems that windows kernel is C also : https://www.reddit.com/r/cpp/comments/4oruo1/windows_10_code...

the kernel is compiled in C++ mode and has a few classes AFAIK. Has been for a very long time - Win3.1 kernel already had some C++ in it.

The macos kernel driver interface, IOKit, is C++ too.

Re: C++: Is It Really a Cruel Joke? (2003)

#100
post #30

Earlier quoted context omitted.

I read that book around 1998 and was an instant convert. C++ has a steep learning curve, and does not stop you from getting yourself into a lot of trouble, but it does stand up to Bjarne’s original promise about performance. IMHO the STL is one of mankind’s greatest accomplishments.

I have recently got upto speed with c++17 features and I want to explore more C++. So far I have used Java and Python to build webapps. Are there libraries/framework that can replicate the MVC in C++ as well? I think I can extend functionalities from there.

Not quite MVC but RxCpp exists and can help with designing MVP style code. (also known as event driven programming)
Post reply on HN