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.
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.
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.
I beg to differ.
- Runtime errors are more common in PHP and that's a good enough reason for me to say that PHP dev workflow is worse.
- You also seem to miss some common errors when the PHP assets are missing. Suddenly the compile con becomes an advantage for Go.
- Different servers (apache, nginx, etc) give you yet another thing to configure.
From my very old past experience, PHP development gives you more headaches than Go.
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.
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.
I'd add generics to that list, but Go doesn't have them either, so not really a point for discussion.
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.
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.
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.
Also PM is just a simple hypervisor, it doesn't have any logic, while Apache and Nginx do.
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
if you want a quick script 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.
And 98726354 packages that get pulled when you `npm i express`
Is it a better language with better workflow? Maybe. But I do know there are people using it in just this way.