> You can do this with one PHP file , one a super cheap hosting , with code that is simple and clear.
This. PHP is basically Functions-as-a-Service over commoditized virtual hosting. Maybe we need a toolchain that can transpile down to PHP, starting from more common languages with better development workflow.
What languages have better development workflow? I'm myself biased towards repl-driven development with Clojure, but for example Rust's or Go's development workflow is a lot worse than PHP.
PHP: write file to disk, reload webpage/run curl
Rust/Go: write file to disk, compile file, run binary, reload webpage/run curl
The popularity of PHP is not hard to understand when it comes to ease of development.
honestly, that argument died when Hot Reload became a thing ... something like 10 years ago? you dont reload pages, they automagically reload whenever you either save or the compilation finished.
unless you want to check your pure JSON api itself... but why arent you writing a test making sure of your behaviour there? its literally both less effort and assures you of the correct behaviour in the future as well.
> - Runtime errors are more common in PHP and that's a good enough reason for me to say that PHP dev workflow is worse.
Seems you just know more Go than PHP, which is fine of course. No language has "more runtime errors" than other languages, just developers of varying skill-levels in that particular platform
> - You also seem to miss some common errors when the PHP assets are missing. Suddenly the compile con becomes an advantage for Go.
And you don't get errors when assets you use in your Go program is missing? Only difference is that PHP compiles when you hit the webpage, instead of a separate step, so you'll get the error when trying to load the page, not when running "go build".
> - Different servers (apache, nginx, etc) give you yet another thing to configure.
Just like in Go, you don't have to use a separate server in order to develop. Just fire up the PHP development server that PHP ships with.
> Seems you just know more Go than PHP, which is fine of course. No language has "more runtime errors" than other languages, just developers of varying skill-levels in that particular platform
A type system reduces the risk of runtime errors, because it doesn't let you write code with undefined behaviour such as indexing a null. Depending on the implementation, it can even force you to handle all possible failures explicitly so that execution always completes. With languages such as rust or Haskell it's feasible to write complex code with almost complete confidence it won't hit any runtime errors, excluding resource exhaustion or machine failure of course.
On the other hand you could argue that logic errors depend on the skill of the programmer and not the language.
Right now, PHP is only missing typed local variables. Class fields are typed, function arguments are typed, function returns are typed. And local variables can be typed for static analysis purposes with `/* @var $str string */` annotation.
I'd add generics to that list, but Go doesn't have them either, so not really a point for discussion.
FYI you can get a lot of this checks in PHP too if you annotate your code. It is built in in the IDEs too so there is no extra work for you. Sure you can make errors but I do it for productivity reasons, I can perform refactoring like "Rename", "Find Usage" in PHP exactly as in Java, it is much pleasant then the situation on front end.
> - Runtime errors are more common in PHP and that's a good enough reason for me to say that PHP dev workflow is worse.
With type hints you can eliminate a lot of runtime errors these days.
> - You also seem to miss some common errors when the PHP assets are missing. Suddenly the compile con becomes an advantage for Go.
When using Composer, specify the extensions and the PHP language level you need in "composer.json", and it will barf during deployment at the composer install stage.
The only thing Composer can't check is configuration parameters (e.g. max execution time, memory limit).
> - Different servers (apache, nginx, etc) give you yet another thing to configure.
Not much anymore, at least Debian and Ubuntu integrate all three major web servers (apache, nginx, lighttpd) pretty much out of the box.
Me personally if I would be asked something like "we can;t use PHP starting from tomorrow for our backend crap, what should we use?"
I would say node or if we need to use a static language would be Java. And the choice is not about the language but about the entire ecosystem(libraries, tools, developers, documentation)
Using type hints and a good IDE there are not many type related issue slipping in the code.
You can also do it in one golang file. Or one python file. Or one nodejs file.
With PHP you have more moving parts, Apache/Nginx with their configuration and then the PHP script. With golang/rust/python/nodejs you have direct access to the webserver and more control, but the same simplicity.
>With PHP you have more moving parts, Apache/Nginx with their configuration and then the PHP script. With golang/rust/python/nodejs you have direct access to the webserver and more control, but the same simplicity.
From my limited node experience I had to setup Nginx too and then connect it with node, and setup some manager like "pm" to keep the things running.
When people say PHP is simple to setup they mean the customer buys some web hosting, and then puts the files there (at most you setup the db credentails and table names ). The customer will not need to hire a sys-admin that will have to use latest docker stuff or try to fix the issue that your customers runs RedHat but the developer wants to use X npm package but X needs some new npm and node version and now the sysadmin needs to make it somehow work.
I am not saying PHP is superior, if you are expert in Java, .Net, Python etc continue using that if it makes sense, in reverse if you (your team) are PHP experts then it is a waste to not exploit that experience. You might say that you should fire the good PHP developers that worked for you for years and take a chance on finding some CoolLang experts, from my experience is not easy to find good developers(in all dimensions not only good at reciting best practices), developers that you know that will not leave after 1 year because they want to work on new shit, developers that like to do their job for the end product , for the customer satisfaction and not just like to code because the language is cool, the framework is popular, the IDE colors are shiny and for the CV. If you have a good developer or team , use it.
My point was that I already have a cheap webhosting, with a domain and email and I can now just login into cpanel and paste a script.
As a developer as other mentioned there are ways to run stuff from CLI, so IMO PHP is pretty equal with python or ruby , not sure there is a general clear winer so it always depends on the project and the team.
But if you are a new dev and you don't know any of the languages I would say start with Python, even if I prefer the C syntax. I got into PHP indirectly, I worked on desktop applications and I was asked to help with a web project so I learned it by doing (but I was already experienced so I did know what are some good practices), in the end desktop applications are no longer popular so I am still working on SPAs
For someone who's not developer, PHP is way more simple to deal with. Upload to your FTP, follow some script or edit config file, get it up and running.
That's much more complicated with virtually every other language.
I mean, this has been going for decades, I didn't think it was up for debate. There's close to zero sysadmin skills required for dealing with PHP hostings, most of them have CPanel or something similar, most of them are very cheap, and there are plenty.
There's nothing similar for Python or any other language.
Vhost doesn't give you that kind of access, AIUI. They simply serve multiple users from shared webserver infrastructure using Host: header to disambiguate. (User-specific paths like www.vhost.com/~foobaruser/ used to be an option, but modern web security mechanisms rely on the base domain as an indicator of site-level 'context'.) That makes it quite isomorphic to lightweight "serverless" cloud hosting.
This. PHP is basically Functions-as-a-Service over commoditized virtual hosting. Maybe we need a toolchain that can transpile down to PHP, starting from more common languages with better development workflow.