"Given that JavaScript’s author was recruited to do “Scheme in the browser,”" Didn't he disclaim that multiple times?
Beautiful JavaScript – Functional JavaScript
21–30 of 59 posts
Re: Beautiful JavaScript – Functional JavaScript
#22"Given that JavaScript’s author was recruited to do “Scheme in the browser,”" Didn't he disclaim that multiple times?
Just to be clear the prototypal inheritance came from Scheme, but the funcational aspects of JavaScript came from Lisp. Scheme's influence on JavaScript was, at the time, indeed an open question. On the other hand they absolutely told Eich not to do anything that resembled Lisp. JavaScript was to be Java's little brother and it had to look like and mostly act like its big brother. Eich made it work like Lisp anyways…
Re: Beautiful JavaScript – Functional JavaScript
#23linters and static analysis in JS is still young, but will complain about type mixing and mutables.
Re: Beautiful JavaScript – Functional JavaScript
#24Time again I'm always surprised by how people over look type systems when talking about functional languages. Really, much of that list is not fundamental to FP, but always giving me an Int when you promise one matters.
Re: Beautiful JavaScript – Functional JavaScript
#25My concern with all these "functional javascript" posts is that people might (understandably) leave with the false impression that this is what functional programming looks like in general. It's like if you tried to get someone into cars by having them drive a Hyundai i10. Regardless of whether you think JavaScript qualifies as a "functional language" just because it supports higher-order functions, the fact of the m…
Just exposing people to a few basic patterns from functional programming will 1) encourage them to learn a real functional programming and 2) help them write better code. Learning Haskell or Clojure or something is a big task, especially if you're doing it just because you're curious what all this functional programming is about. Everyone understand JavaScript, so being exposed to functional programming there is not…
Re: Beautiful JavaScript – Functional JavaScript
#26My concern with all these "functional javascript" posts is that people might (understandably) leave with the false impression that this is what functional programming looks like in general. It's like if you tried to get someone into cars by having them drive a Hyundai i10. Regardless of whether you think JavaScript qualifies as a "functional language" just because it supports higher-order functions, the fact of the m…
Just exposing people to a few basic patterns from functional programming will 1) encourage them to learn a real functional programming and 2) help them write better code. Learning Haskell or Clojure or something is a big task, especially if you're doing it just because you're curious what all this functional programming is about. Everyone understand JavaScript, so being exposed to functional programming there is not…
(GHC) Haskell and Clojure are pretty big languages, so it's not surprising that learning them requires a lot of effort, but are you seriously suggesting that learning JavaScript (all quirks included) is easier than learning Scheme or Standard ML (all quirks included)?
I've honestly tried to learn JavaScript (in depth, not just whipping something together by gluing libraries foo, bar, qux), but several parts of its semantics continue to baffle me. Like “this”.
Re: Beautiful JavaScript – Functional JavaScript
#27Will there be a time when going functional will be not just the fast way to write code, but the way to write fast code? Are there efforts to create high performance functional primitives that are easy to use and also outperform their imperative alternatives? I've used numpy, for example, and I wouldn't necessarily put it in the easy to use category. I'm hoping one day I can write straightforward functional code and have it not be so much slower than imperative code that I have to question which one I should use.
Re: Beautiful JavaScript – Functional JavaScript
#28"Given that JavaScript’s author was recruited to do “Scheme in the browser,”" Didn't he disclaim that multiple times?
"As I’ve often said, and as others at Netscape can confirm, I was recruited to Netscape with the promise of “doing Scheme” in the browser."[0] I guess what you're confusing is that he disclaims that it is inspired mostly on scheme: "I still think of it as a quickie love-child of C and Self."[0] [0] https://brendaneich.com/2008/04/popularity/
So JS got ideas from Scheme, Self, and Java.
Re: Beautiful JavaScript – Functional JavaScript
#29Like a lot of people, I'm drawn to the idea of functional programming, and I enjoy using the functional building blocks in JavaScript. What I struggle with is performance, and I bump into it all the time. The difference between overwriting an array with a for loop and using map() is roughly an order of magnitude. I use map() and other functional primitives whenever I can, with anything small and with any code that do…
i think the problem is that js is not really designed for this kind of usage. If you look at this from the point pf view of an compiler FP is way easier to modify and optimize to improve performance. There are many factors but i believe the most important factor of future FP-base optimising compiler is rich type-info that makes many optimisation techniques possible or easier (this is important) to implement. While it's kinda boring, just look at haskell what possible there with rewrite rules. In a way it's possible to write your own compiler optimisation for your library.
In JS it's way harder because JS is untyped and the type system is way, way more complicated. Many of the hatches you use to optimise your program make it harder for the compiler to optimize your program. And i know about JIT-compiler, they are really complex beasts and the only way to tackle a language like JS. Just look (again) at Haskell, i always wondered what a really, really god JIT-compiler would look like. I would think that all the optimisation that you get by just using some pragmas would be only "engineering" work and don't require some fundamental breakthroughs. Especially if you consider the huge amount of time that went into something like the JVM.
Re: Beautiful JavaScript – Functional JavaScript
#30Like a lot of people, I'm drawn to the idea of functional programming, and I enjoy using the functional building blocks in JavaScript. What I struggle with is performance, and I bump into it all the time. The difference between overwriting an array with a for loop and using map() is roughly an order of magnitude. I use map() and other functional primitives whenever I can, with anything small and with any code that do…
Also, are you using javascript native .map method ? IIRC libraries like lodash or ramda, through use of reducers, have vastly faster idiomatic FP performance. Mostly because they avoid successive array allocation.