I do wonder if there really was value in salvaging PHP when we have a wealth of other languages and frameworks that do a perfectly fine job without any of the legacy mistakes sitting around.
I do wonder if there really was value in salvaging PHP when we have a wealth of other languages and frameworks that do a perfectly fine job without any of the legacy mistakes sitting around.
The tales of legacy mistakes holding back php are things with no basis in reality. What legacy mistake holds php back? Method names/parameter ordering?
When I started with php in 2001 those elite programmers at meetups were looking down at php because Java was cool. In 2003 those elite programmers thought php should die because asp took over. PHP kept going along quietly taking over the web until the facebook movie came out making PHP cool for a moment. Those elite programmers decided PHP was too mainstream and the why PHP sucked movement started. The elite guys moved to Ruby On Rails then node/MongoDB, angularjs, React, Nextjs leaving each ecosystem for the next hoping that one day they will strike gold.
Nobody can tell me why PHP is “bad” or what Python does that PHP can’t. Inconsistent params are the only argument I’ve heard. Which my IDE solves. What about JavaScript splice vs slice. I look it up every time.
Personally, I can't stand writing PHP, because, sure, I can write secure, testable, safe code in any language, including PHP, but, how do I say this, PHP is the only language that feels actively hostile to my attempts to do so. The house style at my current company could be boiled down to "Check 3 times that there are no PHP footguns present in this code. We have been burned before." The developer experience and tooling is far behind comparable languages. I feel like I have to put my sysadmin hat on to fix anything that goes wrong with my environment.
When I write Javascript or Python, I have complaints and issues, but I enjoy writing code. I think PHP, for many programmers, including myself, is just a hostile and unenjoyable experience. If you enjoy writing PHP, I have nothing against you and am certain you will remain employable, there's a lot of PHP out there.
> Honest question: what are people using if not PHP? Node? Python? The 80% of us who aren’t FAANG and are writing CRUD apps.
Python, Node, Java, .NET, Ruby. MVC CRUD apps are pretty similar in all of these (also in PHP). All of those languages (including PHP) power many many many software companies (including FAANG, who use a lot of Java and C++, and Facebook famously was built on PHP).
Surely JS has at least an equal amount of foot-guns to PHP. I mean, at least PHP (to my knowledge) never had a meta-language written around it that compiles to PHP to make it safer.
This is important
* memory model (shared, per request, etc)
* request model (by the app or by the web server)
* compilation/build step
* deployment
* hosting
* tooling (IDEs, linters, testing, package manager, etc)
* how to scale
* available programmers
* community
This is not important * $ in variable names
* arrows (->) for accessing object members
* argument order in standard library
* not elegant enoughThey have trouble grokking that there is a method of dev in which the server is not the language parser, so all other languages feel like a wrong step.
Here on HN someone just asked why anyone would write in anything except JS [1].
Now, Node has it's advantages, and so does PHP. My personal preference is PHP. But in mindset, Node is far ahead of anyhere that Rails or Django ever got in their respective waves.
Static typing, concurrency, blazing fast, single binary.
I have once heard an ancient prophecy (I think it's Greek) that says "Debating around PHP online summons the ghost of the dark behind your back" or something like that (I don't speak Greek, sorry).
In the Client/Server world now days, the most of the time you only need one or two languages, one running on the Client side (JavaScript for example) and one running on the server (**, Go, Java, JavaScript etc).
In that setting, JavaScript comes with the hard advantage of both-end compatibility, that gives you something like Server-side Rendering, which no other backend-only language could do, at least not "natively". If you have a foundation this good, people will build the library themselves when the language/runtime don't have it built-in. (the same is true when it comes to Swift/Dart/Kotlin. I bet there is someone/company out there writing both their app and their backend in Swift/Kotlin)
For "backend-only" languages, it's largely down to personal/team preference. Some needs performance, some wants "write-friendly" (contains many factors). But the problem is, the market now days is saturated with better options that also do more things (often in a better way). When you bring all the options on the table, then suddenly that-language-the-name-we-shall-not-say started to look way less attractive.
It's just that, comparison/competition kills things, no elite required.
The problem with swapping out php on the backend for node is now you have to maintain a node server, manage long running processes. If you make a change to a node file you have to restart the server. Where php is running under apache or nginx and files can be dropped in without taking down the site.
That's why everyone is going serverless.. who wants to manage a node server.
Isn't it the definition of a "backend-only language" that it renders server-side?
I'm not even really sure why python is so popular for DevOps cause I do everything in php and it's unit tested and works well with reproducible results.
That's a lousy dig at Python. Stuff you solve with a free text editor and 15 seconds worth of configuration aren't real problems.
caching, jobs, docker via sail, authentication and authorization, one command to have a full multi team/tenant SaaS app template via jet stream.
even rails doesn't have this, as you need to choose your own implementation for auth and access control, something like sidekick for job queue etc....
plus the ecosystem. I've tried so hard to like other frameworks and some I really do (like remix.run) but the lack of real momentum and community hurts most anything else and just doing everything as serverless micro services isn't always preferred or using micro frameworks.
I'm excited for the new features and with octane you can get more reqs per second than Phoenix framework which should make it easier to scale apps with less resources.
Among that choice set, PHP is definitely the best contender.
I have a HTML page. How do I add a hit counter to it with Ruby?
I can do it right now in PHP with zero dependencies and it'll fit in this comment:
<html><body>
<p>You are visitor number:
<?php
$count = file_get_contents('hit_count.txt');
$count = $count + 1;
file_put_contents('hit_count.txt', $count);
echo $count;
?>
</p>
</body></html>
Is it shit? Yep. Does it (mostly) work? Yep.When you want to do something, you can just copy and paste a handful of lines of PHP into a file and rename it from .html to .php and it'll basically work anywhere. You don't need to worry about frameworks or anything. Routing is handled by the web server. Hosting is handled by someone else. Deploying is just FTP'ing a .php file off to a server somewhere and then requesting it.
But when you are ready to get into "real" programming, that's all there too. PHP has a true learning _curve_. Every bit of complexity is only a small step from the previous. Getting started does not require a ton of background or knowledge. You can start out copying and pasting some code into the middle of some HTML and a year later end up working within once of the nicer, more comprehensive frameworks managing your dependencies with a relatively decent package manager... and still hosting it all on your $3/mo shared hosting.
If every professional developer stopped using PHP tomorrow, we'd still end up back exactly where we are as a bunch of people found PHP as the most accessible and direct solution to the problem they have.
While with rails, to do basically anything, you already have a full db ready and incrementing a counter using the ORM is even easier than opening a text file. So people avoid PHP because it most likely involves dealing with absolute crap code written with no understanding.
How it makes it harder? Or you compare PHP a language with Rails a framework? Maybe shut up if you have no idea or show us a pure Ruby code that does the same thing. Or install the most popular PHP framework, really learn that and then tell us that PHP made things harder. I don't know Ruby or rails so I can't shit on that like an idiot.
<? include '../menu.php' ?>
can rails compete with the performance of octane using swoole with 8k reqs per sec?
rails is the first framework I ever learned in 2012 but I kept jumping back and forth until laravel basically started lapping rails in terms of baked in goodies.
There was no chance of it being killed off rapidly as the author was perhaps implying. It might have slowly rotted away, had the maintainers not stepped up with v7 and hit a home run.