Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I actually think the opposite is the case. let is nice, but javascript has no typing whatsoever. The PHP type system isn't perfect (with a lack of generics being the biggest pain point), but in javascript you just have to annotate and pray (or use typescript and compile it back to javascript, hoping people interface with your code correctly). And PHP has a dedicated string concatenation operator, which has helped it avoid horrors like '2' + 2 = 22 that javascript has to offer. Javascript will just straight up let you add properties to any object on purpose or by accident, which is useful for polyfills but also fucking horrible for bug avoidance and an invitation for less restrained individuals to make true abominations.


All of those things I see as productivity issues, not language fundamentals. TypeScript solves types in JS for me the way Laravel solves superglobals in PHP.

Adding properties to an object is fine IMO. Arbitrary properties and prototypes are, to me, a much cleaner system than PHP's somewhat confused mix of array, object and class. The lower you go in JS the more unity of concepts there is, whereas the lower you go in PHP the more hacks you discover.

All of the above said, I would prefer a string concatenation operator to overloading +. JS template literals mostly solve that for me in practise. And what I really actually want is an equivalent of Haskell's <> or mconcat, which concatenates anything monoidal - strings, lists, etc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: