News for hackers. Stuff that matters.
Re:Comparing Parallel Rust and C++ by _pferreir_ on Thursday November 07, 2019 @05:48AM (#21472087)
It's not the most readable Rust code I've ever seen and I guess that's not the main concern here. That said, I guess people find C++ easier because they're already used to the syntax.
Re:Comparing Parallel Rust and C++ by blub on Thursday November 07, 2019 @06:09AM (#21472177)
Even an amateur C++ programmer or C programmer would understand what that C++ code does. The only slightly opaque thing is the std::tie call. I'd feel comfortable having one of my C-focused colleagues modifying that C++ code.

The Rust code is... typical Rust. The algorithm almost gets lost in the specific peculiarities.

Re:Comparing Parallel Rust and C++ by the_why_of_y on Thursday November 07, 2019 @07:26AM (#21472547)
The first thing an amateur C++ programmer would notice is that that code isn't standard C++ code, what with its weird "#pragma omp" thing that isn't in the index of the Stroustrup book.
Re:Comparing Parallel Rust and C++ by gpderetta on Thursday November 07, 2019 @07:33AM (#21472594)
the nice thing about those pragmas is that the code has can be understood even if you ignore them. I do not know if this is true for all omp pragmas (IIRC some the newer ones might have some non ignorable semantics) but it is true for this omp for.
Re:Comparing Parallel Rust and C++ by the_why_of_y on Thursday November 07, 2019 @07:58AM (#21472755)
Yes, of course - a language extension can often give you better ergonomics than a library interface, both in implementing the code and in diagnostics reporting. The downside is that it's more effort to implement a language extension, it's more difficult to evolve it, and it restricts user's choice of implementation to those that have implemented the extension. For example, Microsoft Visual C++ supports only OpenMP 2.0, from 2002.

An interesting question in this context would be, is there anything preventing adding an OpenMP extension to Rust?

Re:Comparing Parallel Rust and C++ by gpderetta on Thursday November 07, 2019 @08:58AM (#21473187)
Of course there is a cost in making something part of the language, and the C++ way has always been to put features in the library whenever possible.

Regarding choice of implementation, there are more C++ compilers that support OpenMP than rust compilers.

Re:Comparing Parallel Rust and C++ by pcwalton on Thursday November 07, 2019 @10:36AM (#21474096)
Rayon is basically the "OpenMP of Rust" already.

OpenMP is designed around C-style for loops, which Rust discourages.

Re:Comparing Parallel Rust and C++ by gpderetta on Thursday November 07, 2019 @11:05AM (#21474391)
FWIW OpenMP supports any C++ random access iterator and c++11 range-for loops. I guess you count any external iterator as C-style loop.
Re:Comparing Parallel Rust and C++ by MauranKilom on Thursday November 07, 2019 @11:41AM (#21474754)
*newer OpenMP versions. MSVC is stuck on OpenMP 2.0 in which you can't even use unsigned integers as loop variable. No, seriously.
Re:Comparing Parallel Rust and C++ by petschge on Thursday November 07, 2019 @12:39PM (#21475274)
MSVC is hilariously bad and not used in HPC code. Not sure how much high performance game code is compiled with it.
Re:Comparing Parallel Rust and C++ by pcwalton on Thursday November 07, 2019 @12:42PM (#21475314)
A lot. I don't think OpenMP is used much in games.
Re:Comparing Parallel Rust and C++ by neutronicus on Thursday November 07, 2019 @04:26PM (#21477469)
Yeah OpenMP is mostly for problems with much less data-dependency than games.
Re:Comparing Parallel Rust and C++ by imtringued on Thursday November 07, 2019 @06:59PM (#21478767)
Rayon only covers a fraction of OpenMP's features.