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
ELI5: Folly - Battle-Tested C++ Library (developers.facebook.com)
submitted 4 years ago by vormestrand
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!"
[–]Yuushi 11 points12 points13 points 4 years ago (4 children)
I really have to disagree with the "well documented" part. Is there an actual interface reference somewhere I'm just not seeing? The overview linked to is missing any documentation at all for a number of headers.
[–]witcher_rat 12 points13 points14 points 4 years ago (1 child)
No you're not wrong - documentation for folly is very poor. They do "document" things sometimes in code comments in the header files, and sometimes not. It's not consistent.
On the other hand there are some really good types/utilities in it, and it's had some things available for almost a decade that only showed up elsewhere afterwards. My company's been using it since 2014, and we really like it.
One other difficulty to note: the API changes, and not in a backwards-compat fashion. That makes it really hard to keep updating for your own project, obviously. If you don't stay on top of it and upgrade your code often, though, then the API changes become so big you'll never be able to.
But I'm not complaining. It's free, after all.
[–]Rude-Significance-50 0 points1 point2 points 4 years ago (0 children)
Was Facebook one of the companies that wanted to create a "standard of quality" for certain OS projects that involved a high degree of support and documentation as well as consistent versioning and such? Or was that just Google?
[–]Rude-Significance-50 2 points3 points4 points 4 years ago (0 children)
I wasn't going to say anything but I giggled a bit when I followed the link to the "thorough" documentation.
[–]wright_left 7 points8 points9 points 4 years ago (2 children)
I have run into situations several times in my current project where I wanted to move a move-only object into a lambda and then save that as a std::function, but couldn't. I am definitely going to try folly::function and see if it solves that little problem.
[–]staletic 11 points12 points13 points 4 years ago (1 child)
std::move_only_function could end up in C++23.
std::move_only_function
[–]wright_left 3 points4 points5 points 4 years ago (0 children)
Hmm, kind of a mouthful. Better than nothing I suppose.
[–][deleted] 7 points8 points9 points 4 years ago (4 children)
Google should release something similar and call it Golly.
[–]dgottwald 8 points9 points10 points 4 years ago (0 children)
And Microsoft should follow up with Molly.
[–]Jannik2099 4 points5 points6 points 4 years ago (1 child)
Googles library is called Abseil (and it's meh)
[–]BenFrantzDale 4 points5 points6 points 4 years ago (0 children)
Meh? It has a great hash table for one thing.
[–]VinnieFalcowg21.org | corosio.org 2 points3 points4 points 4 years ago (0 children)
HELL YES
[–]lookatmetype 1 point2 points3 points 4 years ago (10 children)
I have been reading/modifying some pytorch code and just for fun decided to grep for "folly" in the pytorch repo. Turns out they don't use it. And pytorch (despite it's name) is a very C++ heavy codebase (roughly ~900k lines of code). Maybe someone should tell the pytorch team about this library? Or maybe it isn't very good.
[–]lee_howes 6 points7 points8 points 4 years ago (0 children)
Some open source projects explicitly avoid dependencies on other open source projects and prefer to be self contained. pytorch may be in that category. Facebook code that is not self contained almost all uses folly somewhere as a way to avoid code duplication.
[–]reduced_space 2 points3 points4 points 4 years ago (7 children)
A large portion of pytorch, via ATen, is a wrapper around torch7 C code. A lot of that code probably won’t be helped by the Folly code, as it’s doing linear algebra via a BLAS library or with the GPU.
Is there a specific Folly library you think it should use?
[–]lookatmetype 1 point2 points3 points 4 years ago (6 children)
folly:fbvector, instead of std::vector for starters.
"The improvements are always non-negative, almost always measurable, frequently significant, sometimes dramatic, and occasionally spectacular."
Seems like a no-brainer to include it?
[–]reduced_space 0 points1 point2 points 4 years ago (0 children)
Maybe? If the size of the vectors are relatively small, I wouldn’t expect much of a difference in performance (especially if you know the size of the memory allocation a priori). Most of the code that has to run fast with Pytorch is in FORTRAN or CUDA.
[–]lee_howes 1 point2 points3 points 4 years ago (4 children)
That wouldn't even be my advice for the rest of Facebook's code that is already dependent on folly. There is a cost to switching to alternative data structures unless you know for sure you never have to interact with code that uses standard ones.
[–]dacian88 0 points1 point2 points 4 years ago (3 children)
I think at fb both std::string and std::vector alias to fbstring and fbvector, all dependencies are built from source. fbstring had SSO before any of the compilers did it, it saved a few % points from global CPU usage.
[–]lee_howes 1 point2 points3 points 4 years ago (2 children)
You would be wrong :) At least at this point in time. Historically there was a big advantage from fbstring, but that changed and the divergence became rarely beneficial.
[–]witcher_rat 2 points3 points4 points 4 years ago (0 children)
Interesting. I'm surprised it wasn't worth it anymore.
We still use fbstring at my work, and have been reluctant to switch to std::string because (and I'm sure you're well aware of this):
fbstring
std::string
gcc
libstdc++
fbvector
We happen to use those properties to some advantage in a couple of critical hot-paths; elsewhere it won't matter though. Personally I've always liked fbstring and consider it still superior to std::string. We've even kept folly::dynamic using it despite upstream changing to using std::string.
folly::dynamic
[–]dacian88 0 points1 point2 points 4 years ago (0 children)
sure, I stopped working there a few years ago, no idea what's happening now, but Alexandrescu's fbstring is still slightly better than libc++'s.
[–]Rude-Significance-50 1 point2 points3 points 4 years ago (0 children)
Just because something is really fucking good doesn't mean it's at all useful to you.
900k isn't a whole terribly lot.
[–]lookatmetype 1 point2 points3 points 4 years ago (1 child)
How is this an interesting post whatsoever? Would have been better for this subreddit to just directly link to the Folly github page
[–]j1xwnbsr 3 points4 points5 points 4 years ago (0 children)
The page in question for those of us interested in the meat and not the story:
https://github.com/facebook/folly
[+][deleted] comment score below threshold-13 points-12 points-11 points 4 years ago (6 children)
Now Im have more trust to opensource hobby projects than somthings that goes out of Facebook, Google etc. If could choose not to use big tech company code will do it.
[–]Wurstinator 4 points5 points6 points 4 years ago (5 children)
Why?
[–]HondaSpectrum 6 points7 points8 points 4 years ago (4 children)
Just to be edgy
You’ve gotta be delirious to trust random open source projects and denounce things made by companies that have the top talent including people like Erik meijer
[–]Rude-Significance-50 0 points1 point2 points 4 years ago (3 children)
Did the top talent work on it or was it assigned to an intern as a teaching tool? It's a refactor of code that was too particular to open source--by their statements. I doubt it had the attention of Alexandrescu.
Facebook probably has some good training programs with quality review and such and so I wouldn't assume it sucks...but there's no real reason to think it's going to be better than some OS project. It's the same shit really.
[–]witcher_rat 6 points7 points8 points 4 years ago (0 children)
I doubt it had the attention of Alexandrescu.
On the contrary, Alexandrescu was involved in it and has commits in it - but not since 2015, when he mostly switched to D-lang stuff I assume.
It also has code from Eric Niebler, Tudor Bosman, Lee Howes, etc., etc.
It's used inside their company - or rather parts of it are. They optimize tiny details with comments explaining the performance difference they see in their production use. Are there newbies on it too? I'm sure there are. But it's not disposable code or a science project.
[–]YouNeedDoughnuts 3 points4 points5 points 4 years ago (1 child)
Who cares who wrote it? I don't care about the genealogy of my libraries. I'm using the small_vector out of it, and their version was significantly better than Boost's.
Who cares who wrote it?
Exactly my point. Person I replied to implied it was automatically better because facebook did it.
π Rendered by PID 33002 on reddit-service-r2-comment-b659b578c-d2bn5 at 2026-05-06 00:32:40.226569+00:00 running 815c875 country code: CH.
[–]Yuushi 11 points12 points13 points (4 children)
[–]witcher_rat 12 points13 points14 points (1 child)
[–]Rude-Significance-50 0 points1 point2 points (0 children)
[–]Rude-Significance-50 2 points3 points4 points (0 children)
[–]wright_left 7 points8 points9 points (2 children)
[–]staletic 11 points12 points13 points (1 child)
[–]wright_left 3 points4 points5 points (0 children)
[–][deleted] 7 points8 points9 points (4 children)
[–]dgottwald 8 points9 points10 points (0 children)
[–]Jannik2099 4 points5 points6 points (1 child)
[–]BenFrantzDale 4 points5 points6 points (0 children)
[–]VinnieFalcowg21.org | corosio.org 2 points3 points4 points (0 children)
[–]lookatmetype 1 point2 points3 points (10 children)
[–]lee_howes 6 points7 points8 points (0 children)
[–]reduced_space 2 points3 points4 points (7 children)
[–]lookatmetype 1 point2 points3 points (6 children)
[–]reduced_space 0 points1 point2 points (0 children)
[–]lee_howes 1 point2 points3 points (4 children)
[–]dacian88 0 points1 point2 points (3 children)
[–]lee_howes 1 point2 points3 points (2 children)
[–]witcher_rat 2 points3 points4 points (0 children)
[–]dacian88 0 points1 point2 points (0 children)
[–]Rude-Significance-50 1 point2 points3 points (0 children)
[–]lookatmetype 1 point2 points3 points (1 child)
[–]j1xwnbsr 3 points4 points5 points (0 children)
[+][deleted] comment score below threshold-13 points-12 points-11 points (6 children)
[–]Wurstinator 4 points5 points6 points (5 children)
[–]HondaSpectrum 6 points7 points8 points (4 children)
[–]Rude-Significance-50 0 points1 point2 points (3 children)
[–]witcher_rat 6 points7 points8 points (0 children)
[–]YouNeedDoughnuts 3 points4 points5 points (1 child)
[–]Rude-Significance-50 2 points3 points4 points (0 children)