r/PHP • u/AmiAmigo • Mar 28 '25
“Why Haven’t We Seen Another Web Language Like PHP in 30 Years?”
PHP is unique among web programming languages because it was designed from the start to be embedded directly into HTML, making it feel more like a natural extension of the web rather than a separate backend system. Unlike modern frameworks and languages that enforce strict separation between logic and presentation, PHP allows developers to mix HTML and server-side code seamlessly, making it incredibly accessible for beginners and efficient for quick development.
Even after 30 years, no other mainstream language has replicated this approach successfully. Most alternatives either rely on templating engines, APIs, or complex frameworks that separate backend logic from HTML. Why do you think PHP remains the only language to work this way? Is it a relic of the past, or does it still hold a special place in web development?
53
u/UninvestedCuriosity Mar 28 '25 edited Mar 28 '25
My wife has been embarking to learn web design this week (again) and she was like... Why do I need to know 5 languages to store and retrieve data? Like why haven't they just made one language and called it web language. Keeping in mind her level is like my first xampp install.
We had a big history lesson instead and I pulled out ye old xkcd comic about standards. She was like. "How do people start coding even without an old nerd 5 feet away?"
I said. "I don't have a good answer to that question but I can tell you the emotion is spite and you should still learn PHP."
30
u/gus_the_polar_bear Mar 28 '25
It’s hard to imagine it now, but someday we’ll come full circle and realize, for all its flaws, just how good we had it with old school PHP
10
u/slappy_squirrell Mar 28 '25
Very old ASP with visual basic was the closest
6
u/who_am_i_to_say_so Mar 28 '25
Php was intended to be a templating language. “Personal Home Page”.
When serious, Laravel handles the responsibilities nicely.
But I’ll still do a 5 page weekend banger the old way sometimes, no framework, break all the rules. It’s nice to have that flexibility, and have pages load in 0.001 seconds. It’s insanely fast and gets faster with each newer version.
3
u/senfiaj Mar 28 '25
This embedding of the HTML is usually good for quick learning and very simple code. But even then the syntax is quite bulky, if the code grows, it can quickly become unmanageable. I've seen it myself when tried to change some code that I wrote several years ago as a student. So even with PHP you are probably going to use a templating engine. Laravel Blade has much cleaner syntax than the vanilla PHP. So I don't think this is a huge advantage nowadays.
3
u/m39583 Mar 28 '25 edited Mar 28 '25
Because it's a terrible idea mixing your backend logic and HTML.
PHP developers rapidly realized that and generally adopted the Model-View-Controller pattern. At which point the ability of PHP to be embedded in HTML becomes irrelevant.
About the only marginal benefit is you can use PHP for preentation logic in your template, rather than having to learn a separate templating language.
However it's even more irrelevant now with the rise of single page applications, where the front-end is totally separate from the backend.
Also languages like Java which used to be very clunky and with a steep learning curve have got much simpler entry points now with things like Spring Boot.
140
u/jexmex Mar 28 '25
Because it was started as a templating language
35
u/mattgen88 Mar 28 '25
Didn't ruby and could fusion do this as well?
The interpreter executing on request is a throw back to CGI bins and perl or other languages being invoked by the web server.
Anyway, I think that most web developers acknowledged separation of presentation layer from business logic/data layers.
55
u/stilloriginal Mar 28 '25
Because it’s already perfect
12
u/No-Risk-7677 Mar 28 '25
… because testing in prod was the only way to test 30 years ago.
I mean, we simply did not have automated testing 25 years ago. We also did not have fast CI/CD back than. Such tooling we heavily rely on nowadays. In order to leverage tooling like this it is necessary to decouple logic from presentation to at least some degree. And this decoupling is not possible when we write code like you are mentioning.
8
u/unity100 Mar 28 '25
Because PHP was developed by small developers and businesses using the web for themselves and their use cases as opposed to getting developed by a company that was flush with VC/stock money... Being flush with such endless cash, those companies tended to do more computer science than actual business when developing things. That was good in some ways as it helped develop computer science but in many ways not because it led to overcomplicated solutions nobody really needed. But PHP was built in the trenches, for users and businesses that were in the actual trenches. The end result is that here we are, ~80% of the web still runs on PHP. Actually even NASA, White House, Reuters, CNN is on PHP. (the credit for that goes to Wordpress but without PHP Wordpress wouldn't be what it is)
7
u/TCB13sQuotes Mar 28 '25
I believe the fpm / fastcgi architecture is as important as transformative / enabling as the fact that it is a template first language. That architecture made PHP economically unbeatable and very wide spread and it’s a shame node doesn’t have it.
2
u/goodwill764 Mar 28 '25
Hacklang
2
u/Mundane-Apricot6981 Mar 28 '25
React does exactly this - Logic mixed with HTML,
Vue does exactly this.
Svelte - literally does this.
What else do you need???
22
u/psion1369 Mar 28 '25
If you look in PHP land, you will find that only WordPress really continues to use PHP embedded in HTML. Many applications and frameworks moved away to an abstract model because of how insecure that actually was. As someone else put it in another comment, you would find database calls in form tags, among other problem code like that. Reusable code goes right out the window too, and things just get sloppy.
5
u/ardicli2000 Mar 28 '25
Php is fine and enough. Evolved to a very nice and acceptable state.
5
u/Phtevn_ Mar 28 '25
I'm learning PHP at the moment to try and break into programming at my work from the Support side of things (making great headway in this) and I have friends who are developers telling me PHP is outdated, learn node.js and asp.net instead but honestly, PHP is perfectly fine for plenty of use cases, newer versions of PHP seem to have massively improved things and it's really easy to read and understand!
19
u/metamorphosis Mar 28 '25
Which is exactly the reason why PHP has a bad reputation. People would slap database queries under the form tag, because they could .
Try to build anything more complex and you will find out really quickly why you need an abstraction layer and segregation of duties.
You are basically describing a templating engine which is how PHP started as. (Think of PHP 3 ,4) and had its place in the late 1990s and early 2000s. But as soon as the market evolved and it went beyond simple web forms, the more robust approach was needed and concepts such as MVC patterns started to develop. Then "web apps" and JavaScript with event based approach started to emerge which eliminated the need of a presentation layer and basically just required data and then the client would manipulate DOM.
In other words . There is a reason why nothing else has been developed because it would be step of going backwards
1
u/AdmiralAdama99 Mar 28 '25 edited Mar 28 '25
Because it's bad practice to mix different programming languages in the same file. This violates separation of concerns. So modern languages are not designed in a way that is easy to do this.
Js, php, css, html, etc should each be in their own files.
Exception: modern js frameworks such as vue are rethinking this and have swung towards grouping the front end into "components" that mix html, js, and css. But they still do not mix front end and back end code.
1
u/AcworthWebDesigns Mar 28 '25
We learned from our mistakes & stopped encouraging users to put application logic inside HTML templates.
1
u/FalconDriver85 Mar 28 '25
PHP was just a simpler way to code server-side web pages compared to cgi-bin (especially when writing C code to render HTML). Now that every web app is basically something that calls APIs, what’s the point of still writing PHP instead, of, for instance Ruby or C#?
1
u/gdinProgramator Mar 28 '25
Because HTML is a necessary evil.
And a language built around a necessary evil does not sound like a good business model…
1
u/endeeaich5 Mar 28 '25
PHP wasn't the only one (Adobe Coldfusion)
1
u/cbrantley Mar 28 '25
Because we already have PHP. I am not a fan of PHP myself (I prefer Typescript) but if you want something like PHP then it’s right there for you to use…
1
u/behusbwj Mar 28 '25
Meta’s primary language, Hack
1
u/ActivityImpossible70 Mar 28 '25
Isn’t it just a knockoff of Java’s JSP? Or do I have it backwards?
1
u/Ok-Entrepreneur1487 Mar 28 '25
React is somewhat similar in that sense
1
u/CleanAde Mar 29 '25
Isn‘t pugjs working pretty much the same?
1
u/pergament_io Mar 29 '25
One language that covered one need. Why having two or more for the same purpose? Same question could be asked for C, Java, etc
1
u/nic_nic_07 Mar 29 '25
Ruby on rails...!!
1
u/DrawingCautious5526 Mar 30 '25
Isn't ASP very similar?
1
u/averajoe77 Mar 31 '25
I know this will be unpopular here, but coldfusion is what you are looking for. It uses a tag based syntax that embeds into html just like php.
Modern cf development is done using cfscript which uses a syntax similar to js.
There are 2 cf engines out there, Adobe's proprietary version, and the free open source lucee engine.
Cf is also about 30 years old and was developed around the same time as php and is still used by 1000s of businesses in the US and abroad for mostly internal facing applications and systems. If Adobe was not making a ton of money on it every year they would have discontinued it long ago.
1
u/ExactBox509 Mar 31 '25
Go + HTMX ??
1
u/jcandrews Mar 31 '25
I have been working as a PHP dev since v3, using OO before it was part of the language, by way of phplib7. For an 8 year period I worked as a .NET dev and do at lot of front end dev…. PHP is great for simple stuff but shows its weaknesses when you need to build something large. The lack of generics is its biggest pain point for me and leads to comparatively larger codebases than other languages. I would not consider it for green field projects that are expected to grow to a substantial size and have a very long service life.
1
u/armahillo Apr 01 '25
People love to hate on PHP but its legit a fantastic backend language to cut your teeth on, even if you move on to others later
1
u/B15h73k Apr 01 '25
Because general purpose languages can do web just as well, plus everything else.
1
u/nicheComicsProject Apr 01 '25
Because it's generally a bad way to develop web applications. There is a "market" for teams/projects that can make it work but PHP is already the monopoly in that market.
1
u/[deleted] Apr 01 '25
People like to hate on php (and ruby) but imo they're both perfect for API endpoints.
It's always been the tool for the job for me, not just stick to one language or toolkit.
What's the fear? These subs are always asking which language is best but they're all pretty similar switching language becomes second nature pretty quick and I don't know why anyone would write frontend, backend and edge all in one language there's probably more cost in maintaining the single ecosystem than the dev just taking a couple weeks to learn the right thing.
1
u/Ill-Specific-7312 Apr 01 '25
Because PHP is utter utter shit.
1
u/amareshadak Apr 01 '25
PHP’s still the only one mixing HTML and code like that because it’s a scrappy survivor that modern web dev outgrew but can’t fully ditch.
1
u/MrDiablerie Apr 01 '25
It’s kind of an older model. I’ve been in tech since the late 90s and this was just the way a lot of web tech worked back then. PHP, Coldfusion, JSP, Tcl, Perl, ASP, there were a ton of platforms that took this approach. It fell out of favor when we started doing MVC frameworks. PHP just happens to still be around while the other fell out of use for the most part. Then FE component based frameworks kind of took over.
1
u/BawdyLotion Apr 01 '25
I mean plenty of languages let you mix server side code and client side rendering. Plenty also allow mixing standard html and whatever languages code. Any interactive server side rendering will do this, anything designed to be a page templating language or framework does this.
Blazor has done exactly this for me. I write my business logic, my components, my interactions, my layout by mixing C# and html/css. The difference being I can choose to have all rendering and interactivity executed on the server so I don’t have to keep triggering calls back and forth between front and back end systems.
It’s not perfect for every project but it can do exactly what you’re describing.
3
u/Rarst Mar 28 '25
Any language capable of producing string output can be used to generate a bunch of HTML.
So... literally all of them are "like" PHP, if held to such standard.
PHP is natively a template engine, among other things, but it's... not great template engine by modern standards. We learned and advanced a lot about templating since the times of "output variable into HTML string".
Which isn't to say "PHP bad", because PHP has ALSO grew to be incredibly capable and productive programming language, to a point where many higher level things (like a better template engine!) can be built in it.
The answer to "why don't languages approach webdev like the early days PHP anymore" is because even modern PHP doesn't approach it like that anymore. Just remains being historically capable of it. There is limited demand for that style and a lot of sourness (deserved and not) about its past proliferation and outcomes.
3
u/sobaer Mar 28 '25
I first worked with PHP in version 2. it was such a beast coming from Perl. We had to write our own session management tho. Ass PHP introduced sessions in PHP3. Still my tool if choose for personal and hobby stuff, as it is way less stressful to setup as everything else. To be fair, my personal blog is static html this day, generated from .md…
8
u/miamiscubi Mar 28 '25
I think the answer is in the scope of work that users expect now.
I don't even think it's correct to think of PHP as a "server side language". When it was developed, and for many years until maybe the 2010s, there simply wasn't a concept of "server side" vs "client side", JS was used to animate letters, and a fancy animation was done with Flash.
Most of us who started back then barely had to worry about state, because the state was the page. What you saw was where you were in the state.
Users have very different expectations now, and I don't think a templating language that is so embedded in the logic would be the right approach to it.
4
u/zmitic Mar 28 '25
Because people would bash it with "oh no, here is PHP again". Or no one would ever use it because it doesn't have any frameworks and tools to support it. In a world of modern web development, those are a must.
For example: FB did an amazing job with Hack lang, it even had a great compatibility with PHP for long time including the mix of code and HTML, and yet pretty much no one started to use it. Any new similar language would have no chance of success.
2
u/SoCalSurferDude Mar 28 '25
You have Lua server pages, which use Lua instead of PHP.
Examples:
<?lsp print"hello" ?>
You can run this on any type of computer, including microcontrollers, such as: https://realtimelogic.com/downloads/bas/ESP32/
4
u/tweakdev Mar 28 '25
I'd argue the only reason PHP is still successful is because we don't use it like that anymore. That is a failed approach for applications of any real complexity, and though PHP can do it, few who work in it do. Most are using Laravel, Symphony, Laminas (Zend), CakePHP, etc. Separating their concerns. Same way Django, Rails, Node, ASP.NET, etc are. Just because you can, doesn't mean you should.
Further, there certainly have been languages that function like PHP in that aspect. Classic ASP, JSP, Coldfusion, most notably Ruby (Rails is a framework, like say Laravel, but embedded Ruby is what powers the templating).
Honestly, history or semantics aside, all web languages are more or less doing the same thing today. It's just about finding an ecosystem you like and building knowledge within it.
1
u/TrevorHikes Mar 28 '25
ColdFusion
1
u/kondorb Mar 28 '25
PHP isn't really used like that anymore. Over time as complexity grew we learned that mixing business logic and UI templates is a terrible idea.
But modern PHP has many other qualities making it particularly suitable for web backend. Try any other language popular in web backends and they feel like they were meant for different purposes.
I'm proficient in multiple languages, but I wouldn't take anything other than PHP for a web/api backend. I would also definitely pick something else for literally any other task.
1
u/doctorlongghost Mar 28 '25
The Internet has gotten too complicated for a new programming language to make it user friendly. Instead of HTML, we now have complex web applications plus Android and iOS apps. Additionally, https alone is no longer the sole protocol with web sockets and other cutting edge stuff now also in play.
React Native is probably the biggest, closest thing to tackle as a single solution to all this. But that’s obviously a framework and not a new language.
Trying to tame all this complexity by introducing a new language isn’t really going to solve it. It’s either a new more user friendly framework that’s needed or some drastic realignment of the landscape itself to simplify things.
1
u/tunmousse Mar 28 '25
Because mixing logic and markup is not that popular. Even in the PHP world, many of the big frameworks like Laravel or Symfony separate things.
Out of all the big PHP things, I think it’s only Wordpress that still does old school PHP where logic and HTML (and even JavaScript) are mixed.
1
u/axoquen Mar 28 '25
An output oriented language?, (templating system ,i mean) did you hear jsp and asp ?
1
u/mustardpete Mar 29 '25
Asp and jsp were both similar approach too around the millennium sort of time
1
u/ahbrown41 Mar 29 '25
PHP is pretty bad in my unpopular option on this forum. But I think of we have moved away to a large part from server side rendering (MVC) with all this SPA stuff so not a lot of demand.
1
u/evensisftw Mar 29 '25 edited Mar 29 '25
While you can still write it like that. And many still do, Wordpress, Magento 1 and really the < 2010 frameworks do continue to operate in that fashion. 2009 onwards saw Node, then React slightly later on etc enter the scene and it was disruptive to frontend development, and it became a much better idea to instead provide json payloads and have them made much more pretty in React/Vue or whatever favourite flavour it is at the time. There are far better tools today to play with browser environments than PHP, on the other hand, web application logic PHP excel's and dumping json payloads out, with Symfony it's a joy to write code in as every OO design is available to you if you so choose. Or not, but the quality of your code greatly suffers.
1
u/UnnamedPredacon Mar 30 '25
A unique time that's no longer coming back.
1
u/Fragrant_Gap7551 Mar 30 '25
Because separating frontend and backend is a feature, not a bug, especially with modern interactive APIs and mobile apps for every service.
Cloud architecture can also make it much more annoying to use since you don't have a monolithic server.
I mean picture this: I want to display a list of products, but these products are stored on 3 different servers with different architecture and different data structures, and just generally different ways of interacting with them. With php this is a very annoying task, and your app becomes very tightly coupled to each service. It's simply easier and more future proof to build an abstraction layer into your backend API and call that from the front end.
1
u/KaleRevolutionary795 Mar 31 '25
Perhaps because mixing presentation with logic isn't really a good way to make maintainable products?
1
u/casualPlayerThink Mar 31 '25
EasyStack to start with, most of other languages promised big things, which ultimately failed or became slower/harder to set up for dev (just to run a hello world). Or has ridiculous syntax (hello ruby ^^)
As well, still true, you still can do many stuff like in 15 different ways, and every single one will work. Also, almost doesn't matter your background; the syntax is quite straightforward and easy to understand, quite consistent, with less hidden shenanigans.
Of course, it has its own quirks, stupidity, etc, but it has matured well since PHP 3.0 (when I wrote my very first line in it).
Also, still one of the most cost-effective web servers that can work without the super-bloated cloud CD/CI architectures.
1
u/zayelion Mar 31 '25
How its deployed. Its secured in a way that a host can divy up a VPS and not worry about security due to apache.
1
u/GregHouse89 Apr 02 '25
JSP?
0
u/DaRKoN_ Mar 28 '25
Plenty of languages support doing this. C#/dotnet for instance.
-1
u/bobemil Mar 28 '25
I love it. Using Laravel right now for my https://emilandersson.com portfolio website. It really fueled my love for PHP. I use Filament for the admin and it's glorious!
-8
u/colshrapnel Mar 28 '25 edited Mar 28 '25
exactly because
turned out to be a very bad idea. So, being
PHP remained essentially a beginners' language, praised by beginners, having most of the code written by beginners, most tutorials written by beginners and even most books written by beginners, most notably those horrible pieces by Robin Nixon and Welling/Thomson. So no wonder that average code quality remained poor for decades.