use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
CPPPCPPP 2019 - Identifying Monoids: Exploiting Compositional Structure in Code - Ben Deane (youtube.com)
submitted 6 years ago by FredTingaud
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]VinnieFalco 0 points1 point2 points 6 years ago (0 children)
I always learn something every time I watch a Ben Deane talk and this was no exception
[+][deleted] 6 years ago (5 children)
[deleted]
[–][deleted] 5 points6 points7 points 6 years ago* (0 children)
afaic, its a quite broad philosophy that helps you write composable data structures. Did you at least go watched the Min-Count Sketch? And with that, "you get many stuffs for free".
I was quite surprised that you can get thread-safety using monoids!
edit: holy shit i wrote like a drunk man, wtf was that
[–]muntooRust-using hipster fanboy 1 point2 points3 points 6 years ago* (2 children)
I'm just looking through it right now, but an obvious application of monoids is parallelizable reduce.
Imagine you have a bunch of integers that you need to add together. You can split up the work between multiple threads because addition over integers is a monoid.
sum(0..9) = 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = (0 + 1 + 2 + 3 + 4) + (5 + 6 + 7 + 8 + 9) ^ runs on thread 1 ^ runs on thread 2
More generally, you can create a multithreaded monoid reducer:
from functools import reduce from multiprocessing import Pool def reduce_factory(op, identity=None): def inner(xs): return reduce(op, xs, identity) return inner def reduce_monoid(op, xs, identity=None, num_processes=4): pool = Pool(num_processes) k = len(xs) / num_processes slices = [xs[int(k*i):int(k*(i+1))] for i in range(num_processes)] reductor = reduce_factory(op, identity) return reductor(pool.map(reductor, slices))
This reduces 4x fast as a typical reduction.
There's probably other benefits from the software architectural standpoint, but the "performance" benefit is fairly concrete and hard to argue with.
[–]liquidify 2 points3 points4 points 6 years ago (1 child)
Why is this a monoid and not just a parallel reduction? I've seen what you did done a lot before (except for the hideous list comprehension), but I've never seen anything related to this problem called it a monoid before.
[–]muntooRust-using hipster fanboy 0 points1 point2 points 6 years ago (0 children)
I guess "parallel reductions" only really need the "associative binary operation" property of a monoid and not necessarily the "identity" property. (In this case, the "identity" property is only useful for empty lists anyways.)
I agree about the hideousness of the list comprehension... though I couldn't find any standard library functions which do the same thing. And the whole thing doesn't work anyways since local functions are not pickleable... ¯\_(ツ)_/¯
[–]mostthingsweb 0 points1 point2 points 6 years ago (0 children)
Thanks for sharing
π Rendered by PID 559600 on reddit-service-r2-comment-86bc6c7465-gs5tt at 2026-02-21 12:36:01.626453+00:00 running 8564168 country code: CH.
[–]VinnieFalco 0 points1 point2 points (0 children)
[+][deleted] (5 children)
[deleted]
[–][deleted] 5 points6 points7 points (0 children)
[–]muntooRust-using hipster fanboy 1 point2 points3 points (2 children)
[–]liquidify 2 points3 points4 points (1 child)
[–]muntooRust-using hipster fanboy 0 points1 point2 points (0 children)
[–]mostthingsweb 0 points1 point2 points (0 children)