Oddbean new post about | logout
 PHP, IMO has some advantages over JavaScript (and a lot of the other more popular languages).

The benefit that PHP has is that it is pretty simple to deploy. Copy it into a folder usually and maybe a few lines of config in Apache / Nginx, and you are up and running.

Most modern JS/TS usually needs npm. I am pretty decent with build systems and NPM, and I hate dealing with it. You don't need any of that with PHP. Even if you use composer (the npm equivalent), it is a lot more sensible.

Dealing with Requests/Responses is super straightforward.

IIRC it has things like type hints now. You have a decent-ish OOP system. First-class functions etc.

Also, the language/runtime has improved a lot in the last 10 years.

People write it off. But PHP isn't a bad choice in some circumstances. 
 The main advantage of JavaScript is that it's the most widely used programming language on the planet. If it exists, it has been implemented in JavaScript.

That doesn't mean it's a perfect language. Most widely used things aren't the best in their class. But it means you're maximizing the potential. It's easier for people to contribute code, to hire people, to reuse code. JavaScript is the English of programming languages - if it's not your first language, it's your second.

And it's good enough to power Netflix. 
 i was going to type this out but i got sidetracked by some schizo on SPC trying to aha!snafu me into something I had no part of 
 I won’t deny it is widespread, and I won’t deny that you need to know it. I’ve made a decent living from being reasonably good at JavaScript/Typescript in the browser. I am one of those weirdos who can write fast JS that will work in ancient browsers still in Vanilla JS.

However, the last time I checked, a huge chunk of the web was still powered by PHP.

However, that is in the browser. You are almost always writing JavaScript, or something is getting compiled into JavaScript. 

The issue is that there are better options on the server. 

Suppose I were to choose something for a non-trivial project. I wouldn’t choose JS or PHP. e.g. I could write something in Go or C# tomorrow with good performance and the advantages of static typing.

And it’s good enough to power Netflix.

I am not fond of this argument because:

PHP still powers Facebook, last I checked. So you could make the same argument about PHP.
The needs of these large corps are not the same as you or I. Netflix can throw hundreds of programmers at a problem. A small business can’t do that. I’ve worked in big corporations that make billions, and their business-critical code was crap. They solved it by hiring many people and constantly putting out fires. 
 Deno is a lot better than Node.js because it has no build system, it "just works". But you still have to know about Linux and the terminal to use it, so no matter how much better they make it, the deployment method alone rules out a lot of PHP users. I agree there's still an audience for PHP. Facebook using it is a fluke though, and they wrote their own version of it (Hack) to work around it. Still, I concede that PHP can scale, especially with php-fpm. 
 @misterjesus @Alex Gleason @anime graf mays 🛰️🪐 I dont think thats an A-B comparason.


You can 100% build Javascript that doesnt require npm. You probably don't want to do that unless you are doing something VERY basic

The same is true with PHP. At some level of complexity, you are going to need to use externally written code. PHP SUCKS for this. The best solution i found was using composer, which is infinitely more shit than npm

I would go as far as to say, PHP doesn't really have a good niche atm other than being quick and dirty 
 How is composer "infinitely more shit" than npm? I've had more issues with npm than composer. I've had more issues with third-party npm packages than anything from PHP land. Though I was using smaller libraries like Flight.

Also, a lot of third-party libraries can be used without composer. IIRC I can just vendor a directory and use autoload. 
 @misterjesus @Alex Gleason @anime graf mays 🛰️🪐 The number of times composer would fail silently astounds me. npm is pretty obvious if something goes wrong, and it typically only goes wrong when youre doing something you shouldnt be doing (100x more eyes looking at npm makes it less buggy imo) 
 I've had odd problems with NPM as well. I'm not too fond of dependency systems in general. 
 @misterjesus @Alex Gleason @anime graf mays 🛰️🪐 I guess i tend to work on projects large enough where we need to use them. Im not managing that many libs manually 
 

I guess i tend to work on projects large enough where we need to use them

I’ve worked on some very large projects (100,000s of lines of code), and we didn’t have them. We had a DLL folder (this was old school .NET Framework). It worked fine.

You don’t have people doing dumb stuff like importing a whole library for a trivial piece of code.

I try to avoid libraries these days unless it is worth using them.

 Im not managing that many libs manually

I suppose you haven’t been burned enough by dependency hell yet.

EDIT: BTW, I am not saying you should or shouldn’t use them. I am just saying that there are drawbacks to using dependency management systems. 
 @misterjesus @Alex Gleason @anime graf mays 🛰️🪐 Im not about to impliment object factories in C++ from scratch... Im going to use com

Not gonna whinge about who has the bigger cock. I just don't think this is gonna be a constructive conversation in general 
 @LESS THAN 200 DAYS UNTIL CHRISTMAS @Alex Gleason @anime graf mays 🛰️🪐 @misterjesus npm creates node_modules with  20000 files in it when you install one little thing