just an fyi for FP: you can skate on c++ backgroun...
# arrow
j
just an fyi for FP: you can skate on c++ background for 3 decades in the jvm without any surprises but this is proof positive I'm not in the twilight zone with arrow.
r
yep, here we always refer to the CT meaning of it. I think Bartosz post on CT for C++ may help you draw the anology between the two worlds and what you already know from C++ https://bartoszmilewski.com/2015/01/20/functors/
j
i think the occasional signpost in the autodocs specifically to functor is going to help those of us who learned it from James Coplien's Purple book of c++ idioms which were dissimiilar concepts altogether but drove the entirety of the culture.
i have scratching my head for weeks or longer trying nail down the simplest possible analogs back to template metaprogramming and STL
there is no FP equivalent to the c++ iterator, but java streams and to some lesser degree iostreams do appear to fit monadic definition
without gc we would have been tossed out on our ear for favoring recursion or immutability in constrained programming situations
our closest relationship to FP was metaprogramming with macros and templates to eliminate the intermediary state entirely and avoid object creation.
r
right, in Kotlin instead of that you use generics or the kind emulation to achieve polymorphic functions and classes that are equivalent to those templates
but the allocation free runtime is only possible if your implementations use inline classes and cast to the correct states
otherwise is just standrd JVM dynamic interface dispatch as a penalty
so one function call away from the abstraction always
The alternative is to work with concrete types or model your entire program as an ADT that can be interpreted and optimized but allocations are still always there
Among other things because in Kotlin you can’t represent unions or products as structs without allocations
all ADTs and sealed hierarchies are penalized because they require allocation and generate garbage to clean up by GC