3 ms·
I'm a PHP dev and I'm pretty happy with the language, especially some of the things introduced in recent versions. I think it's a fine choice for anything that
by AegirLeet 6y ago
I'm a PHP dev and I'm pretty happy with the language, especially some of the things introduced in recent versions. I think it's a fine choice for anything that doesn't fall in the "low-level, high-performance" or "mobile/desktop app" categories.
For web applications, I think PHP's idea of a clean slate for every request also makes a lot of sense and immensely simplifies development. I can write a simple PHP application that handles thousands of concurrent requests without even thinking about threading, synchronization, memory leaks or anything like that because handling that stuff is basically built-in.
PHP has a really good ecosystem. A framework like Laravel can do just about anything you'd need in an application out of the box. Routing, rendering HTML, generating URLs, handling sessions, logging, validating requests, an ORM, translations, encryption, sending emails, queues, schedules, caching - it's all there. I've never seen anything quite as fully-featured in any other language. On Packagist, I can find packages for pretty much anything from clients for obscure SOAP APIs to libraries for handling GraphQL. There's also a lot of great tooling, with a good package manager, static analysis tools like Psalm, code formatters etc. Also, PhpStorm is a fantastic IDE.
Outside of PHP, I mostly have experience with Java and JS.
If you know Java, modern PHP isn't all that different. Java has some nice stuff that I hope we'll get in PHP some day (generics is the big one). I built an application using the Play framework (Java version) a couple years ago and it was quite similar to modern PHP frameworks. However, there was always a bit more complexity with Java. Everything was just slightly more complicated. So with the trade-off basically being performance (which is better in Java) vs. ease of use and developer experience (which I think is better in PHP), I'd choose PHP most of the time.
Now, when comparing it to JS, I'm really glad I mostly get work with PHP instead of JS. I know this might sound strange coming from a PHP developer, but holy shit, JS is a mess. When writing JS, I'm constantly going between "oh, nice, this is really easy to do with Vue" and "what the fuck does that error even mean, how am I supposed to find any problem buried under several layers of bundlers, polyfills, loaders, transpilers and reactive frontend black magic?". If JS wasn't the only thing that works in a browser, I would avoid it like the plague.