4 ms·
"C and Perl and Python and PHP and Java and Javascript and so on, ... It feels like a categorically different problem to try to transition a team from one of th
by grannyg00se 14y ago
"C and Perl and Python and PHP and Java and Javascript and so on, ... It feels like a categorically different problem to try to transition a team from one of those to a functional language."
I just have to throw a flag here and point out that Javascript is also a functional language. With Javascript you can declare functions as variables, pass functions as arguments to other functions, return functions as the result of other functions, and use them as part of a data structure. Javascript is much closer to Scheme than it is to a C paradigm.
- silentbicycle 14y agoWell, you can pass around function pointers, return function pointers, and store function pointers in data structures in C, too. You can also use closures - a closure is just a (function pointer, struct with its closure values) struct. Sure, OCaml, Scheme, and company box the pair for you, garbage collect it, and don't make you flatten your code into a single file-level scope, but the difference between Javascript and C isn't as big as you think. Javascript is kinda sorta maybe functional if you look at it right, but it's still mostly the same imperative/object-oriented mishmash as Java, Python, or Ruby.
- abecedarius 14y agoBeing able to nest first-class functions without manual closure-conversion / lambda-lifting makes a big difference for the feel of a language, to me. (Java is sort of in between -- it technically has that feature but with verbosity getting seriously in the way of using it.)
- silentbicycle 14y agoIndeed. I'd certainly rather be able to nest functions, but C became a lot more powerful to me after I learned how to compile a bunch of high-level features to it. (Your 'ichbins' helped, by the way. That, LiSP, and some SML papers.) I'd still rather automate much of the heavy lifting, of course. I'm weirded out by the idea of writing CPS-transformed code by hand for node.js, but apparently people like it? Perhaps it's something similar.
- abecedarius 14y agoThe thing I don't get about node.js is that it used to have a promise abstraction and they dropped it to go callback-only. I guess the abstraction leaked, in a language not built around it? I like to imagine Node's success comes from bringing some of E's insights to a community just ready to use them, and if the cost is manual CPS, apparently it's not too high. (Relevant E theory at http://erights.org/elib/concurrency/overview.html http://erights.org/elib/concurrency/overview.html )
- rblackwater 14y agoNo, Javascript is imperative with first-class functions.
- lclarkmichalek 14y agoThere is a distinct difference between languages designed around the functional paradigm (Haskell, lisps etc), and languages that support the functional paradigm (python, javascript etc). Most javascript code is imperative, not functional, and it would be disingenuous to say that there is not a difference in the way of thinking when writing in lisp, and when writing in javascript.
- qxcv 14y ago> With Javascript you can declare functions as variables, pass functions as arguments to other functions, return functions as the result of other functions, and use them as part of a data structure. I'm pretty sure you can do all of those things with function pointers in C. void (*func)(void), for example.
- gizzlon 14y ago"With Javascript you can declare functions as variables, pass functions as arguments to other functions, return functions as the result of other functions, and use them as part of a data structure. " Yup, in Perl as well..