News for hackers. Stuff that matters.
Re:PHP Popularity: Is it decreasing and what to do about it? by themodelplumber on Friday April 21, 2023 @04:54PM (#35659963)
What's the JS equivalent of "place an index.php file in a folder to deploy"?

What's the JS FOSS equivalent of ProcessWire as a CMF + CMS?

What's the JS equivalent to e.g. DreamHost and other drag + drop hosts?

(Legitimately curious, and I'm mainly inquiring after equivalents-for...better-thans would definitely be interesting)

Re:PHP Popularity: Is it decreasing and what to do about it? by 9dev on Friday April 21, 2023 @05:02PM (#35660099)
People always seem to come up with the argument that you can drop an index.php in a folder and be done with it. Only nobody uses php that way since decades.

Modern php code uses Frameworks, Package mangers, opcode caching, and application servers. It’s just that other languages don’t carry all the cruft php has in its heritage…

Re:PHP Popularity: Is it decreasing and what to do about it? by wvenable on Friday April 21, 2023 @05:09PM (#35660208)
The drop index.php into a folder is the only way I use PHP now.

Back when I was building applications in PHP it was all frameworks. package managers, op code caching, etc. But I no longer do PHP development but for my own personal websites I still use PHP but in that most minimal form.

Re:PHP Popularity: Is it decreasing and what to do about it? by themodelplumber on Friday April 21, 2023 @05:54PM (#35660737)
Exactly, if one is not developing PHP for the enterprise (maybe some non-enterprise simple projects still use opcodes though? lol), it's silly not to leverage index.php for all it's worth :-)

So where is the hyper-simple JS equivalent for that class of non-enterprise projects, is what I wonder...the enterprise stuff has always been heavy and loads projects down with maintenance debt.

Re:PHP Popularity: Is it decreasing and what to do about it? by toyg on Saturday April 22, 2023 @05:33AM (#35664791)
The equivalent for JS is just an HTML file.
Re:PHP Popularity: Is it decreasing and what to do about it? by 9dev on Saturday April 22, 2023 @07:37AM (#35665499)
There are projects between hobby users and Facebook, believe it or not :-)

I actually like using a reliable package manager, a wide ecosystem of good packages, and modern language features. There is nothing "heavy" about modern PHP, unless you want it to.

Re:PHP Popularity: Is it decreasing and what to do about it? by djbusby on Friday April 21, 2023 @05:07PM (#35660173)
Exactly! Those languages are working on their own cruft!
Re:PHP Popularity: Is it decreasing and what to do about it? by mekster on Saturday April 22, 2023 @01:34AM (#35663671)
> Modern php code uses Frameworks, Package mangers, opcode caching, and application servers.

How do these change the way you can deploy PHP files by simply uploading them?

For frameworks, all you do is run a single command to install.

If you mean JS package managers, that's agnostic to what language you use.

Opcode caching doesn't require anything special from deployment point of view and I don't see a need for app server for PHP.

Re:PHP Popularity: Is it decreasing and what to do about it? by 9dev on Saturday April 22, 2023 @07:32AM (#35665457)
It changes deployment because you need to flush the opcache after deploying new code, for example; you need to install composer packages, restart the app server (if you use one), etc. I mean obviously you still upload files, but there are more steps involved in a proper deployment.

Once you start getting into zero-downtime deployments, you'll quickly see the need for both application servers like Swoole or RoadRunner, as well as strategies that don't leave requests in the air with half the code from the old version and the other half with the new one.

Let HackerNews hobby programmers snark all they want, those are very real problems with very real solutions.

Re:PHP Popularity: Is it decreasing and what to do about it? by lsaferite on Saturday April 22, 2023 @10:56AM (#35667191)
I mean... using a symlink to the deployment root gives a quick atomic swap. You update the link, then reload the server config, no downtime and no partial deployments during a request. This also solves for the opcache freshness as well if I recall correctly. (It's been a little bit since I've done any PHP work)
Re:PHP Popularity: Is it decreasing and what to do about it? by 9dev on Saturday April 22, 2023 @05:59PM (#35671286)
Of course, you can do that. It’s the strategy Etsy used, for example. Point still standing, that makes deployments definitely more complex than just „uploading a file“.

And then again, you’ll end up wondering why your servers should waste cycles upon cycles for executing the same bootstrap code over and over again, if they could instead only do that once, keep the app in memory, and only execute the request handling code… and just like that, you’ll end up with Octane, or Swoole, or what-have-you.

Re:PHP Popularity: Is it decreasing and what to do about it? by hakfoo on Saturday April 22, 2023 @02:07AM (#35663841)
What I like about PHP is that it's not just batteries-included, it's "Entire Batteries Plus Store Included". The standard library is huge, documented, and also features 15 years of accumulated notes and discussion right on php.net.

The tendency to have a npm package for everything is overwhelming because you end up with choice paralysis and risk on picking "Oh, you picked CSV-to-array library #823, it's the buggy/insecure/unmaintained one."

Re:PHP Popularity: Is it decreasing and what to do about it? by eurasiantiger on Saturday April 22, 2023 @09:38AM (#35666507)
File reading excluded, CSV to array is like two generator functions and a main, even with rudimentary schema support. No reason to add a dependency at all.
Re:PHP Popularity: Is it decreasing and what to do about it? by anonzzzies on Saturday April 22, 2023 @02:15AM (#35663882)
> Only nobody uses php that way since decades.

… in your echo chamber. I know first hand of multiple very large corps doing that (one of them being a bank and this is their payment api) and very many smaller shops. Sure, we recommend against it, but saying it’s decades ago like that is nonsense; many people do this because it’s convenient.

Re:PHP Popularity: Is it decreasing and what to do about it? by itslennysfault on Friday April 21, 2023 @05:08PM (#35660199)
Well "place an index.php file in a folder to deploy" is a lot of server (maybe Apache / PHP) running to support that.

Node typically IS the server. So, you could install express and have a simple web server listening on a port and serving up html or json in about 5 lines of code. Unlike PHP Node is not, in itself, a templating language. So if you want to render HTML pages you'd also need to install something like EJS, but generally node servers are just serving up JSON API, and your frontend would be some frontend framework (React, angular, vue). Although all of that is trending back the other way with NextJS the old is new again and server-side rendering is the hotness again.

Another option is to use a framework like NestJS. With that you do

    # install the nest cli (only needed for starting a new project)
    npm i -g @nestjs/cli

    # scaffolds a new project
    nest new project-name

    cd project-name

    # node server is now running on port 3000
    npm start

For easy deploy. That was kinda Heroku's thing. You just "git push" a node project and it magically knows how to deploy it, but Heroku got bought by Sales Force and murdered from my understanding. There are a lot of alternatives though. AWS, Azure, Google, CloudFlare, Digital Ocean, etc, etc all have similar offerings where you just push a node project to git and it deploys automagically.

Alternatively you can use AWS Lambda / Azure functions (or a dozen other "serverless" solutions) and you can just drop js files (functions) and they run on demand.

For a ProcessWire alternative there are a ton of options. A few I've seen are: Ghost, ButterCMS, Strapi

Re:PHP Popularity: Is it decreasing and what to do about it? by themodelplumber on Friday April 21, 2023 @06:02PM (#35660834)
Thanks for the info!

> AWS, Azure, Google, CloudFlare, Digital Ocean, etc

I'm always curious to know if there are more casual options in this space, for non-earthshaking projects. Maybe more like how DO was at the beginning?

Re:PHP Popularity: Is it decreasing and what to do about it? by belmont_sup on Saturday April 22, 2023 @12:55AM (#35663454)
Handful of great new hosts I’ve seen pop up:

Render.com, Fly.io, northflank. And I actually like AWS lambdas, so great option for me is SST.dev, which wraps AWS CDK, and provides an actual live development workflow with actual AWS resources.

Re:PHP Popularity: Is it decreasing and what to do about it? by steve_adams_86 on Saturday April 22, 2023 @01:38AM (#35663695)
I’ve been using fly.io for little things and it’s remarkably nice and easy to use. I can’t vouch for large scale projects, but for little things you want to experiment with it’s a joy.
Re:PHP Popularity: Is it decreasing and what to do about it? by boringuser2 on Friday April 21, 2023 @04:58PM (#35660029)
Do you really think the inability to create anything but an index.php file is the bottleneck?

Those people just use drop-in tools now which are better than custom applications for a large portion of standard use cases.

Re:PHP Popularity: Is it decreasing and what to do about it? by themodelplumber on Friday April 21, 2023 @05:00PM (#35660073)
Bottleneck? Just asking what's the JS equivalent in convenience for deploying a simple project.

It doesn't need to even look like index.php, just needs to be as convenient, ideally?

Drop-in tools? Examples? I was using PHP drop-in tools back in 2004 but I'm not sure if that's what you mean.

Re:PHP Popularity: Is it decreasing and what to do about it? by adoxyz on Friday April 21, 2023 @05:07PM (#35660179)
With node, install express, and run `node index.js` and you have a full blown server.
Re:PHP Popularity: Is it decreasing and what to do about it? by jahsome on Friday April 21, 2023 @05:05PM (#35660138)
Express and it's spiritual successors are the node "hello world" answers you're after, I think.
Re:PHP Popularity: Is it decreasing and what to do about it? by com2kid on Friday April 21, 2023 @05:01PM (#35660082)
For JS, you need to setup a listener like PM2 and point it at the folder, but once that is done, you can drag and drop and index.js file into place and it'll all work as expected.
Re:PHP Popularity: Is it decreasing and what to do about it? by smcleod on Friday April 21, 2023 @05:06PM (#35660166)
Oh that's easy - just install 10 insecure npm packages that each install another 10 npm packages (some of which are even maintained!) then make sure you remember to bundle it up in a nice, heavy electron wrapper. Then you're all ready to distribute it via some random App Store - just don't forget to charge a monthly subscription while you're at it. /s
Re:PHP Popularity: Is it decreasing and what to do about it? by themodelplumber on Friday April 21, 2023 @05:57PM (#35660775)
Don't do this to me, I maintained one of these projects years ago, and am still somehow billed $0.30 a month for the privilege of the original dev having used Amazon tools for it :D
Re:PHP Popularity: Is it decreasing and what to do about it? by smcleod on Friday April 21, 2023 @06:04PM (#35660852)
The pain is real! Speaking of Amazon - AWS CDK is promoting lots of terrible practises mostly built on barely supportable TS/JS, it's so... so terrible.
Re:PHP Popularity: Is it decreasing and what to do about it? by joquarky on Friday April 21, 2023 @08:02PM (#35661862)
I've been doing web development since before the <table> tag was introduced.

> just install 10 insecure npm packages that each install another 10 npm packages

I still don't understand why companies are fine with this.

At my last job, even principal and staff level developers needed every Windows or Mac application install vetted by IT. We had real time system monitoring on all employee workstations that ate up half the RAM and CPU resources and constantly kicked us off the VPN for even the slightest quirk (including the CPU redlining due to scanning).

But npm dependencies? Nothing. Install whatever you want and push it to production.

This is an S&P 500 company that deals with tons of PII.

Re:PHP Popularity: Is it decreasing and what to do about it? by chclt on Saturday April 22, 2023 @09:45AM (#35666572)
Because the working part of an organisation such as the one you describe tries to continually optimize away these restrictions. NPM (et al) is a good way to obfuscate the fact you're pulling unknown code to get shit done and processes haven't caught up yet.

I'm not saying this is good, but the reality with these company-internal restrictions is, that the most productive people find ways around them and are rewarded for it.

Re:PHP Popularity: Is it decreasing and what to do about it? by armarr on Friday April 21, 2023 @05:06PM (#35660168)
An html file with a <script> tag
Re:PHP Popularity: Is it decreasing and what to do about it? by themodelplumber on Friday April 21, 2023 @06:06PM (#35660881)
I see we both read the same JS Game Dev book...
Re:PHP Popularity: Is it decreasing and what to do about it? by rikroots on Saturday April 22, 2023 @04:28AM (#35664468)
Exactly this. It's the perfect approach for teaching people the basics of how to use my JS library - https://scrawl-v8.rikweb.org.uk/learn/first-lesson/
Re:PHP Popularity: Is it decreasing and what to do about it? by DonHopkins on Friday April 21, 2023 @05:08PM (#35660195)
What is the PHP equivalent of writing your front end and back end in the same language so you can share libraries and data and not have to switch gears between two different languages each time you look up or down the stack?

There is a HUGE advantage to using the same language in the browser and on the server, and PHP isn't ever going to displace JavaScript in the browser. So JavaScript it is. That ship sailed a LONG time ago.

Re:PHP Popularity: Is it decreasing and what to do about it? by archerx on Saturday April 22, 2023 @01:43AM (#35663714)
I like switching gears, I truly don’t find it an advantage using the language for both. Have separate languages makes the distinction between backend world and front end world very clear. Also the backend code is mostly data manipulation and the front end code is mostly rendering so there is very little overlap in similar functions for both. The separation helps keep things tidy in my brain.

I much prefer not having to write JavaScript everywhere, not every problem is a nail and not every solution requires a hammer.

Re:PHP Popularity: Is it decreasing and what to do about it? by ihatepython on Saturday April 22, 2023 @02:40AM (#35663978)
Don't you think it would be better to write everything in HTML? It wouldn't be too hard to make it Turing complete. This way your server is written in HTML, your browser is written in HTML, no more switching gears.
Re:PHP Popularity: Is it decreasing and what to do about it? by ThatPlayer on Saturday April 22, 2023 @07:06AM (#35665295)
I believe you'll need to compile the PHP runtime itself with emscripten, since LLVM won't take PHP code, but PHP compiled to wasm will!
Re:PHP Popularity: Is it decreasing and what to do about it? by pjmlp on Saturday April 22, 2023 @03:46AM (#35664286)
As long time Java, .NET and C++ developer, this is oversold, beyond some form validation there is hardly any value sharing code.

And in what concerns validation, it can be automated on most frameworks, which has to be done on server side anyway due to security concerns.

Re:PHP Popularity: Is it decreasing and what to do about it? by toyg on Saturday April 22, 2023 @05:38AM (#35664817)
The value is really not in sharing code, but rather sharing developers. Instead of having to assemble and keep happy a diverse group of specialized professionals, you can just hire and fire a bunch of cheap JS folks, who are easily replaceable.
Re:PHP Popularity: Is it decreasing and what to do about it? by pjmlp on Saturday April 22, 2023 @06:33AM (#35665091)
Offshoring already takes care of the cheap developers part.

When people get what is peanuts in local currency of the owner company, whatever they are using doesn't matter and most sweet shops are experts in everything.

I can also tell that at the level I work on, salaries are the same regardless of FE, BE, DevOps, ...., specially because no one has a single role.

Re:PHP Popularity: Is it decreasing and what to do about it? by DonHopkins on Saturday April 22, 2023 @06:17AM (#35665008)
toyg makes a good point about sharing developers, but also sharing code is important, especially for efficient server side rendering, with view code that runs on both the server and the browser.

The point is it takes fewer people (or even the same person) to write less code (instead of writing everything twice, then trying to keep them in sync forever).

There's a fascinating deep discussion about SveltKit and other frameworks here:

Reacting To Web Hot Takes from Rich Harris - SVELTE STUFF

https://www.youtube.com/watch?v=JGuUY7dZhWs

Re:PHP Popularity: Is it decreasing and what to do about it? by pjmlp on Saturday April 22, 2023 @06:34AM (#35665102)
Java and .NET have been doing efficient server side rendering for several decades now.
Re:PHP Popularity: Is it decreasing and what to do about it? by paulryanrogers on Sunday April 23, 2023 @10:31AM (#35676544)
LiveWire?
Re:PHP Popularity: Is it decreasing and what to do about it? by edmundsauto on Saturday April 22, 2023 @01:02AM (#35663479)
I have a hobby app that is index.html and I just manually add <script> tags to load libraries. No build step, I just use GitHub to cloudFlare pages to host.
Re:PHP Popularity: Is it decreasing and what to do about it? by asdfman123 on Saturday April 22, 2023 @03:43AM (#35664266)
It’s funny that it reads like some novel approach, but a script tag within an html page is what JavaScript is and was designed to be.
Re:PHP Popularity: Is it decreasing and what to do about it? by anonzzzies on Saturday April 22, 2023 @02:23AM (#35663918)
I would stick with Laravel or something like that if I were you. The rest is good for your resume, but if you don’t need that, I would forgo the misery that is js/ts dev.
Re:PHP Popularity: Is it decreasing and what to do about it? by tommica on Saturday April 22, 2023 @05:42AM (#35664838)
Oh, processwire looks interesting, first time hearing about it
Re:PHP Popularity: Is it decreasing and what to do about it? by 0xblinq on Sunday April 23, 2023 @11:08AM (#35676880)
> What's the JS equivalent of "place an index.php file in a folder to deploy"?

My favorite way to do this is to add a custom script to package.json like:

"start": "pm2 start index.js --name myapp --watch"

Any file change will reload the application and if it crashes it will be restarted. So just scp/rsync files if that's your desired workflow.

In my experience, it's far easier and faster than setting up nginx, apache, fpm, etc, etc.