4 ms·
Interesting. there are some parts i like a lot here, but two things that I really dislike syntax wise. One is the lean towards a chainable syntax - this has pro
by cupofjoakim 4mo ago
Interesting. there are some parts i like a lot here, but two things that I really dislike syntax wise. One is the lean towards a chainable syntax - this has proven to a big footgun for many devs in both java streams and typescript, making it very easy to go from O(n) to O(2n). The other part i really dislike is the first argument principle noted. If i myself define `string_and_reverse` and I can call it both through `string_and_reverse(42)` and `42.string_and_reverse()` i could definitely see this leading to some very funky looking chaining.
Perhaps it's just one point from me - not liking chaining :D
- KolmogorovComp 4mo ago> making it very easy to go from O(n) to O(2n) Strictly speaking I assume everyone knows O(n) = O(2n) =O(kn) for k in R. But I see your point. I assume any decent compiler would merge the loops though
- cupofjoakim 4mo agoFair! That'd depend on the operations right? For example, AFAIK typescript can't do much about multiple chained `map` calls, and i've seen quite a few `.filter(...).map(...).filter(Boolean).map(...)` :/
- c0balt 4mo agoTo be fair this likely should be handled by the interpreter/compiler for the compiled JS. V8 probably can merge this into one loop or another similar based on runtime types
- keithasaurus 4mo agoYes, blorp does that. And it also allows local mutation and loops inside pure functions, so performance doesn't need to be left on the table in most cases.
- xigoi 4mo ago> i could definitely see this leading to some very funky looking chaining. At least for me, thing .doThis() .thenDoThat() .andFinallyThis() is much more readable than andFinallyThis( thenDoThat( doThis(thing) ) )
- cupofjoakim 4mo agoWell, nesting is not the only option. ``` thing.doThis() thing.thenDoThat() thing.andFinallyThis() // or doThis(thing) thenDoThat(thing) andFinallyThis(thing) ```
- xigoi 4mo agoThat’s not equivalent.
- keithasaurus 4mo agoYeah, this is the idea. This chaining is exactly the same as the pipeline operator in some some function languages, except that it hopefully reads in a more familiar way to programmers of non-functional languages.
- keithasaurus 4mo agoHi, maintanier of blorp here. I think you mean that [1,2,3].map(func(x): x *2).filter(func(x): x > 5) would iterate twice, correct? Under the hood blorp optimizes that away for the functions we can. It constructs a loop and combines logic into a single iteration where possible. Of course, blorp also allows local mutation in loops (even in pure functions, so long as the logic is contained to the function), so if there's a specific algorithm you'd rather express in a loop, you can.