Hacker News new | ask | show | jobs
by osrec 1670 days ago
It's so nice to see a comment giving PHP the praise it deserves. Honestly, PHP is a good, if not great, language to use for building solid web apps fast.

People seem to love to hate it because it's the "cool" thing to do. Yet PHP developers continue to ship things faster, while JS devs are probably still fiddling with their Node environment setup...

3 comments

> People seem to love to hate it because it's the "cool" thing to do.

While I agree with this, I think the tone is slightly dismissive. From what I have seen, older people in our trade seem to recommend against PHP due to it having a terrible relationship with consistency, functionality, performance, etc. in its history. Though I have (thankfully) seen that the language and its standard library has undergone several large improvements, which is great to hear.

> Yet PHP developers continue to ship things faster, while JS devs are probably still fiddling with their Node environment setup...

On your point of JavaScript, the build environment nonsense can definitely get hairy. It's why we get things like Deno, which attempt to throw all this cruft away and start again. And sometimes that's a good idea. If you're dedicated to Node, replacing Webpack with Rollup seems to be what is generally recommended. The only obvious disadvantage there is compatibility with Webpack plugins.

It would be nice to have a type-checked JavaScript variant with a practically non-existent build environment (no Webpack, Rollup, etc.) As much as I adore TypeScript, the compiler itself is massive and takes quite a long time to even start.

> From what I have seen, older people in our trade seem to recommend against PHP due to it having a terrible relationship with consistency, functionality, performance,

As an older person in the trade, I don't agree with the other older persons. Only consistency is a problem with PHP code, and that is largely NOT caused by PHP. Inconsistency is the product of developers coding without any real thought about how to abstract things (ok, well, maybe not in the case of magic strings). You can do this with every language. Some languages do everything possible to force consistency, and developer still find a way to be delightfully inconsistent even with the syntactic equivilent of bowling gutter bumpers (see Cobol, Go, Java). Consistency is a developer problem. You can write great code in languages that are terrible.

PHP has never been slow (compared to other dynamic languages), or lacked functionality. If there is a rub on PHP it comes from no separation of code and presentation, which flew in the face of the MVC pattern which was THE WAY for a very long time. Now... well, JSX much? Anyhow, my team works with Go, JS, PHP and Python, and the code that takes the least effort to both extend and maintain is... the PHP.

I am honestly and truly trying my absolute best, but no matter how hard I try, I again and again completely fail to sufficiently and comprehensively put into meaningful words how the inconsistency of the PHP language doesn’t play a role AT ALL when building actual web applications for actual users.

It just. Doesn’t. Matter. Choose Symfony or Laravel, and you are in for a wonderful development experience, from setup to dependency management to architecture to implementation to testing to deployment – for certain kinds of projects it’s just perfect.

I agree with you, and it's super hard to explain. But if you have the right type of project requirements, Laravel is unbelievably great to work with. I love other languages more than PHP, but for a real world, client facing project that I want to be mostly hands off, Laravel would get my vote 9/10 times.
I think you've sufficiently and comprehensively put it into meaningful words above!

The truth is, those who care to use the language properly know this already. Those who wish to dismiss it always will, and this happens to be an easy angle of attack.

> It's why we get things like Deno, which attempt to throw all this cruft away and start again

Doubt. Your "something@v1.2.3" in Deno is no different than "something": "^1.2.3" in npm. The problems will appear when you update stuff.

The only thing benefiting deno currently is the clean slate and the lack of hacks (for now).

They are different, currently no Deno registries have dynamic version resolution (no greater than operator). Once you have locked in on a version you are in it for good unless you change it manually

However if the argument is: updating libraries break stuff, that is gonna happen every time in every language. There is no guarantee the next version will just work as the last one did

Not only shipping things faster but testing faster, scaffolding faster, debugging faster ... the tooling for PHP is much more mature than it was 6-years ago and there are so many GOOD packages out there that haven't been forked and copied 20x over.

