|
|
|
|
|
by kafkaesq
3206 days ago
|
|
That's nice, but form a hard-nosed engineering perspective, not just sometimes, but in general 19 lines of yucky procedural code that pretty much anyone can understand (and debug) are usually way, way better than 9 lines of "elegant" functional code comparatively far fewer people can (really) understand - and which can be comparatively far more sinister and nefarious to debug. Given that, after all, it's just posting likes we're talking about. You'd think that with such a bold proposition as "Why category theory matters -- no really, it does!" this would be about hot-synching whole data centers, or getting drones to deliver medicine in Africa, or something like that. You know, something perhaps unthinkable (or maybe just far less tractable) with procedural (or just less sophistical functional) code. But no, in this case apparently it's about... updating your FB likes. |
|
> 9 lines of...functional
First of all, those numbers are more like 1000 vs 200, but lines of code isn't a useful metric here.
The thing functional programming does for us is not hide the functionality of our code, it is to make it more consistent.
Category theory shows us ways that our code can be more consistently organized, so that we don't need to reason about the entire codebase when writing the code that guess it together.
This means we can create modules that are so compatible, all it takes to compose them is a simple map or fold.
While it may take more effort to understand the functional language itself, you may find that effort is comparatively less than learning what someone's imperative code does.
I always know right away what map and foldl will do, but I can never know what a loop does without reading through that loop.