105 points · by theThree · 2y ago · 119 comments
With PHP to move my code to a production system I just need to run `git pull` and the new codebase is instantly live. No builds, no server updates.
The Markup system of PHP is also very very handy. No more messing with handlebars or external libraries.
Realistically you can start a small site with PHP and HTMX and no external PHP package dependencies in an evening.
> designed to be practical and useful, rather than attractive.
It gets the job done. Really well.
definition of "functional" is "designed to be practical and useful, rather than attractive"
I spend most of my time writing GO now.
Go + htmx + tmpl is all you need for a basic site. The go runtime produces binaries... While you're still installing php and a web server, my binary is already running and in systemd.
Need validation, grab validator. Need a DB, grab sqlc and write sql and then have the code for your API calls generated for you!!! (This bit of code generation feels like magic candidly)
Need a command line tool? GO.
Have to build a Key Value store? GO
Want to build a database? GO
Do you need a container deploy system ... well Kubernetes is already in GO...
There was a magic to LAMP and PHP 4... it was the right stack at the right time. When I work in go now I feel all that magic again.
It’s basically Java 1.2, sold in “Unix-flavor”, somehow making it acceptable to the people that otherwise hate to touch anything non-C (and in extension, never having used anything more modern)
I like Rust, and zig. Both end up with better performance than go. All three will output portable binary.
I like Ruby and Django. I can get a V1 site out faster than I can with go.
Java is java. Its great if its huge, but hard to do "simple" in java... and the specter of "is this the year oracle fucks every one" looms large in the java ecosystem.
The compile/test loop for GO is stupid fast. How go deals with dependency is fist class. Go nailed concurrency model has found a sweet spot between safety, ease of use and developer performance that is unmatched.
Go is the "brutalist architecture" of programing. Most people look at it and go "why" but if you embrace it, and adopt it, there is an effective sensibility that you're not really getting elsewhere.
On another note, whether or not I can make a database in Go is irrelevant. We're talking about replacing PHP, a web language. Why would I need my web language and database language to be the same?
Well over a decade old.
>> If third party libraries are important to you, it's hard to recommend Go over PHP.
There are plenty of third party libraries for go. This is where most of Go departs from PHP/java/ruby. Php/ruby you might look to something like larval or rails. Java had spring/hybernate/struts/grails (there's a lot there). Is there A framework you're going to jump on in Go? No, Go isnt Rails, it isnt omakase. Go has a ton of parts that "just work" and work well together.
You can pick an ORM (gorm) or use code generation like SQLC (magic!). There is a clean validation implementation that covers 99 percent of your use cases and is easy to extend. If you hate that there are 3 solid alternatives. Do you want a custom router, there are lots of choices but the standard library is good enough. How about logging? Works fine out of the box but plenty of choices here too. Auth, Identity and Access control what do you need there is a middle ware for it already or you can build one in 10 minutes. Are you parsing massive JSON files? hey if the standard lib is too slow there's 4 other choices depending on your use case.
Want to recycle all your code for CLI tools or service workers ... go is a hell of a lot more elegant than ruby or PHP for this (better concurrency primitives).
> On another note, whether or not I can make a database in Go is irrelevant.
I have a little project: the web server, the DB the, images, everything. One simple binary, one config file. Im not installing web servers, run times, databases. It's clean simple and out the door. Im playing with a search engine in go that looks like it could be mixed into that same binary and be 75 or 80 percent of what a solr/open search server would be.
Would rails or larval be faster to launch. Sure. Are they going to keep getting features out ahead of go after 6 months or a year. No things are gonna be really even. And when ruby or PHP hits the wall (and they have a point where scaling them stops making sense) then what do you do? Port to java... or go? You could just pick go from the start and scale it all the way out. Binary blob monolith to scaled services you can just stick with go....
Now it's really hard to fix. The std lib already does implicit nulls all over the place.
Kotlin kind of fixed it for Java, and it really helps us.
PHP is old, and makes it easier to forgive it's mistakes. But Go?
They relied on decades old insights of persons who worked on C and Unix. That said, I'm honestly still on the fence about if nil checking is really braindead, or just what it boils down to in the end and the rest like exceptions and Options/Result is just theatrical.
What I don't get is that they are not more pedantic about checking nil errs in the compiler. They error hard during compilation on unused variables, but err checking is simply not done.
The simple stuff is just too boring once you are an expert in the subject.
Later they started to move away from all that with PSR, typed object layer and more es6/py3 set of features.
If you're very much into art, you've probably seen the simple stuff already, and you would prefer to see something that surprises you or makes you think instead of the nth iteration of the same tropes.
But PHP is a tool, and you want your tools to be boring and reliable. (Whether PHP fits the description is a different discussion.)
For example instead of just doing something there are multiple levels of indirection and instead of simply operating on a variable they tend to setup overly complex types that get passed around. Obviously sometimes you need that, but I'm talking about adding this complexity when it's not necessary.
Okay fair enough...
> > I was never able to move from PHP to something else.
But that's why people like PHP, they have little exposure to something else.
People that have experience with langs like Rust, Java or C#, Kotlin, Haskell or Elm, OCaml of F#, they usually do not like PHP. Why would that be?
People who only every have used PHP (and maybe some JS) they are usually the only ones raving about the language.
If you have seen a lot of movies (critics usually have) you are better at judging the merits of movies. Same for languages.
> are better at judging the merits of movies
Their definition of "merit" is "surprises me and brings something new to the table", while a regular person wants "is entertaining". i.e. they are better at judging the merit of something not actually wanted.
Those hinted types are than enforced through an IDE.
Thats just horrendes langauges missuse / misdesign.
If you like strong typing, great, but many popular languages have weak types and dynamic types by design. It’s not some horrendous oversight.
Types are great and they have downsides. Perl, PHP, Python, Ruby, JS, Lua, lisp, objective c are proof that you dont NEED them to have working code.
And what did you mean with "no server updates"? PHP has to be updated and the server processes has to be restarted.
The markup of PHP is a mess, OK js is not much better :D
Sure you can start PHP without any dependency, cause it has a "million" dependencies included.
And yes, i use both. The right tool for the right job.
This is exactly what good/great languages are doing: providing a standard large standard library.
Perhaps what you refer to are great ecosystems of programming languages?
This is not true. You can update a PHP file without restarting your server, and it will run your updated code.
Make sure your .git folder is not "instantly live" as well...
However, it might be a good idea to try languages, that are encouraging different paradigms, belong to another family of programming languages, or are often used for other things than PHP usually is. Try a Haskell, try an Erlang, an Elixir, a Scheme/Racket, a Rust. Languages so significantly different, that they add value for your learning experience as well as enabling you to do new things and get to know elegance in programming language design.
The whole "no build step" was the most underrated factor for its success, because it was such a low-skill tool to pick up.
The tightness of that edit-test-move loop was why I used it, even if the "edit" included "sftp it to a vhost".
That bit is what made it successful & I can't think of anything I've used in the last decade which felt as easy as PHP for that particular style of self-taught programmer.
I have a hard time with people joking about PHP because while it wasn’t perfect back in the day, it’s probably the culminating point of the non elitist computing. PHP was accessible to anyone who had the basics of creating an HTML website (which was a skill any random person could acquire in a day or two).
Also, the people making those jokes are most of the time working on projects with micro services and SPAs everywhere for a boring business app with CRUD and forms. Which I find pretty ironic since a single PHP monolith solved this exact use case 20 years ago.
Nowadays we tend to bring up a whole virtual OS.
An interesting direction in this area might be GraalOS, which might allow running multiple applications in a single OS process, doing the necessary isolation itself. (Not affiliated)
PHP has libraries for compiling SCSS and minifying JS, and filemtime() is very fast. So if you wire them together in just the right way, you can edit any script or stylesheet under the project hierarchy and have them compiled, minified, and bundled together on the fly. Cache the bundle until you edit one of them files again, and automatically bust the cache once you do.
No need to build anything whatsoever, both on the frontend and on the backend. It's like REPL over HTTP.
I use this in production for a system with 3k requests per second that runs in a single Apache+PHP web server and a single 80GB MySQL database. Never needed to optimize anything.
You have no idea how happy it makes me to see someone else was bold enough to try this and it worked for them too.
Simple, maintainable, instant SCSS and JS build pipelines with all the benefits and no drawbacks! Plus any junior can understand and change it in minutes.
If you do compiling and minifying, that's a build step.
While it was always easy to debug java based apps and the debug support is great (remote connection, drop frames, all types of breakpoints etc.) people struggled with this in php.
I showed a professional a few years back how to debug with php, after 2 weeks he stoped using it...
To build anything useful you quickly discover that it's hard to build from source (both the lang and extensions), some parts unmaintained for years. There are many counterintuitive idiosyncrasies you must deal with to be productive. The ecosystem suffers from the overuse of indirection and reflection. Php only looks easy, but the rabbits hole goes deeper than most other langs.
Sure but the important part here is it’s also easy to deploy to the internet for free or a few bucks.
All you said is right but still, I don’t think there is anything comparable nowadays and if I had to explain to my son how to create a basic non static website without using proprietary PaaS, I’d have a hard time (without PHP).
Was it the best option when you were a company building a product ? idk but at least it was a viable option. Was it the best option for any kiddo wanting to learn creating things on the internet ? Totally and we never got anything better for this since PHP.
Can you give examples of counterintuitive idiosyncrasies you must deal with to be productive?
Nothing comes close to it in Go, Ruby, JS (Node), Python; from what I've seen. Laravel is one step ahead.
Every language is...
I'm familiar with Livewire and have used AlpineJS, but I plan to adopt Qwik (Resumability) as a component in Astro, which addresses frontend performance. One step ahead of others now that I don't have to maintain Go language as a backend which took me months to migrate to TypeScript for a medium size platform.
And then, you'd need to have an ecosystem as strong as Laravel which... wow... would take a _lot_ of investments.
As far as I know, the bulk of this effort has been one developer pushing it along. I wouldn't personally use it but it _does_ exist.
It's also worth noting that these older frameworks all come from a different era of development - nowadays most newer devs seem to want to build microservice-after-microservice, where these don't quite fit into the picture.
I can't really agree with that when Express and Django exists in this world. But Laravel is indeed amazing piece of software
If you run `laravel new my-app`, you got an application with caching, database, queue, views, translations, whatever else you can think of, ready to use with things like Oauth / Payments / E2E Testing / Feature flags / Search... a command away.
You don't get that with Express, you don't get that with Django, from what I've seen (but I'd be very happy to be wrong!)
But yeah Django is nearly perfect, my dream framework is Django officially typed in a world where the python community get its shit together with type checking.
We are not far but I miss having good IDE auto completion and not having errors in my IDE as a reliable source of confidence.
I mean, with Django, literally just defining your database models in models.py and not touching anything else is enough to have a working application with a full featured admin backend with authentication already built in.
If you define your models correctly with the good constraints you are literally left with writing your HTML views and/or API endpoints, adding permissions and call it a production app.
I’ve never touched Ruby but it also sounds like we shouldn’t discard RoR in terms of productivity.
I'm doing some Ruby for work and I hate it with passion every time i have to touch it.
Official tutorial-style documentation for Ruby is largely non-existstant (except for a book from 2002 that teaches outdated stuff from ruby 1.3). Learning ruby is 99% monkey learning, as in reading some random tutorial off the web and then doing some monkey-see-monkey-do. It's awful and it's frustrating.
Python on the other hand is extremely well documented:
* Tutorial: https://docs.python.org/3/tutorial/index.html
* Standard library reference: https://docs.python.org/3/library/index.html
* Language reference: https://docs.python.org/3/reference/index.html
Guess which language is thriving and which is slowly losing relevance?
Laravel is miles ahead of Django, in every single aspect. The template system is incredible while the django one is stuck in the 90s. The integrated job queues, scheduling, asset bundling, etc, etc. And yes, you also have Admin interfaces for Laravel, both paid and free, and they're as good or even better depending how you look at them. Community is also a lot bigger which means more packages and better maintained.
RoR is insanely productive.
I also found, that doing my own plain PHP imports/requires worked better than what WordPress by default wants you to do for example, so I can well imagine, that something similar can happen with Laravel.
Edit: Link that shows only PHP repos: https://github.com/aaviator42?tab=repositories&q=&type=&lang...
That said, I do have some book recommendations and some useful links.
Books:
* PHP & MySQL: Novice to Ninja by Tom Butler
* PHP 8 - Quick Scripting Reference by Mikael Olsson
* PHP 8 Objects, Patterns, and Practice by Matt Zandstra
* Programming PHP (2020) by Kevin Tatroe and Peter MacIntyre
Links:
* https://www.php-fig.org/psr/
* https://web.archive.org/web/20230110234256/https://www.cases...
Nor PHP 4 for that matter.
IMO what PHP has going for it is: (1) no build step, and (2) built in templating. Ease-of-use very high in terms of web development.
I am interested how PHP and frontend tooling will work out in the future. Nobody is compiling JS/CSS with PHP (as far as I see). That is usually done with Node.js. Livewire (and Inertia.js) are bridges. Sometimes PHP becomes a backend to provide an API for an SPA frontend.
Python, C#, C++, and JavaScript are super popular. Ruby, Go, and Kotlin have been getting more popular. Etc.
I know people who are just now getting into Laravel and I'm sure it will remain a valid framework for years. That said PHP's popularity has only been going down since it peaked around 2010. This is reflected in all metrics you can think of.
https://www.tiobe.com/tiobe-index/php/
https://trends.google.com/trends/explore?date=all&q=php&hl=e...
https://insights.stackoverflow.com/trends?tags=php
Ironically, PHP is a pretty awesome language now compared to the days of v4 or v5.
The one area where PHP is useful in 2024 is for prototyping a website quickly. As a one-person team, PHP without a framework (and without OOP) is the fastest way to build a fully-functioning complex site. I built a massively complicated site this way, in very little time. This is great because if it ever becomes popular, I can simply hire developers to rewrite it in the latest framework du jour (probably Next/Nuxt/whatever)