DEV Community

Discussion on: Functional Programming in JavaScript

Collapse
 
lifelongthinker profile image
Sebastian

Great post, thanks for sharing. πŸ‘

I'd like to add that JavaScript used to be a Lisp dialect, so has its roots in FP.

Only "recently" do we see a lot of OOP concepts finding their way into JS (especially through ECMA standardization).

Now add the fact that JavaScript was actually a misnomer (it had nothing to do with Java or Java's foundation) and we might understand why many devs from an OOP background struggle with JS at the beginning.

Of course, the latter is mitigated through ECMA's standardization efforts that have added a lot of OOP ideas to JS.

Collapse
 
iquardt profile image
Iven Marquardt • Edited

There were three new features in ES6 relevant to FP: arrow syntax for lambdas, the Promise abstraction and tail call elimination. Browser vendors skipped the latter, because the teams in charge were biased for OOP and probably the respective companies as well. The Promise Aplus design process was also biased against FP, because the key players were again employed by the very same companies.

Collapse
 
hunter profile image
Hunter Henrichsen

I started with Java, and definitely experienced that. I heard a comparison that comparing Java to JavaScript was like comparing a car to a carpet, but I don't think that holds as much anymore because the JS ecosystem has really developed in the past few years.

I think adding the option to do OOP in JS is a good direction to take, as letting developers choose which paradigm to use for each situation is really powerful. That power is another reason I see the same approach being adapted in Java 8+ and other languages.

Collapse
 
lifelongthinker profile image
Sebastian

The car / carpet thing is awesome. That's exactly how it used to be.

And I second what you said: JS has come a long way and it's good that we can use it as a full-grown OO language now.

It's also nice to see that so many popular languages are opening up to all different sorts of paradigms. Gives us developers lots of options and flexibility.

Collapse
 
craigmc08 profile image
Craig McIlwrath

JavaScript actually does have a bit of a connection to Java. See this article for more detail, but I'll try to summarize it.

Netscape thought that bringing Java to the web was a great idea and they were working with Sun Microsystems to make this happen. The purpose of JavaScript was to be a scripting language that was easy to use (for amateurs, as opposed to the more enterprise-y Java). JavaScript was originally supposed to be Scheme-like, but the partnership with Java forced it to become more Java-like.

It wasn't called JavaScript at first. It started as Mocha (to connect it thematically to Java), but then became LiveScript (to avoid any legal issues before Netscape sealed the deal with Sun). It was renamed to JavaScript after the deal closed, because it was supposed to work very closely with Java (see LiveConnect)

Of course, being a Scheme language with the requirement that it looks like Java was a surefire way to confuse anyone who first looked at the language.

Collapse
 
lifelongthinker profile image
Sebastian

Thank you very much for the insight. That is entirely news to me. It is interesting how much political/legal energy is put into what is otherwise technical decision making. πŸ‘