I've started learning Scala. Don't know how far I'll get unless someone's willing to hire me to learn it (not impossible, I see a few jobs saying just that.) So far it at least seems like a nice blend of functional programming (ML type inference branch) and practical utility (JVM base, willingness to let you get dirty and imperative.) Though I'm also getting whiffs of C++ complexity... possibly unavoidable if going for that amount of flexibility in both coding style and performance.
It reminded me that I have trouble respecting a language that doesn't have first class functions, which got me wondering about the languages I know well.
C: no.
C++: no, directly, though you can make function objects with classes and operator(). Bit verbose, though. C++11 made improvements.
Java: I don't know, actually. Searching... looks like not really, though Java 8 made improvements.
Perl: Wikipedia says yes, though you hand around references to subroutines, and I found recently that nested functions aren't actually bound to their scope: function 1 defined in function 2 is still callable outside function 2. Wikipedia does say that nested named functions are in Perl 6, vs. the Perl 5 that AFAIK everyone still uses, if they use Perl at all.
Python: pretty much... but as Robbie and I found recently, Python doesn't do proper lexical scoping. And WP says it doesn't really do anonymous nested functions; Guido seems to have a reluctance to embrace FP. (Also see reduce being exiled to a functools library, not that Perl is better, to my surprise.)
So, wow, none of them.
Ruby I know basically nothing of, but WP says no. JavaScript I don't know enough of, though WP says yes. It also says mostly yes for Rust and Go. I'm sad D isn't on the table.
[Feb 2017 edit: JavaScript has better lambdas than Python, but has the same weird scoping problem.]
It reminded me that I have trouble respecting a language that doesn't have first class functions, which got me wondering about the languages I know well.
C: no.
C++: no, directly, though you can make function objects with classes and operator(). Bit verbose, though. C++11 made improvements.
Java: I don't know, actually. Searching... looks like not really, though Java 8 made improvements.
Perl: Wikipedia says yes, though you hand around references to subroutines, and I found recently that nested functions aren't actually bound to their scope: function 1 defined in function 2 is still callable outside function 2. Wikipedia does say that nested named functions are in Perl 6, vs. the Perl 5 that AFAIK everyone still uses, if they use Perl at all.
Python: pretty much... but as Robbie and I found recently, Python doesn't do proper lexical scoping. And WP says it doesn't really do anonymous nested functions; Guido seems to have a reluctance to embrace FP. (Also see reduce being exiled to a functools library, not that Perl is better, to my surprise.)
So, wow, none of them.
Ruby I know basically nothing of, but WP says no. JavaScript I don't know enough of, though WP says yes. It also says mostly yes for Rust and Go. I'm sad D isn't on the table.
[Feb 2017 edit: JavaScript has better lambdas than Python, but has the same weird scoping problem.]