Settings

Theme

Ask HN: What's your beef with PHP?

15 points by meneses 9 years ago · 24 comments


open-source-ux 9 years ago

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.

Avalaxy 9 years ago

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

neilsimp1 9 years ago

More than anything else, it's standard library.

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

  • mastazi 9 years ago

    Mmmmhhh most languages are, more than anything else, their own standard library ... Although there are languages with a very small standard library that are not "batteries included", but they are lower level so it's an apples to oranges comparison.

Xeoncross 9 years ago

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.

  • flukus 9 years ago

    What other languages are you familiar with to compare it too? Because Javascript is in no way well thought out and it doesn't do parallel computing let alone do it right, it's bound to a single core.

    • Xeoncross 9 years ago

      I didn't mean that javascript had parallel computing, but that it would get it. I know both PHP and Javascript will get it. Because they have the user-base, they will have the features. (Though I don't expect it until the end of EC6-7 and about PHP 10.)

      My languages mostly are C-based Bash, Python, Lua, Objective-c, Javascript (EC5), Go, etc...

    • dudux 9 years ago

      I wonder: What in JS ist not well thought. I don't like programming JS, but compared to PHP it has many neat features and ways to get things done. It's just different from other languages.

      Parallel works. You can even create a deadlock very easy. Also, Node.js can spawn new processes.

      • flukus 9 years ago

        Honestly, this has been done to death and it's pretty well accepted that it's not a great, or even good language, so I wont go over it again. It was a language designed in a few days to handle some basic client interactivity and it's good it that, it's just not good at anything more complicated than that, even despite the astronomical amount of effort people have put into working around it's warts.

        > Also, Node.js can spawn new processes.

        And yet it handles incoming requests on a single process.

iDemonix 9 years ago

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.

anamoulous 9 years ago

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

  • trebor 9 years ago

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

    While true, this is an apples to oranges comparison. Go libraries, bindings, and extensions are written in Go. PHP bindings and extensions are written in C.

    Writing a language extension or library binding in PHP requires an understanding of PHP internals and the C language. Compared to writing a binding or library in Go, this is difficult. It requires the knowledge of 2 languages (instead of 1) and an understanding of how PHP works "under the hood".

    However, I think that Zephyr shows promise. It's a high-level language designed for creating PHP extensions, without a direct understanding of PHP internals or C being required. https://zephir-lang.com/ (I just wish it didn't limit you to OO design/implementation.)

  • existcreate 9 years ago

    I've seen "flamework"-style code go horribly, undeniably bad. But if your goal is "simple and fast and damn the technical debt"-development then I have no qualms with anyone who does it.

codegeek 9 years ago

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.

smilesnd 9 years ago

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.

  • stevekemp 9 years ago

    I've actually configured my webservers to start firewalling hosts that make requests for /admin.php, /wordpress/wp-admin/blah.php, and any other request which is destined for a PHP-file.

    I don't use PHP, and these kind of bots are just too noisy to put up with.

taf2 9 years ago

I love PHP- it's a great get it done language. I think people just like to complain.

Bahamut 9 years ago

The one thing that has most frustrated me is PHP's array syntax.

  • stephenr 9 years ago

    Compared to what?

    • Bahamut 9 years ago

      Compared to almost any other language I've used - it's awkward, and unnecessarily verbose because it mixes in how one would define an associative array/hashmap/object as the only way to use an array. It does not distinguish a traditional list from an associative array.

      • mastazi 9 years ago

        > how one would define an associative array/hashmap/object as the only way to use an array.

        Well JS goes even further in relation to hashmap/object (e.g. you can iterate object properties as if the object was a relational array, because, well, in JS an object is an array). In PHP, on the other hand, you can't refer to $object['property']

        Hovever I have to agree with you when it comes to the overlapping between relational arrays vs "simple" arrays, the fact that all arrays are actually relational introduces weirdness, for example sometimes when you replace an array element you end up with elements that are not in the order you expect them to be.

      • stephenr 9 years ago

        But you specifically said its array syntax is annoying.

        What is "annoying" about:

            ["foo", $bar, BAZ, 1, 2, 3]
wazanator 9 years ago

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.

crispytx 9 years ago

PHP is the bomb.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection