Not clear how you're reaching that conclusion. Native constructs can still implement prototype methods transparently to the developer without the class keyword. Just as devs could in userspace.
But contrary to what you're saying, most popular userland libs are indeed function oriented, and they don't end up like you're suggesting. E.g. RxJS, lodash
By function oriented in this context, I mean that they don't rely on the new keyword for ordinary code. Which reads cleaner
Anyway, functional stdlib can be pretty clean, such as something like Stream(persons).filter(person => person.age > 18).map(person => person.firstName).
Also there's the Pipes spec in the works that would allow for chaining distinct functions that are not on same obj. Not sure of current status
I’m just expanding the example in my mind, nothing arcane. And maybe it’_.s just me, but I _.fail to _.see how lodash _.is “cleaner”, or why “new” makes things dirty. Are we discussing The High Art of Source Code here? If yes, it ain’t my thing.
functional stdlib can be pretty clean, such as something like Stream(persons).filter(person => person.age > 18).map(person => person.firstName)
I see a stream object with at least a couple of methods, how is it functional? What does functional mean here, callbacks? I mean, array.filter(predicate) also takes one. If that’s the thing, nobody takes it away, it’s already natural to js, since it’s multiparadigm. And we already have piping, it looks like foo().bar().baz() or map(foo).filter(bar) or Object.keys().reduce(quux). If you want a class deconstructor for FP-101 code, here it is:
You can turn it into “fize.toString("hex")” with a little Proxy magic (still no chance for a type safety, sadly).
I understand the different approaches you propose, and I could even write some decent Haskell in my experimenting ages, but my main question is what problem do we solve here and how this solution would be functional and not “move methods to same-named pojos, write them explicitly and pretend it’s FP”.
But contrary to what you're saying, most popular userland libs are indeed function oriented, and they don't end up like you're suggesting. E.g. RxJS, lodash
By function oriented in this context, I mean that they don't rely on the new keyword for ordinary code. Which reads cleaner
Anyway, functional stdlib can be pretty clean, such as something like Stream(persons).filter(person => person.age > 18).map(person => person.firstName).
Also there's the Pipes spec in the works that would allow for chaining distinct functions that are not on same obj. Not sure of current status