Hacker News new | ask | show | jobs
by vorpalhex 2954 days ago
> i don't understand all this animosity toward PHP

Most PHP code is terrible. That's not really PHPs fault - it's capable of producing very nice programs with beautiful behavior.

As a language, it suffers a bit from being older and it was internally very inconsistent for a long time. For a long while, it's package management and practices were way behind the curve. Many people who program in PHP learned it as a first language, hacked together programs in it, and probably used hack together libraries and tooling.

PHP can be used with grace, but most people don't have that experience with it.

2 comments

> Many people who program in PHP learned it as a first language, hacked together programs in it, and probably used hack together libraries and tooling.

This describes me very well, and i don't think i'm alone. When i look back at my(very early, first language) PHP code it looks horrible. A lot of it is just copy pasted code from random websites telling me that that it does what i wanted it to. Which is a pretty good description of me at a young age trying/learning to program by internet. I don't use PHP today, and i really don't want to, but i suspect that is in some part due to me struggling with stuff i never understood when i was doing it and developing a distaste for it looking back at my bad code from that time without realizing it could be done differently/in a way fairly close to what i do in my current work-language. I just wanted to make my WoW dkp page work and searched the internet when wondering how to and ended up writing really bad code. It still worked pretty good and i had fun doing it but i never considered writing PHP again once i moved on.

For what use case is PHP better than other languages?
Rapid development of performant get/post web interfaces. Ruby is nice but runs a lot slower. Python is better in a general-purpose sense, but every file will have a preamble of includes for things that are just built-in to PHP.

As a general purpose language, PHP is weak. As a web-form DSL, it's great!