4 ms·
Php's inconsistencies in regards to needle vs haystack make me weep. Javascript doesn't have anything remotely like that.
by azangru 4y ago
Php's inconsistencies in regards to needle vs haystack make me weep. Javascript doesn't have anything remotely like that.
- lordgroff 4y agoI hope you realize that "fixing" these types of early mistakes is almost impossible for PHP, a language which tries hard not to break things, especially something that's going to be used everywhere. But if this is such a deal-breaker and your IDE is dumb as a stump and can't remind you nothing prevents you from wrapping the stdlib or using something like psl to do it for you.
- azangru 4y ago> I hope you realize that "fixing" these types of early mistakes is almost impossible for PHP I do, yes; which means early mistakes stay in the language forever; same as in javascript. More's the pity.
- unity1001 4y agoIf its powering 80% of the internet, 30% of all ecommerce websites, its not a mistake.
- iLoveOncall 4y agoI think fixing as in "removing and replacing" is indeed impossible, but defining a new convention and making alternative names for the same function would work fine. Let's say the new convention is that functions are named str_*(), then keep strpos(), but create a new one called str_pos() that is the same, and mark the old one as deprecated (but don't remove it). I am sure there are edge cases where both str_* and str* exist already and do different things, but we can figure something out.
- dbbk 4y agoI think you actually could fix this forward by using named arguments instead of positional ones?
- ceejayoz 4y agoJavaScript absolutely has things like that. Very famously so. https://www.youtube.com/watch?v=et8xNAc2ic8 https://www.youtube.com/watch?v=et8xNAc2ic8
- azangru 4y agoNotice that lots of (probably most of; maybe even all) examples in the linked talk are due to unreasonable inputs. `true + true` doesn't make sense; `{}.toString().call(new Date())` or `+[] === +![]` don't make much sense either. This is just not what developers do. Meanwhile, iterating over arrays is absolutely what developers do, on an hourly basis. Which is why I said that javascript doesn't have things like that — the papercuts it inflicts on you hour after hour after hour.
- ceejayoz 4y agoLaravel's Collection class means I don't ever touch a raw array, and I've never had a "left-pad" scenario happen to me with PHP. Both languages have their warts; neither's tends to be an issue in actual practice with an IDE and experience.