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

Isn't this asking for all the features that lead HN-readers to despise PHP?


There is a lot more wrong with PHP than these (anti-)features. It's loose comparisons for instance, with gems like 0 == "php" returning true, but 0 == "1" returning false [1] [4]

Having a function like nl2br [2], which converts newlines to br tags. The only reason this function would be useful is when you want text to HTML. The problem is, this requires a lot more than just replacing newlines with br tags.

A function like intval [3], which according to the documentation when passed a string "will most likely return 0".

And just about anything on http://www.phpwtf.org/

My main point is, that PHP is not broken because of these features. PHP is broken because the language has been hacked together from the start and there is no way to guess what built in functions will do if you haven't looked up the full documentation for them first.

[1]: http://www.decontextualize.com/wp-content/uploads/2010/01/ph...

[2]: http://php.net/manual/en/function.nl2br.php

[3]: http://php.net/manual/en/function.intval.php

[4]: http://i.imgur.com/pyDTn2i.png


All languages have odd quirks. One can cherry pick from any of them: https://www.destroyallsoftware.com/talks/wat


PHP is built on odd quirks. that's the difference.

It's only popular because it's easy to setup shared apache+php hosts and deploy scripts via FTP on it.


Yes, only ;)


...yes, but these are also the features that led people to use and keep on using PHP. one man's poison is another's drug of choice ;)

(to be honest I'd love to see PHP dead and buried, but there's still no other tool that fills its niche, and I hope that when one such tool gets developed, it's actually based on a sane programming language - PHP as a language means nothing, it was just "something" that grew organically into a language to fill an empty niche, and the only other alternative for this niche back then would've been Perl).


Heh, I spend about 80% of my working life writing PHP, I use it for some of them!


I think most people hate the language itself but recognise its strength of crazy-easy-to-get-started-with.


PHP has some ugliness, but in what way are any of these specific features bad?


"- I want the same language in my controllers, in my db code AND in my templates"

I read that as "let me mix them together like a PHP spaghetti app". The original poster may not have meant that, but after 13 years of writing PHP, the common complaint I still hear from newbies is "but structuring my code/using a framework has such a steep learning curve!". I'd rather like separation of concern enforced at the language level :)

And no, I don't have a clue how that'd work ;)


Their complaint is valid imho. They can use PHP to learn the basics of programming, and after this, as the next logical step, learn to structure their code. PHP is a bad language to get started with to learn programming for a number of different reasons (much worse than Python or Javascript), and this is why it would be cool to have the "PHP way" but based on a different language.

...now, I first learned coding by solving algorithmic math problems in C, but if someone would've tried to make me learn C++ or Java and OOP at that point I would've had the same complaint your newbies are having about "why learn so much just to 'structure' my code?!" :)


He didn't say implementing those functions in the same code, but using the "same language". To me, PHP's use in templates is pretty much its core idea. I think it's a good idea, and basically defines what a ruby/python version would be like.

Unfortunately it also makes possible the abuse you note - hopefully there's better solutions than requiring a different language in those 3 places.


Would love to know where the downvotes came from :)




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

Search: