News for hackers. Stuff that matters.
Re:JavaScript Pattern Matching Proposal by genezeta on Wednesday April 25, 2018 @12:12PM (#16922973)
Leaving aside syntax preferences or other superficial concerns, I find it discouraging that "Motivating Examples" for a proposal include direct references to particular libraries, or particular libraries' examples.

I mean, that one (of two) motivations for adding a feature to a language is "Terser, more functional handling of Redux reducers", just feels wrong and casual.

Re:JavaScript Pattern Matching Proposal by curun1r on Wednesday April 25, 2018 @01:51PM (#16924133)
It's probably more of a "know your audience" decision. Anyone who's used an ML-derived language will understand the motivation for pattern matching. But a large percentage of JS developers don't really have much background in non-mainstream languages or programming language theory, so they chose an example that's likely to resonate more with that group.
Re:JavaScript Pattern Matching Proposal by christophilus on Wednesday April 25, 2018 @02:14PM (#16924381)
> But a large percentage of JS developers don't really have much background in non-mainstream languages or programming language theory

Not to side-track the issue, but I keep hearing this. I'm wondering if this is true, and if so, how such a statement is verified. I'm currently a full-time JS dev, but have written my own programming languages, have professionally written in C, C++, C#, F#, Ruby, and others, and have dabbled in many other languages (and would love to professionally work in Clojure). [EDIT: Er, to the "non-mainstream" point, I've dabbled in Rust, Clojure, OCaml, Haskell, PureScript, Erlang, Elixir, and Elm. I don't know many JS devs that have done all of that, but most people I know have tinkered in odd non-mainstream languages.]

Most JS devs I know are not single-language devs. Am I just a super anomalous member of the JS community?

... Anyway, back on topic, I'm a big fan of pattern matching, so I'm all for seeing this proposal become a reality.

Re:JavaScript Pattern Matching Proposal by chc on Wednesday April 25, 2018 @03:09PM (#16924962)
I think you're a super anomalous member of any programming language's community. I doubt even one programmer in a thousand has written F# professionally (not being hipster here — I haven't done it myself).
Re:JavaScript Pattern Matching Proposal by myrryr on Wednesday April 25, 2018 @08:18PM (#16927707)
a LOT of function programmers end up doing a lot of javascript work.

I don't think he is odd in any way.

Re:JavaScript Pattern Matching Proposal by wtallis on Wednesday April 25, 2018 @11:43PM (#16928624)
Sure, a lot of functional programmers probably do end up doing javascript work. But that's still a large subset of a very small fraction of programmers in general, and they're definitely still vastly outnumbered by the folks who are barely more than script kiddies.
Re:JavaScript Pattern Matching Proposal by kreas on Thursday April 26, 2018 @12:20PM (#16933276)
Who are you calling a hipster....
Re:JavaScript Pattern Matching Proposal by curun1r on Wednesday April 25, 2018 @04:00PM (#16925454)
It's certainly been my experience that there are a lot of JS developers who aren't like you, though I have met a few who are. But JS has traditionally been one of the most accessible languages. Before transpilers became common, view source allowed non-programmers to learn javascript by example. And because of it's use in the front-end/web, you saw a lot graphic designers and other non-programmers learn it to be able to put something online. Javascript also goes out of its way to be friendlier. While other languages complain when you try to add two different width integers, Javascript will happily add a number and a string together. It's something that drives those of us with a static typing background nuts, but makes the language more approachable overall.

It's certainly a tired narrative that a lot of the churn in the front-end javascript framework world comes from developers who aren't aware of well-recognized patterns and techniques from other languages. But stereotypes and tired critiques almost always have some basis in reality and it does seem like the JavaScript world is rediscovering a few lessons the hard way rather than learning from the experience of other language communities.

Re:JavaScript Pattern Matching Proposal by noxToken on Wednesday April 25, 2018 @04:45PM (#16925928)
> Javascript also goes out of its way to be friendlier. While other languages complain when you try to add two different width integers, Javascript will happily add a number and a string together. It's something that drives those of us with a static typing background nuts, but makes the language more approachable overall.

We have differing definitions of friendly. Since I understand types and operator overloading, I know that 1 and "1" are different. I also know that the operator + does traditional math addition and concats Strings. If I didn't, it would probably drive me bonkers that "1" + 1 is "11" in JS instead of 2 or even "2". Having knowledge about types and overloading automatically tells me that String + Int = String.

I'm not saying that JS is bad since it lacks static typing. I'd argue that lack of static typing makes a language tougher to learn rather than more approachable. The barrier of entry is lower, but makes comprehension tougher.

Re:JavaScript Pattern Matching Proposal by curun1r on Wednesday April 25, 2018 @05:44PM (#16926494)
> I'd argue that lack of static typing makes a language tougher to learn rather than more approachable

I think it's a bit of a wolf in sheep's clothing. It makes it harder to master, but less intimidating when you're first starting out.

Also, I probably shouldn't have used the term static typing, since the issues I'm talking about are more associated with weak typing rather than dynamic typing.

Re:JavaScript Pattern Matching Proposal by minor3rd on Wednesday April 25, 2018 @02:26PM (#16924496)
I think it's a stereotype from the old web when it didn't require as much technical skill as other programming fields. Most of my colleagues started in other languages and learned Node/JS on the job.
Re:JavaScript Pattern Matching Proposal by sibeliuss on Wednesday April 25, 2018 @03:58PM (#16925427)
With JavaScript being the most used language in the world I highly doubt the old stereotypes still apply
Re:JavaScript Pattern Matching Proposal by emodendroket on Wednesday April 25, 2018 @04:24PM (#16925700)
Unless front-end development as a category has completely disappeared in the last few years there are certainly quite a few people who don't know how to do anything else.
Re:JavaScript Pattern Matching Proposal by Retra on Wednesday April 25, 2018 @07:12PM (#16927272)
Any language that is the most used is going to be used by mostly below-average programmers. I have yet to see a single domain where quality can be measured by popularity.
Re:JavaScript Pattern Matching Proposal by westoncb on Wednesday April 25, 2018 @04:25PM (#16925711)
Is it the most used language in the world? Seems like I keep hearing comments like that, but the rankings I've seen don't list it that way.
Re:JavaScript Pattern Matching Proposal by goatlover on Wednesday April 25, 2018 @05:20PM (#16926283)
It's the most visibly used language. But the world runs on a ton of code that isn't the web.
Re:JavaScript Pattern Matching Proposal by aylmao on Wednesday April 25, 2018 @05:27PM (#16926347)
According to Stackoverflow's developer survey it is [1]. Doesn't surprise me since developing for web means JavaScript.

Curious to know what rankings you are referring to though.

[1]: https://insights.stackoverflow.com/survey/2018/#technology

Re:JavaScript Pattern Matching Proposal by westoncb on Wednesday April 25, 2018 @07:22PM (#16927335)
I didn't see anything on methodology, but I'm assuming they're just surveying their users—in which case, I think it would make some sense for javascript to be overrepresented.
Re:JavaScript Pattern Matching Proposal by aylmao on Wednesday April 25, 2018 @09:01PM (#16927964)
I'd be curious to see the methodology behind the rankings you speak of.

EDIT: saw the sibling thread.

Re:JavaScript Pattern Matching Proposal by p-funk on Wednesday April 25, 2018 @05:28PM (#16926355)
What rankings have you been seeing? Javascript is on top of the list from what I've been seeing.

https://insights.stackoverflow.com/survey/2018/#technology

Re:JavaScript Pattern Matching Proposal by westoncb on Wednesday April 25, 2018 @05:32PM (#16926391)
Tiobe index for one. But I just searched Google and checked the top few.
Re:JavaScript Pattern Matching Proposal by chc on Wednesday April 25, 2018 @06:12PM (#16926775)
The TIOBE index has always been a bit weird. If you read their note about their methodology, you'll see that it's measuring something kind of interesting, but not really what you'd call "the most used languages." For example, IIRC part of a language's TIOBE ranking is how many college courses use it.
Re:JavaScript Pattern Matching Proposal by westoncb on Wednesday April 25, 2018 @07:26PM (#16927370)
Do you know of another more objective source, though?

Other folks are citing Github and Stack Overflow, but they are just reporting on proportions used on their own sites, and I would not be at all surprised to find that both those sites are more popular with web developers than say Java or C/C++/C# or Visual Basic devs (all those languages outrank javascript on Tiobe).

Re:JavaScript Pattern Matching Proposal by chc on Wednesday April 25, 2018 @08:46PM (#16927888)
That seems pretty likely to be true of Github. But for Stack Overflow, I would be really surprised. Stack Overflow has had a huge and thriving C# community from the start, and it's got so much page rank that questions about any language, "web" or not, are likely to lead there. The only languages that seem likely to be underrepresented are ones that are mainly used by people who learned them long ago and aren't gaining any more users (like MUMPS or something), since those people are unlikely to have questions.
Re:JavaScript Pattern Matching Proposal by sibeliuss on Wednesday April 25, 2018 @05:23PM (#16926310)
At least according to Github: https://octoverse.github.com/ - it's in its own class compared to the others: 2.3m to the next most popular (1m, python)
Re:JavaScript Pattern Matching Proposal by Sharlin on Wednesday April 25, 2018 @07:31PM (#16927412)
Yeah, but there's a trivial selection effect going on with Github.
Re:JavaScript Pattern Matching Proposal by my_ghola on Wednesday April 25, 2018 @03:57PM (#16925424)
I think that the large percentage of JS developers the GP is talking about is people for whom JS is probably their first or second programming language (and then the first is something like python, ruby or php).
Re:JavaScript Pattern Matching Proposal by ubernostrum on Wednesday April 25, 2018 @08:42PM (#16927850)
You are conflating two questions:

1. What percentage of JavaScript/front-end web developers are familiar with any other programming languages?

2. What percentage are familiar with a certain specific subset of other programming languages, namely functional or functional-ish languages with pattern matching as a core construct?

And you're treating an answer to (1) as an answer to (2).

Re:JavaScript Pattern Matching Proposal by Can_Not on Thursday April 26, 2018 @08:49AM (#16931360)
I'm s full time JS dev too. People keep saying that JS sucks or whatever, but [Rust, Clojure, OCaml, Haskell, PureScript, Erlang, Elixir, Elm, Scala, Nim] jobs are just so rare that picking one and going deep is basically like hoping to win a lottery.
Re:JavaScript Pattern Matching Proposal by sharpercoder on Wednesday April 25, 2018 @12:17PM (#16923028)
They should be included, as it simply is a valid use-case which most likely will actually be used. However, there should be many more examples or good real-world use-cases. Lack of those concerns me.
Re:JavaScript Pattern Matching Proposal by karmajunkie on Wednesday April 25, 2018 @02:47PM (#16924716)
I think if you look at languages that support them natively, like F#, OCaml/Reason, or Elixir/Erlang, you'll find plenty of examples of real-world uses. Whether those would suffice to illustrate how to apply them in a JS codebase that has this proposal enabled, I cannot say.

However, having gotten used to having them, I can safely say I'll always feel hobbled to work in a language that doesn't have them, so I'm very much in favor of adding them to JS, whether or not this is the proposal that wins out over time.

Re:JavaScript Pattern Matching Proposal by halestock on Wednesday April 25, 2018 @03:49PM (#16925352)
I actually drew the opposite conclusion. As in, "here's an example of how a commonly used library is overly verbose and how it could be simplified with this language extension."
Re:JavaScript Pattern Matching Proposal by snek on Wednesday April 25, 2018 @03:32PM (#16925200)
Usage of these libraries are not the reason this proposal exists, but rather demonstrating how the proposal fits with popular tools and such within the ecosystem.
Re:JavaScript Pattern Matching Proposal by timhwang21 on Wednesday April 25, 2018 @01:42PM (#16924031)
Stage zero proposals generally read less formally. IIRC they are held to lower standards and expected to be formalized in the later stages.
Re:JavaScript Pattern Matching Proposal by sibeliuss on Wednesday April 25, 2018 @03:59PM (#16925438)
I really liked the examples they used. I was able to share with coworkers who weren't familiar with the concept and it made perfect sense.
Re:JavaScript Pattern Matching Proposal by austincheney on Wednesday April 25, 2018 @01:50PM (#16924116)
Absolutely, agree. The code examples should be vanilla code, which could then be expanded to the preferences of any library/framework.
Re:JavaScript Pattern Matching Proposal by shados on Wednesday April 25, 2018 @08:58PM (#16927946)
Redux reducers were at least partly inspired by constructs of other languages that heavily rely on pattern matching.

So I'd take it more as "You know this mediocre compromise we had to do because JS is missing this core language feature? Well, there you go".

Re:JavaScript Pattern Matching Proposal by avshyz on Sunday April 29, 2018 @03:00AM (#16951003)
Well, think about the @ operator in python. It's aimed solely at people who use numpy.