Really happy to be working with it again, even if on the side for now.

I agree.

Developer speed does not get enough coverage when comparing languages.

When I work with a Node project it's such a slow dragging build process.

Using PHP is like a fun superpower that lets me turn out things on timescales that are borderline miraculous to clients and management.

Hiring developers is rarely considered as well.

I can hire a top-notch PHP engineer for half of what a mid-level JS engineer would be asking.

It's not that PHP engineers are less qualified than JS. I think bootcamps shifted the market for JS developers and now really good engineers cost an arm and a leg while good junior engineers start around the $100k mark. The whole JS salary market is insane and as a startup, I can't afford it right now.

I think it’s interesting to me, as I see these comments a lot with PHP specifically and there is at any honest pushback on this, so here’s my attempt:

Just pay what good engineers should be paid. If there are PHP developers out there not getting the same salary as a their peers like this post mentions, you should leave that job for a better one. Please demand better, PHP developers, for all of our sakes. Business always wants to put downward pressure on salary and we need to be united against this regardless of preferred tech stacks

I agree but I'll counterpoint for just a moment. A lot of mature PHP engineers seem to be from Europe, or rather non-American. I'm often finding it's American salaries that are crazyyyy high, but factor in that health insurance isn't spectacular here it might all balance out.

I've run no numbers, I have nothing but infrences to base this on, but hiring a mature PHP engineer in Europe would 100% be cheaper in the long run than hiring a junior/mid-level JS engineer anywhere else.

There's an interesting comment/quote on an Hacker News post about Perl's "Laziness Impatience Hubris" mantra that I think of when people talk about developer speed.

https://news.ycombinator.com/item?id=23826828

This might be true for the web but for CLI apps etc I don't think this holds the case.

It’s exactly 180 degrees for me. Node js just seems to be super fast. And with typescript its heavenly.

I don't make a website and working on node js is fun. In PHP it is like doing something esoteric. Just a simple argument parsing is so hard in php compared to node js. In nodejs I use meow and even without docs, I can parse cli easily. In fact, I think Rust can be more easier than PHP in many cases. I usually rewrite in rust for long term daemons. Also in php I need to install php I don't know why I should install php-pdo etc. I mean why not just allow composer etc to handle like just like node do? I am frustrated with php stdlib which seems to be fossil at the moment.

The thing I like about PHP is laravel framework where I can set up websites instantly. Node js is fragmented with adonis and many other micro-framework.

Stuff like argument parsing is left to frameworks. Laravel’s Artisan command system has all sorts of built-in functionality for exactly that.
I don't want to install Laravel for cli apps. For that most devs use symphony

https://symfony.com/doc/current/console/input.html

Installing laravel for cli is like buying thread ripper to run minesweeper.

Use whatever framework you like; the point is PHP leaves it largely up to them.
Anecdotal - my experience is the opposite. I have two large PHP side projects currently (vanilla and Drupal) and I find working with PHP and Composer to be a much slower experience overall than my day job developing with TypeScript/Node and JavaScript/React.
I would guess that a lot of the slowness is not from PHP itself, but the way your specific projects are using it. With the vanilla PHP project, the slow down may be caused by poor design decisions from other developers.

With Drupal, the code quality of the core is generally okay, however the added inertia may come from a "square peg, round hole" situation, where the CMS is being used for an obscure purpose for which it wasn't really designed. This is quite common in the wild, probably due to the low barrier to entry and the fact that people will use what they are comfortable with to solve every problem under the sun (not dissimilar to the prevalence of Excel throughout the world of finance for a variety of completely inappropriate use cases).

Much more than most other languages, PHP is purpose-built for serving web requests.

For example, PHP could get along without async/await and promises in a lot of situations, because threading was effectively subcontracted to the underlying web-server. You could just treat, say, a curl call as blocking-- resulting in a simpler code flow-- knowing that wouldn't lock your entire web server.