I'm not aware of any other language that makes it so easy to write your code in either a functional or object oriented style. It doesn't do either perfectly, but it gets you a good 85% of the way there for both. Good enough that advocates of a particular style are able to write and enjoy writing JavaScript. I can't think of any other language that has that level of flexibility. Can you?
>I'm not aware of any other language that makes it so easy to write your code in either a functional or object oriented style
>I can't think of any other language that has that level of flexibility. Can you?
(Subjective opinion here)- I think Lua got it better; you can create a better object oriented program with it, as you can do it with functional style; Ending with a more elegant final source code down the road
Yeah, agree Lua did get it better. JavaScript is very much inspired by Lua, but has the disadvantage of having more "cooks in the kitchen" wanting to mess with it.
I disagree strongly w.r.t. Python as anonymous lambdas are heavily restricted there. I disagree less strongly but also somewhat insistently about Ruby where the distinction between methods and functions is warranted but thus involves more overhead.
JavaScript is hospitable enough that you see entire applications written in a functional style. Where is the Python and Ruby applications written mostly in a functional style? I've never seen any.
I've yet to see entire JavaScript applications written in a functional style. Just because "map" is used more often than Python doesn't make it functional.
> Better at being both a functional and object oriented language?
Well that's both subjective and ambiguous (subjective in the evaluation of quality in each area, and ambiguous because the meaning of "better at a and b" can be interpreted in a number of ways, such as max by min(a,b), max by average(a,b), etc.
But, given that, I'd say that several of the listed languages are better at "being both a functional and object oriented language" than JavaScript, including Scala and Ruby.
All over. Various functional approaches are basic core Ruby programming techniques.
Its not a great FP language because it lacks functional purity (like most Lisps, and, more to the immediate point, like JS) and the main Ruby implementations lack TCO (as, again, do many Lisps and, again, JS.)
But there's certainly a lot Ruby code using functional style.
I didn't ask which are "better", I asked which are better at being both functional and object oriented at the same time. I can accept Lua, but the others I really need a good argument for.
They are all better at both than JavaScript. There is no feature that JavaScript has that the other languages don't, often in very similar shapes. The reverse is mostly not true.