Also, we're stuck with JS for the time being. PHP is easy to ditch by comparison.
Also, we're stuck with JS for the time being. PHP is easy to ditch by comparison.
It's really a hybrid language. You can do a lot functional stuff with it if you'd like. You can also do a lot of the OO thing with it. Neither is perfect, but if you stick to the "good parts", it's a strong language.
Closures in JS are broken due to everything being a reference cell by default. This causes closures to be annoying to construct correctly and more expensive than they should be. "Functional" languages typically treat mutation as a side-effect and require reference cells to be explicitly declared. This helps enforce function purity and referential transparency -- functional-ness.
"Being careful about recursion" is like being careful about looping except recursive expressions are a superset of succinct iterative expressions making Javascript weak when it comes to, say, describing state machines. Lack of TCO makes Javascript a terrible compile target as CPS is impossible.
Javascript is an ambiguous, unsafe, difficult-to-analyze language. It supports some constructs that look like constructs in functional languages but because it does not enforce any functional or type systemic restrictions, these features are mostly cargo.
If you write a recursive algorithm in Javascript, you pay like O(n) for stack frames. The same iterative algorithm costs O(1) for stack frames. Thus, many developers eschew recursion in favor of iteration. This means that the logical code that developers write could be both mathematically sound and run efficiently on the machine but instead developers must either resort to temporal reasoning or perform recursion -> iteration transforms in their heads. This is broken.
Just because Javascript is ubiquitous doesn't mean it's good. I don't understand Javascript evangelists -- they seem to be spreading half-truths.
There are good parts though, and if you stick with them, it's not bad. In fact, it can be a pleasant experience to work with. Just because it's ubiquitous doesn't mean it's all bad.
I like working with JS but I don't know why the two operands aren't commutative in my example.
The DOM is a headache but luckily smart people have made plenty of libraries to abstract that away. What we're left with is a language with a very expressive and powerful core like you said, but there are still some oddities.