Re:Functional Programming using JavaScript
by bodyloss on Monday November 24, 2014 @01:04PM
(#8653646)
Intrestingly it seems that the functional version he proposed is much faster than the OO version. http://jsperf.com/oop-vs-ramda
[ Parent
| on HN ]
Re:Functional Programming using JavaScript
by CrossEye on Monday November 24, 2014 @01:17PM
(#8653724)
(Author of that talk (and co-author of Ramda) here. Your perf test only times the parsing of the function -- not exactly fair.
Re:Functional Programming using JavaScript
by derpface on Monday November 24, 2014 @01:48PM
(#8653911)
Hey man. Great work.
Re:Functional Programming using JavaScript
by pritambaral on Tuesday November 25, 2014 @02:33AM
(#8656746)
Fixed for actually running the tests instead of just parsing:
http://jsperf.com/oop-vs-ramda/3
TL;DR: Ramda is somewhat faster than OO one
Re:Functional Programming using JavaScript
by idlewan on Tuesday November 25, 2014 @05:19AM
(#8657117)
Fixed for running a proper imperative version instead of the functional-oriented 'imperative' version of the original author:
http://jsperf.com/oop-vs-ramda/4
TL;DR: Imperative is faster than functional. Functional is shorter (33% slower in chromium, 83% slower in firefox), but might be more readable depending on your preferences.
Re:Functional Programming using JavaScript
by pritambaral on Tuesday November 25, 2014 @07:03AM
(#8657355)
Pardon me if I read it wrong, but you just removed the promises, didn't you?
Anyway, doing the same to the FP version yields almost equal speeds (Chromium):
Re:Functional Programming using JavaScript
by idlewan on Tuesday November 25, 2014 @07:40AM
(#8657443)
I removed all the useless promises, yes.
The one remaining is the one after fetchData, which looks like it could be async and make use of a promise.
It only yields equal speeds in chromium (good to know), although if you try in firefox, imperative is still 4 times faster.