When Facebook released Folly last week, I couldn’t resist taking it for a spin. Even the “boring” stuff like strings and vectors are pretty neat, but the dynamic class and subsequent JSON parser are very interesting. What’s especially refreshing is the unadulterated use of C++11, a liberty that most libraries likely aren’t able to take.
One thing I’ve noticed when writing C++ is just how different my mindset is surrounding “waste”. In dynamic languages, I don’t hesitate to build up nested hash maps and concatenate strings liberally where convenient; one could argue even that some languages beg to be treated that way, and that the expressiveness you gain from being able to throw caution to the wind with regards to performance is a virtue.
However, while I’d readily write some scrappy string concatenations to generate presentable data in say JavaScript, I hesitate about writing the exact same code in C++, thinking twice about the ramifications of copying the string through the various levels of parsing, escaping, and string building, and worrying about the number of times the string is going to have to reallocate and copy; truly micro and premature optimization at its worst. The irony is, of course, that the C++ code would likely be faster than the JavaScript even with dynamic idioms.
So playing around with Folly’s dynamic class was, in a way, liberating. While I love static typing, indulging in the free-wheeling nature of dynamic C++ was oddly satisfying.
Fedora
In order to play around with Folly, I decided to setup a Linux VirtualBox. I launched a 64-bit CentOS 6 ISO, and proceeded to try to get it up to date. I’m going to spare you excessive details, but let’s just say I lost an entire afternoon trying to get CentOS to play nicely with VirtualBox (could not get internet or file sharing to work, though I could access Apache from my computer to the VirtualBox and vice versa) and trying to get GCC 4.7 installed. Memories of trying to upgrade CentOS 5 off of PHP 5.1 a half decade after its successor had been released, or trying to get anything past GCC 4.4 installed even on CentOS 6 lingered as I fired up the VM, having worked with CentOS at BSA (where I end up being the de facto sysadmin), but I felt that I’d still be most productive with an environment I was familiar with.
How wrong I was. After many hours of bashing my head into the wall, wondering how anyone enjoys system administration stuff (I like solving puzzles in my code, not other people’s), I deleted the virtual hard drive and downloaded Fedora, which I haven’t used since I ran a server with Fedora Core 1 when it first came out many years ago. What a difference. In the back of my mind, I had always associated Linux with CentOS and thus always unfairly associated Linux with being a pain in the ass. My outlook has changed thanks to Fedora.
Not only does it come with GCC 4.7 out of the box (not to mention PHP 5.4 and probably updated versions of just about everything else), but VirtualBox’s shared folder integration and bridge networking worked with just two clicks of the mouse. It basically booted up and was in a state that was ready to use. Compiling Folly from there was a breeze, as all of its dependencies were available in yum. While I’m still getting used to systemd and some other things that are different, Fedora thus far has actually been pretty enjoyable to use.
Eigen
While on the topic of awesome open source stuff, I want to give a shout-out to Eigen. If you’re ever doing linear algebra (not that I do very often), Eigen is absolutely fantastic. It’s highly portable, has no dependencies, and is entirely contained in header files, meaning you don’t need to compile a library first. It’s also LGPL, which I think is the most sensible for a library like this.
While some may balk at their use of operator overloading, it’s actually highly enjoyable to work with. Check out the ease of solving a system of equations.
When I first saw it, I was trying to figure out why they didn’t have a better getting started guide for the library itself. Then I realized that the code they provided compiled as-is and that there wasn’t anything else to do, and no platform-dependent intricacies. It’s also incredibly fast execution wise, at least if you’re comparing it to Matlab as I was. I’d go as far as to say that C++ with Eigen is both more enjoyable to code and more practical to use than Matlab.
Thank You
So, thank you to everyone working on Eigen, Folly, Fedora, and of course all of the technologies upon which these are built, for making available such incredibly useful building blocks for the rest of us.
There exists an opportunity here for a service that lets people donate to multiple open source projects all at once, like a bundle site for open source stuff. A way to make donations more as a thank you than a financial contribution, to reward open source contributors while also allowing people to find new projects that they may otherwise never discover based on other people’s donations.
Recent Comments