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

It’s funny because when I think of “fractal of bad design”, Javascript is the first thing that comes to mind. I love Javascript but it makes me ask “why?” a lot.


PHP is kind of the same league, a lot of hate comes because some senior employee told a bunch of juniors after years of working in Wordpress that PHP is a garbage language and you should not touch it. "It's cool to hate PHP!"

PHP can make absolute garbage, and it can make a elegant product. Just like Javascript can. And same with Python and Ruby and what ever else everyone recommends.

It may be a lot harder to make garbage in Rust, but it's possible. PHP has a problem where it gets out of your way, gives you the entire toolbox to build a house. But the problem is which one of the 17 types of hammers do I use to hammer in one of the 104 different types of nails. Where as Ruby, gives you 3 hammers and 4 different nails, and 7 magic nails that appear after you're done hammering.


Php's inconsistencies in regards to needle vs haystack make me weep. Javascript doesn't have anything remotely like that.


I 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.


> 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.


If its powering 80% of the internet, 30% of all ecommerce websites, its not a mistake.


I 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.


I think you actually could fix this forward by using named arguments instead of positional ones?


JavaScript absolutely has things like that. Very famously so. https://www.youtube.com/watch?v=et8xNAc2ic8


Notice 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.


Laravel'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.


Just use typescript


No.




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

Search: