from Hacker News

Ask HN: What's your beef with PHP?

by meneses on 2/13/17, 10:05 AM with 24 comments

  • by open-source-ux on 2/13/17, 1:37 PM

    I don't have any beef with PHP, although I switched from learning PHP to Python.

    For web development, no other language will get you producing dynamic websites and deploying them as easily as PHP. Compare deployment of Python or Ruby web apps - messier and not simple.

    What don't I like about PHP? The language itself. Its piecemeal, adhoc development is laid bare in its unattractive syntax (this is always subjective I know).

    On the positive side, my impression is that the PHP community are open to criticism - they have to be given the amount of negative comments thrown their way.

    This is in contrast to other language communities that have far too much zeal and sensitivity to criticism.

    That criticism against PHP is also taken on board at times in the implementation of PHP's language features or best practices. I've been impressed by PHP's huge speed up in PHP 7. I wish other scripting languages would also address speed and memory usage with the same priority.

    Finally, it's worth stating the obvious: if you're looking for a CMS, a message board, a blogging platform etc, PHP gives you enormous choice. And yes, some of these solutions do follow modern, secure coding practices. Look at the other popular scripting languages for web development and you'll find the variety of solutions far more spartan.

  • by Avalaxy on 2/13/17, 2:09 PM

    I haven't done any PHP scripting for at least 6 years, but my beef was mostly with the community, not the language. If you do your best, you can write decent and clean code in PHP. But the community largely exists of people who don't have the slightest clue what they're doing and who are writing absolute garbage pieces of code. Usually when there's a data leak on a website, it's the result of insecure PHP scripts (again, the language has ways to prevent this, but the scripters just suck).
  • by neilsimp1 on 2/13/17, 1:02 PM

    More than anything else, it's standard library.

    https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/#...

  • by Xeoncross on 2/13/17, 7:05 PM

    I've been writing PHP for over 10 years.

    1) PHP is slow, uses too much memory. (I wrote the MicroMVC framework and IOSQL)

    2) Makes concurrent (and especially parallel) computing hard (file locking and pcntl_fork())

    3) PHP isn't well though-out (like Javascript) so you are always second-guessing the std lib because of odd/short-sighted design choices.

    I moved to Go and lost nothing.

    However, PHP is (like Javascript) improving and will probably eventually (like Javascript) get parallel computing right.

    Where the users are the features are. That is why PHP, Java, and Javascript aren't going anywhere fast.

  • by iDemonix on 2/13/17, 3:29 PM

    I don't have any, it's great, depending on your use case. I think it's because I learnt it growing up (age 14 onwards) that I always fall back to it as my 'natural' coding language.

    If someone gives me a big file of text to parse through, even though I know Python, can use Perl and BASH, I'll likely still use PHP if it's a one-time thing (sometimes even if it isn't). Why? Because within 5 minutes, I can have a script that reads a file from anywhere, parses it line by line and does any number of interpretation. No worrying about casting strings to integers, no worries about general syntax or indenting (Ok, this is a benefit of Python, but if you just need to do something on the fly, PHP!).

    IMO PHP is very easy to use, very easy to learn and can do almost anything - good and bad. Good because you can use it to solve tons of problems, bad because everyone learns it early on, or as their first language (like me), and therefore most people aren't great at it, the community gets worse.

  • by anamoulous on 2/14/17, 2:03 PM

    If you embrace what PHP is good at, which to me is fast, easy to understand code that is dispatched once per web request in a shared nothing state, PHP is great. When you have to deal with PEAA style PHP, things start to go off the rails in both speed and simplicity.

    I happen to like PHP's standard lib: it's big and addresses a lot of needs in building web apps. But you don't really see tons of new high quality bindings or libraries being introduced at the rate that, say, Go is getting them.

    If someone told me I had to build a product from scratch in PHP, I would probably start here: https://github.com/exflickr/flamework/blob/master/docs/philo...

  • by codegeek on 2/13/17, 4:35 PM

    I don't have any beef with PHP. It pays for my current living so I don't complain. PHP 7 has been a great improvement over the previous versions so that helps as well. At the end of the day, it is just another tool.

    Best thing about PHP applications is that even my grandmother can deploy it. Yes, that can be bad or good depending on where you are looking from.

    Add frameworks like Laravel and you can create some serious prototypes in no time. That's what I care about to get something out of the door.

  • by smilesnd on 2/14/17, 11:12 AM

    My beef with PHP is all the added traffic I get on my http server. Every day I get a list php directories get request from people looking to score on some low hanging miss configured lamp box. Then on the flip side the people that do have php files miss configure they get turn into DDoS boxes against me.
  • by taf2 on 2/14/17, 1:35 PM

    I love PHP- it's a great get it done language. I think people just like to complain.
  • by Bahamut on 2/14/17, 6:10 AM

    The one thing that has most frustrated me is PHP's array syntax.
  • by wazanator on 2/13/17, 6:26 PM

    No problem with the language itself more of a problem with the people who use it and their compulsion to use it for things that don't need it.

    For example it feels like we can't go a year without WordPress making the news for a security flaw.

  • by crispytx on 2/13/17, 1:45 PM

    PHP is the bomb.