Re:Beating Decades of Optimized C with 80 Lines of Haskell
by InvOfSmallC on Wednesday October 16, 2019 @02:49AM
(#21267728)
What is the cost of parallelism of C though?
[ Parent
| on HN ]
Re:Beating Decades of Optimized C with 80 Lines of Haskell
by rootw0rm on Wednesday October 16, 2019 @03:07AM
(#21267830)
spinning up threads and context switching, just like the cost for everyone else?
Re:Beating Decades of Optimized C with 80 Lines of Haskell
by chii on Wednesday October 16, 2019 @04:02AM
(#21268096)
The Haskell version is provably going to work without issue when parrellelized (due to monoid laws), but I doubt the concurrency primitives in C is as trivially usable, and I expect no sane person would want to write that version.
Re:Beating Decades of Optimized C with 80 Lines of Haskell
by cormacrelf on Wednesday October 16, 2019 @05:26AM
(#21268542)
There's nothing stopping you from following the monoid laws in C. There is also nothing stopping you from breaking the monoid laws in Haskell.
Re:Beating Decades of Optimized C with 80 Lines of Haskell
by sasasassy on Wednesday October 16, 2019 @05:09AM
(#21268437)
OpenMP IS trivially usable.
Re:Beating Decades of Optimized C with 80 Lines of Haskell
by keldaris on Wednesday October 16, 2019 @04:36AM
(#21268275)
Why? This is not a hard problem and there's nothing wrong with parallelism in C. I'd much rather work on parallelizing the C code than deal with any amount of Haskell. I suspect there are more people who would agree with me than the total amount of people happy to write Haskell.
Re:Beating Decades of Optimized C with 80 Lines of Haskell
by raverbashing on Wednesday October 16, 2019 @04:13AM
(#21268150)
Whatever the cost in C, Haskell is incurring the same cost, unless it is using green threads.
(You could use green threads in C - or something similar, though to be honest counting words in a file is a bit of an annoying problem for parallelism)
Re:Beating Decades of Optimized C with 80 Lines of Haskell
by pcstl on Wednesday October 16, 2019 @10:24AM
(#21270648)
Haskell does use green threads. The thing is, Haskell code is managed by a Haskell runtime, and each runtime manages a single (processor) thread. So the usual parallelism model for Haskell is to spawn a runtime for each processor core and then let each runtime manage its own green threads.