But since then, and with the release of PHP 7, the language and ecosystem has matured massively. For one, Laravel is excellent - the framework is well designed, the docs are some of the best I've ever worked with, and the developer tooling is (in my opinion) unrivalled.
I work mostly on Node / Java back ends professionally these days, but I find myself almost exclusively using Laravel for my personal projects. THe reason being I'm so much more productive in PHP & Laravel compared to Java. And don't get me wrong, Java is great for building enterprise software, but for small to medium sized web projects it's overkill.
I also have PHP projects which I built well over a decade ago that run perfectly fine today. Meanwhile in Node land it's not uncommon for projects just a few years old to stop working altogether because some package I was using is no longer maintained and hasn't been updated to support the latest version of node. And even when the project still runs the ecosystem tends to change so much that you have to do significant refactors every few months just to keep everything reasonably up-to-date. I think any JS developer can relate to the fact that a good chunk of your time working on JS projects is spent refactoring code because Gulp is no longer being maintained, or LibSass has been deprecated in favour of Dart, or because the community just decided that you need to use React hooks now...
But another reason I don't use Node is simply because JS sucks, even when compared to PHP < 7. It's a poorly designed language that requires multiple layers of tooling just to make it acceptable for use in larger projects. And again, when the ecosystem is changing so often any tooling you're using needs to be updated constantly.
But this isn't a rant about JS. I'm just wondering why in 2023 I seem to love PHP more than ever and the developer community broadly seems to be migrating more towards Node? Can someone explain why I'm wrong about this because when ever I tell any of my Java / Node colleagues that I love PHP they tend to roll their eyes.
Most people in this industry are either junior devs that have no idea what they're doing, mid level devs that fall for the hype and don't like "boring" tech (battle tested, reliable) and end up using stuff that's not even production ready, and senior devs that overengineer and optimize prematurely.
Just keep on your path and don't pay attention to the dummies. PHP is great and will never die.
React, Typescript, and isomorphic/universal JS.
The reasons for React's dominance is a separate topic, but if you're working with react, node becomes a natural fit for the backed because you can render the same components on the server or the client.
Again, the reason for TypeScript's success is a separate topic, but node is the go-to backed if you intend to build with typescript. All things being equal in the interpreted scripting language world, typescript's type system sets it far ahead of php/python/ruby.
Being able to build with one language for both front-end and back-end is a nice perk, but being able to reuse business logic in both environments is massive. e.g. sharing object structure types and interfaces between environments ensures API ingress and egress remain consistent, the same code used to validate form inputs on the front-end can also be leveraged to produce API validations on the backend and many other use-cases.
One runner-up reason: npm. Yes, npm has had a reputational hit due to some excesses of the ecosystem in years passed, but at the time when node was picking up steam, the php composer experience was terrible, whereas npm set the standard for stupid easy package management... yes, it came at the cost of a 2gb node_modules dir but this is (mostly) a developer vanity problem rather than an actual problem (unlike resolving composer dependency quagmires)
> But another reason I don't use Node is simply because JS sucks, even when compared to PHP < 7. It's a poorly designed language that requires multiple layers of tooling just to make it acceptable for use in larger projects
Any specifics? The reality is that PHP and JS are both wart-filled messes, I certainly don't see any substantive justification for the idea that node is worse than PHP.
So when I ask myself “how much do I trust complete strangers on the internet?” the answer is “not much, but even less than that if it’s written in PHP.”
People will continue to roll their eyes. Whether deserved is besides the point. I was no longer interested in being a 'PHP programmer' and have to justify my worth. PHP is by all measures on it's way out. If you are looking at other ecosystems of course you're going to find things that aren't great. PHP has those too but in the 15 years you've been doing it you've created habits that perfectly avoid those. You're not going to attain those same skills immediately elsewhere, and the things that are worse from your perspective are going to stand out more than the things that are better.
You've tied your professional identity to a programming language that people dislike. It's not a fun place to be, but trust me you'll be better off in the long run. This has NOTHING to do with language features, and everything with your feelings and bitterness. Your post is full of emotions. It's not worth feeling this way, it's just a programming language.
On a more serious note, i've been thinking recently that the more experienced you become with programming, the more you will thirst for functional programming or something close to it. I think that we see this with the maturation of the modern JS ecosystem too - with a trend towards thinking functionally, rendering functional components, limiting side effects, top-down data flow etc. PHP is not the easiest place to do functional programming. PHP is also not a glamorous place to be. Laravel is cool, but you are still gonna want something like React or Vue if you are building a modern front-end so why not go all-in on JS? I am not arguing for this - but I can see the argument being made by the community at large so I am not surprised to see PHP devs moving into JS.
You are in like the 1% - the mythical PHP hacker who loves the language. You will live a lonely life in your mystical PHP dragon cave high upon the on the hillside of Mount Lerdorf. This is the life you must be prepared for.
There was a point where colleges were only teaching Node, as JS was very fashionable. I've reeived applications where the answer to languages known are: Javascript, TypeScript, React, C++.
But, anecdotally, we moved one server to Node during the hype cycle, and that taught us enough to not repeat the mistake.
Others in the industry I have contact with (admittedly somewhat of a self-reinforcing circle) feel the same way.
Unfortunately, it is harder to find a good PHP dev.
EDIT: Actually, in my experience, the pool of PHP devs is smaller, but the average quality is higher.
To be honest, I find it hard to justify using anything BUT TypeScript these days.
You're not wrong so much as out of fashion.
It's very important to recognize how much industry trends are driven by fashion. But being fashionable also makes an ecosystem good. Well, at least makes it better. For certain definitions of better. Lots of development attention that means there's probably a highly visible project building exactly the bells and whistles that will garner praise and more attention for the ecosystem.
You can make your slow, measured, careful decisions about tech to use. But webdev is full of YOLO projects too. Churn and fashion are always going to be at your door.
Full stack typescript for me is SO much nicer. Occasionally there's code-reuse but more often it's interface reuse for type-safety and autocompletions. This yields a lot of correctness/safety in a large project.
No context or tooling switching.
The thing is, most of this tooling isn’t even related to the language itself. In NodeJS, you need basically none of your the tooling. Here are reasons why tooling is used:
- Webpack. Files need to be minified because code is downloaded nearly every time you access a website. (Not a language problem.) This also leads to a whole other class of optimizations like dead code elimination.
- Babel. Can’t guarantee client-side runtime layer, so need to make sure new syntax is transpiled. Not a language problem.
- Eslint. Ideally you’d use a linter in any server-side project, like PHPCS for PHP.
- Typescript. This is a language problem. :p At least PHP has some types now!
On Node, you don’t need webpack or babel or any similar set of tools, because Node can resolve imports and you know which Node version you support. Other tooling, like dependency management and linting, would be normal in other languages too.
On the client, you need a huge set of tools just to deal with the fact that your software is literally downloaded over the internet as part of the startup process. That comes with a huge set of performance optimizations related to bundle size that other languages simply don’t need to care about. That’s why there’s so much extra tooling in the JS ecosystem.
To call Javascript "poorly designed" when having a discussion about PHP is… a bit jarring… Both PHP 7/8 and Typescript are huge improvements over their forbearers, but it seems indisputable to me that fundamental Javascript is at least a better-designed language than fundamental PHP (circa v3), and contemporary Typescript is better-designed than modern PHP.
(creds: I've been writing PHP and Javascript since around 1997)
If you look at PHP vs Node in Google Trends, you can see the PHP decline was well on its way before Node.js came on the scene in 2009.
I used to love PHP, but these days JS is good enough that I don't feel the need to look back. My personal JS projects still look PHP-ish in the sense that they're very simplistic, often lacking a build step and often even lacking a framework. I do like having more control over the server logic than what I remember having with PHP (granted this was the days of WAMP and LAMP, and I hear with docker and nginx things are nicer now). I also like the fact that I can go to a single place (npmjs) for both my browser-side and server-side libs because sometimes I haven't decided yet where it'll reside.
How did you came to this conclusion? I work with PHP teams daily and they don't think about moving, but even if they did I wouldn't expect them to seriously consider node. Overall I would say that in the last few years there was increase in number of competent PHP developers.
TypeScript, ignoring about half the language features many of which are "oh my god please never actually use this" (e.g. all the distinctive features of prototypal OO), and finally being able to concisely tell the language to please let you treat async calls the way everyone's always wanted to be able to treat them 90% of the time for the entire existence of JavaScript and Node (async/await) has made the language downright tolerable.
The culture and ecosystem still blows, though, you're not wrong there.
Perl & PHP were two examples of languages that were particularly bad fits for their use cases – poor performance, buggy syntax that led to lots of runtime bugs – both were very successful for a time.
To answer your question: Node meets the above qualities reasonably well. It also is ambiguous enough to allow lots of navel-gazing over academic tangential topics so people can avoid actually getting work done and waste a lot of wall & CPU time doing so.
1. The TypeScript tooling with Node has improved tremendously. Frameworks like Nest make it simple to work with it.
2. There are some really good frameworks that, over the years, have remained simple and just work. Example - Express, Sequelize, etc.
3. Same developer can make changes on both the frontend and backend since the language on both sides is TypeScript now. That simplifies building features as less coordination is required for full feature development.
4. Deploying Node apps is overall simpler. Be it VMs, containers, or serverless. Horizontal scaling is cheap, and most applications don't need much processing optimizations there.
- PHP's capability is limited in a sense that its main use case is akin to a template engine rather than a full fletched executable. This puts a lot of limit in PHP
- TS steps up JS' game. Like what other have said, TS brings the hassle of maintaining complex codebase down quite a lot.
- NodeJS is a stepping stone for many frontend developers to learn backend because of the same language used.
- JS' syntax and capabilities, while having inherent unavoidable footguns, allow expressive code (I might be partial on this, the last time I used php is a long time ago)
Edit: formatting
* The memory is fuzzy what the comparator was, the point stands