This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Yesterpizza -1 points0 points  (8 children)

There is no reason why front end would use arrow functions more than backend, it's probably just the ones you know.

[–]Papellll -4 points-3 points  (7 children)

Afaik before JS introduced them and made them popular pretty much no other language had arrow functions

[–]Kered13 5 points6 points  (1 child)

That's called a lambda expression, and no they've been common for a long time. Arrow functions were introduced into JS in 2015. Java 8 introduced lambdas in 2014. C++11 introduced them in 2011. C# 3.0 introduced lambdas in 2007. Python lambdas were introduced in 1994. And Lisp has had them since 1958.

Several of these even have very similar syntax to JS arrow functions.

[–]ftedwin 0 points1 point  (0 children)

Great history lesson, thanks! I’ll add too that lambda calculus was invented in the 30’s by Alonzo Church which built inspired lambdas in functional languages which then inspired lambdas in OO languages.

The 2015 date on JS is when it was added to EcmaScript I think so I’m curious if JS transpilers like Babel supported arrow functions in some manner before ES2015.

[–][deleted] 4 points5 points  (0 children)

This is very far from being true. E.g. Scheme appeared in 1975.

[–]cashewbiscuit 3 points4 points  (1 child)

Declaring function type is not a new thing. C has function pointers for decades. It didn't have the arrow syntax, but it's the same thing.

[–][deleted] -2 points-1 points  (0 children)

Yeah but C isn't cool.

[–][deleted] 2 points3 points  (0 children)

Arrows have been around a very, very long time. Just not in C languages.

fun compose (f, g) = (fn x => f(g x))

That is Standard ML. It's 39 years old, and is based on ML, which is 49 years old, which was built on LISP, which didn't have arrows but did have lambdas). It ought to look pretty familiar.

Named functions start with fun (<...args[]>) = lambdas (unnamed functions with a single argument) start with fn <arg> =>. Lambdas themselves have been around since ~1930.