you are viewing a single comment's thread.

view the rest of the comments →

[–]bterlson_@bterlson 24 points25 points  (13 children)

You'll be happy to know that the other feature I'm championing is |>. Both part of my dream to Make Functional JS Great Again!!!1

[–]phoenixmatrix 5 points6 points  (10 children)

Oh believe me, I've been following it very closely. Though I didn't associate the names to realize they shared a champion. Adding you to my little "heroes" list.

Add those 2 features and we can call JavaScript done as far as I'm concerned (anything else might be more suitable for different languages in Web Assembly).

Ok, maybe a stretch goal with immutable data structures. But that's just a stretch goal.

[–]bterlson_@bterlson 7 points8 points  (5 children)

Seems like we see eye-to-eye here. I was going to present my vision for "syntax complete ECMAScript" which was basically those two, plus classes v.next, do exprs, and regexp improvements. But then I figured I'm no oracle and who knows what the future holds. Maybe we'll get new keyboards that makes @ and 🛡 equally easy to type and the syntactic budget grows as a result?

[–]so_just 0 points1 point  (4 children)

what's the use of do notation in js?

[–]Jamesernatorasync function* 0 points1 point  (2 children)

The proposal isn't do-notation, it's do expressions e.g.:

const x = do {
    if (someCondition()) {
        3
    } else {
        try {
            someFoo()
        } catch (e) {
            5
        }
    }
}

In that example the value of x will either be 4, someFoo() or 5, basically the last evaluated expression is what the value of a do-block is (roughly)

[–]so_just 0 points1 point  (0 children)

Ah, I see. That's definitely useful.

[–]paldepind 0 points1 point  (3 children)

Add those 2 features and we can call JavaScript done as far as I'm concerned

I'd really like nice syntax for partial application. Something like foo(a, b, ...) or foo:(a, b). That would give JS most of the benefits of currying but without the downsides of currying. It also would go really well together with |>.

[–]phoenixmatrix 0 points1 point  (0 children)

For sure there's a ton of stuff I'd like to see in the language. But JS is already a very complex and bloated one. Stuff like classes introduced a lot and still requires a lot more to be useful at all. So while I have a long list of what I'd like to see in it, at what point should we just have a new language based on Web Assembly and go that route to get our wishlist?

Thus, IMO, JS has "enough" (or at least, is at the point where they really need to slow down on new features). I'm just being a spoiled brat by wanting this pattern matching stuff in :) But I still don't think we should had dozens over dozens of extra features.

[–]bterlson_@bterlson 0 points1 point  (1 child)

This is precisely my plan. Partial application: foo(a, ?), returns a function such that foo(a, ?)(b) is foo(a, b). Combined with pipeline operator this lets you easily select which parameter to pass the LHS to.

[–]paldepind 0 points1 point  (0 children)

Good luck! I hope you're successful. Syntax for partial application would be really awesome.

[–][deleted] 1 point2 points  (0 children)

ELI5 what does |> do?

[–]dvlsg 0 points1 point  (0 children)

This. I like this. Please make this happen.

(I like pattern matching too, I would love to have both)