3 ms·
I think of JS as being Scheme-like, but not because of any love for the language. Instead, whenever I'm using JS I take a Crockford-like approach by only using
by chriswarbo 9y ago
I think of JS as being Scheme-like, but not because of any love for the language. Instead, whenever I'm using JS I take a Crockford-like approach by only using a nice subset of the language: basically, closures and not much else.
When I'm writing JS in this way, my mental model is basically "a crappy Scheme", i.e. I'll tend to come up with implementations which are similar to what I'd do in Scheme (pure functions and closures), except I have to consciously avoid boilerplate (since there are no macros to tame it) and unbounded recursion (since there's no tail-call elimination), hence the "crappy".
Maybe it helps that none of my Scheme code has used continuations, outside of examples/playing, so there's less of a disconnect there?
- drablyechoes 9y agoHeh, I have been writing "crappy scheme" in Perl (and more recently JS) for years. Perl is actually kind of nice to use as a functional programming language, once you get used to thinking of it as such. "Higher Order Perl" is a great book and I still refer to it as a general reference for FP concepts and techniques.
- edem 9y agoI'd suggest using Kotlin then. It has tail call optimization, and nice functional programming constructs. It can also be compiled to javascript: http://the-cogitator.com/2018/04/25/going-beyond-android-kotlin-on-the-frontend.html http://the-cogitator.com/2018/04/25/going-beyond-android-kot...
- chriswarbo 9y ago> I'd suggest using Kotlin then I gave the caveat of "whenever I'm using JS" since I only use JS when I have to, and that's not very often (as I say, I don't have much love for the language). I think it's a bit inappropriate to throw out random suggestions like Kotlin when the discussion is about Javascript and Scheme. I spend most of my time in Haskell, which (like seemingly every language these days) can also be compiled to JS, and I'd wager is 'even more functional' than Kotlin. I didn't mention it because the discussion was about JS and Scheme ;)