News for hackers. Stuff that matters.
Re:Why has CPU frequency ceased to grow? (2014) by madez on Wednesday February 21, 2018 @04:52AM (#16428247)
While Rust doesn't promote a specific model for parallelism, it's stronger compiler helps a lot with that.

https://doc.rust-lang.org/beta/nomicon/concurrency.html

https://doc.rust-lang.org/book/second-edition/ch16-01-thread...

I don't think fixing C(++) can give what Rust can give, because Rust has a clean start with these strong guarantees built-in while for C(++) it would always be an addon. Defaults are powerful.

Re:Why has CPU frequency ceased to grow? (2014) by chrismorgan on Wednesday February 21, 2018 @05:48AM (#16428517)
A really powerful outworking of it is seen in the Rayon crate, where you can change a sequential iterator into a parallel iterator just by adding the crate, importing the trait and changing `iter` to `par_iter`. If it’s not thread-safe to do, then it won’t compile. (That’s the big difference from C++.) If it is, it will, and it’ll be smart about how it runs, spreading the load across all available cores pretty much optimally, or not bothering with multiple threads if it’s not going to be worth it (e.g. single-threaded, or only one item in the iterator). And all that with close enough to no overhead.

Basically, Rayon makes data parallelism really easy in a way that few if any other languages do. I’d love to have an equivalent in Python or Node, but it’s just not possible to achieve such a thing in most languages—even if you ignore the thread safety aspect.

Parallelism hasn’t seen a great deal of use until it’s urgently needed, because it’s hard to get right in most environments, and you normally need to substantially refactor code to make it happen. My hope is that with the likes of Rayon, parallelism can be a much more natural thing that people that care even a little about performance will just do, because it’s so easy to do.

https://crates.io/crates/rayon

Re:Why has CPU frequency ceased to grow? (2014) by pjmlp on Wednesday February 21, 2018 @07:03AM (#16428803)
> Parallelism hasn’t seen a great deal of use until it’s urgently needed

This is the main reason why, initially, Windows Store APIs were all async.

Microsoft learned that when developers can choose between both models, by default most chose synch models.

Re:Why has CPU frequency ceased to grow? (2014) by romwell on Monday February 26, 2018 @10:47PM (#16470938)
>Basically, Rayon makes data parallelism really easy in a way that few if any other languages do.

Syntax-wise, there's OpenMP which can turn a for-loop into a parallelized for-loop (independently scheduled iterations) with just some syntactic sugar on top of the loop.

OpenMP has support for at least C++ and Fortran, and is not hard to use.

I wonder how Rayon compares to OpenMP.

Re:Why has CPU frequency ceased to grow? (2014) by ethagnawl on Wednesday February 21, 2018 @10:02AM (#16429893)
FWIW, you can also achieve similar behavior in Clojure via pmap, Reducers, etc.
Re:Why has CPU frequency ceased to grow? (2014) by floatboth on Wednesday February 21, 2018 @11:10AM (#16430460)
Re:Why has CPU frequency ceased to grow? (2014) by brazzy on Wednesday February 21, 2018 @11:57AM (#16430855)
To me, the "If it’s not thread-safe to do, then it won’t compile" part sounds rather more notable.
Re:Why has CPU frequency ceased to grow? (2014) by coolsunglasses on Wednesday February 21, 2018 @12:45PM (#16431307)
That's true of Haskell for the parallelism faculties. It's also true for STM. You can still get stuck or have race conditions with the other concurrency abstractions but it's less common than I encountered elsewhere. I didn't have problems resulting from mutable shared state that was aliased across threads and wasn't supposed to be, it's always explicit.
Re:Why has CPU frequency ceased to grow? (2014) by mitchtbaum on Wednesday February 21, 2018 @01:46PM (#16431833)
Another good crate to look at for this is Actix, Rust actors framework:

https://github.com/actix/actix

Re:Why has CPU frequency ceased to grow? (2014) by beojan on Wednesday February 21, 2018 @05:43AM (#16428488)
C++ has parallel algorithms built in (http://en.cppreference.com/w/cpp/algorithm).

Parallelism is complicated though, and easy parallelism pretty much requires a functional style. Things like Haskell's Accelerate library (https://www.stackage.org/package/accelerate) seem the ideal way forward to me.

Re:Why has CPU frequency ceased to grow? (2014) by smitherfield on Wednesday February 21, 2018 @02:12PM (#16432044)
Should be noted that so far only Visual Studio (partially) implements C++17 parallel algorithms, although there are several third-party implementations.[1]

Apples to oranges comparison of course, since Rayon isn't [planned to become?] part of the Rust standard library.

[1] http://www.bfilipek.com/2017/08/cpp17-details-parallel.html#...

Re:Why has CPU frequency ceased to grow? (2014) by beojan on Thursday February 22, 2018 @05:08AM (#16436541)
If you're including third-party libraries, you have things like ArrayFire and Intel TBB.
Re:Why has CPU frequency ceased to grow? (2014) by ilogik on Wednesday February 21, 2018 @06:52AM (#16428757)
Doesn't go also make it relatively easy to write parallel code?
Re:Why has CPU frequency ceased to grow? (2014) by gameswithgo on Wednesday February 21, 2018 @09:37AM (#16429721)
Not especially. It has goroutines, C# has Tasks, C++ has green thread libraries. Added onto this are channels which are basically thread safe queues, other languages have those too. (I am aware that there are differences between what features goroutines and Tasks provides)

Go's implementation of these things is nice, neat, and all included out of the box though which is nice.

In general you can make parallelism easy, or efficient, rarely both, at least not in a way that can solve problems generally.

edit: I should add Go does also come with a data-race detection tool which can be very useful. Not sure any other language includes that out of the box!

Re:Why has CPU frequency ceased to grow? (2014) by burntsushi on Wednesday February 21, 2018 @12:05PM (#16430916)
I think Go does make it relatively easy to write parallel code in comparison to most other frequently used languages.

> Not sure any other language includes that out of the box!

Rust's compiler does it by default, at compile time. ;-) Go's race detector is never wrong, but it may omit things. On the other hand, Rust's compiler is also neither wrong nor does it omit things, except under one circumstance: someone, somewhere, wrote `unsafe` code and committed a bug inside that block.

ThreadSanitizer is also a thing: https://clang.llvm.org/docs/ThreadSanitizer.html

Re:Why has CPU frequency ceased to grow? (2014) by Thaxll on Wednesday February 21, 2018 @11:37AM (#16430677)
Except in other languages it's not part of the core, it's an external library. So on the end it's easy to write "parallel" code.
Re:Why has CPU frequency ceased to grow? (2014) by gameswithgo on Wednesday February 21, 2018 @01:41PM (#16431794)
In C#, Task is part of the language, thread safe queues are part of the core libs.

Still not quite as tightly integrated as Go though.

Re:Why has CPU frequency ceased to grow? (2014) by ztoben on Wednesday February 21, 2018 @08:03AM (#16429107)
I believe you're thinking of concurrency, which go handles pretty well with goroutines.
Re:Why has CPU frequency ceased to grow? (2014) by icedchai on Wednesday February 21, 2018 @09:16AM (#16429554)
Go can use multiple cores. Goroutines will run in parallel (assuming GOMAXPROCS > 1.)
[dead]
Re:Why has CPU frequency ceased to grow? (2014) by gilrain on Wednesday February 21, 2018 @09:27AM (#16429633)
As someone who frequently posts about my personally-excellent experiences with Rust, what makes you suspect it's astroturf rather than just turf? You think Mozilla is paying people to post about Rust using puppet accounts? C'mon.
Re:Why has CPU frequency ceased to grow? (2014) by kibwen on Wednesday February 21, 2018 @04:16PM (#16433040)
Think about it. Mozilla Rust -> Godzilla (C)Rust -> "Godlike" giant lizard crust -> God is radiant -> light -> illumination -> Illuminati lizard people from beneath the Earth's flat crust are funding paid protestors to shill Rust, it's really the only explanation that makes sense.

(The person you're replying to is using the transparent internet argument tactic of trying to cast doubt upon genuine enthusiasm by implying some vague sinister motive, conveniently without bothering to articulate what that motive might even possibly be. Let's all recognize bad-faith arguments, downvote, and move along.)

Re:Why has CPU frequency ceased to grow? (2014) by arbie on Wednesday February 21, 2018 @10:33AM (#16430138)
It does seem a little odd that every comment about Rust gushes about its progress and stability without discussing any downsides. One would be similarly suspicious if, e.g., Perl6 were discussed this way.
Re:Why has CPU frequency ceased to grow? (2014) by gilrain on Wednesday February 21, 2018 @11:05AM (#16430409)
Try it out and write the critique, then. The posts are positive because Rust is genuinely achieving rapid progress and stability... but certainly not without flaws.

I've experienced plenty of frustration, albeit outweighed by the massive benefits for my use case. And there are whole problem domains to which it's just not suited. I see these mentioned pretty frequently.

Re:Why has CPU frequency ceased to grow? (2014) by Thaxll on Wednesday February 21, 2018 @11:45AM (#16430761)
For once there is no consensus how to do parallelism an concurrency in Rust since none of the library are matures.
Re:Why has CPU frequency ceased to grow? (2014) by kibwen on Wednesday February 21, 2018 @04:07PM (#16432982)
> none of the library are matures.

Rayon, the Rust library getting most of the discussion in this thread, is now 1.0: https://github.com/rayon-rs/rayon/blob/master/RELEASES.md .

Re:Why has CPU frequency ceased to grow? (2014) by coldtea on Wednesday February 21, 2018 @12:14PM (#16431007)
Don't most people opt for something called Tokyo? I don't do Rust much, but even I have heard of it by now...
Re:Why has CPU frequency ceased to grow? (2014) by steveklabnik on Wednesday February 21, 2018 @12:25PM (#16431108)
Tokio for IO concurrency, Rayon for data parallelism.
Re:Why has CPU frequency ceased to grow? (2014) by Bitcoin_McPonzi on Wednesday February 21, 2018 @01:17PM (#16431576)
Exactly! Rust doesn't solve any parallelism problems. It's no better than established languages like C# or F#, and probably worse.
Re:Why has CPU frequency ceased to grow? (2014) by vvanders on Wednesday February 21, 2018 @04:02PM (#16432953)
I'd consider handling data races gracefully a pretty large step forward in doing parallel data computation.
Re:Why has CPU frequency ceased to grow? (2014) by coldtea on Wednesday February 21, 2018 @12:13PM (#16430999)
>It does seem a little odd that every comment about Rust gushes about its progress and stability without discussing any downsides.

Doesn't seem odd at all.

First, a lot of people commenting about Rust are enthusiastic recent adopters that haven't seen much of the language, including any real ugly sides yet.

Second, it's not entirely true, almost all Rust threads mention the steep learning curve, the slow compiler, and other issues such as the variadic generics (or lack thereof to be precise).

Third, we have seen the same "early adopter enthusiasts seeing it all rosy" circle for RoR, Go, Node, and Mongo, nothing out of the ordinary here.

Re:Why has CPU frequency ceased to grow? (2014) by chillee on Wednesday February 21, 2018 @11:03AM (#16430389)
That's what happens when you have a new hip language/framework that has a lot of hype.

You see the same with Rust, Elixir, VSCode, Elm, Purescript, ReasonML, etc.

It's not astroturfing, it's just a lot of beginners that are overly excited to proselytize their new discovery.

Re:Why has CPU frequency ceased to grow? (2014) by pault on Wednesday February 21, 2018 @11:24AM (#16430587)
I don't think it's fair to claim these people are all beginners. More likely it's a phenomenon where mature languages have been around long enough that you already know their strong and weak points, but when you look at a language in development you only see its potential.
Re:Why has CPU frequency ceased to grow? (2014) by chillee on Thursday February 22, 2018 @02:20PM (#16440525)
I mean, it's not just true for new languages. For Haskell, you see beginners claim that "it's a perfect language and can do no wrong", while experts in the language will acknowledge its faults, including: long compile times, the downsides of laziness, etc.