3 ms·
I don't know. I don't write functional because it's hard and I'm super smart, I write functional because it's easy and I'm lazy. I'm also not sure the example
by vnorilo 5y ago
I don't know. I don't write functional because it's hard and I'm super smart, I write functional because it's easy and I'm lazy.
I'm also not sure the example in TFA is much of an argument. From a glance looks like the programmer got entangled in their own cleverness, but the slice we are shown is too small to show if there's some external reason to do it like that.
story time: once did a compile time parser generator with c++ templates. "Zero-cost" abstraction and all that jazz. Turns out the binary was so large that a type-erased vtable system ran faster, for all its nonzero cost.
Templates are orthogonal to functional or imperative. It's a code generator. Understand what you generate!
- tooltower 5y agoI've had this experience too. It doesn't take a lot of template use for both binary size and build time to blow up. When iterating with `make` starts taking over a couple of minutes even on a smallish-medium-sized project, it becomes a bit much. I didn't do anything fancy like compile-time parser generation. it was overuse of the standard library features, like `std::variant`.
- pharmakom 5y agoI have settled on the immutable core + imperative shell pattern, because it’s the easiest way to write robust software in my experience. It’s much easier to do this in a functional language like F# or OCaml than it is in a mainstream OOP language, even one with all the bells and whistles like C#.
- vnorilo 5y agoTrue. Especially when guiding a team C# makes life hard because so much of immutability is by convention only. I suppose it will get better once we can move to C#9 with Records, but even so, some discipline is required.
- logicchains 5y agoIt's getting much easier in C++ due to constexpr becoming more and more powerful. A constexpr function is a mathematical function, in that the compiler guarantees that its output is a deterministic function of its input.
- garethrowlands 5y agoIt's a great pattern. It's also the default in Haskell because you can't normally invoke imperative actions from a pure function.