by gregjor · 2y ago · 0 comments
When I have to work with code built on a frameworks -- usually Laravel but I've had to deal with CodeIgniter and several others -- the Achilles' Heel of frameworks becomes apparent: the application gets built around the framework, then framework code and supporting dependencies get updated in breaking ways, and you have to decide to either rework a lot of already working code, or keep what you have and fall more and more behind. That happens with every framework -- I have a project stuck with Bootstrap 3 for exactly that reason.
Go explicitly promises no breaking changes in the language or standard libraries. PHP does not make that promise but has more or less avoided major breaking changes over the years. Why would you give that up to get a little bit of early-stage traction from a framework?
Ideally an application has no external dependencies beyond the language(s) you choose and their standard libraries. Every dependency you add introduces another point of failure out of your control, back-compatibility problems, and possibly the dependency falling into obsolescence, or hijacked for a supply chain attack. I know writing non-trivial web apps without any dependencies seems impossible but I prefer aiming for as close to zero as possible (and carefully vetting every dependency introduced) rather than starting out with a huge set of dependencies such as Laravel or this Go-based clone.
Sockets: Don't use but if I did I wouldn't need a framework.
SPA: I don't write apps that way. Server-side, which is why we're talking specifically about PHP and Go.
Queue handler, scheduler: Can easily do in the database or with Redis.
Container: What? Do you mean something like Docker? That has nothing to do with the web app development language or framework.
Auth: OAuth2 and SAML not a big deal, but maybe worth introducing a dependency depending on requirements. Regular username/password/MFA auth easy to implement, certainly no framework needed for that.
Likewise with routing, "MVC" structure, etc. Frameworks can save some time beginning but eventually you have to debug them, or run into limitations to work around. And one day the framework gets updated and you have to deal with breaking changes.
you should always prefer a codebase optimized for the business, the purpose & the people who work on it everyday. if that requires more time to grasp it for newcomers, perfect. people make that weird argument all the time for going with a framework due to popularity & common ground. that’s so absurd. optimizing for onboarding time & quickest graspability, when that factor is usually irrelevant in most projects.
also, the best thing about modern PHP are the PSRs. They are not appreciated enough. Stick with them. Don’t be clever. Don’t use magic. Be explicit. Don’t don’t repeat yourself. Write code like your mom reads it. Et voilá, your homemade framework is gonna be just fine.
Especially compared to projects built around frameworks by devs who very rarely if ever look at the source code of the magic they use. debugging and fixing those issues took more of my lifetime than the hours i’ve put into updating my personal web app framework (latenight-php).
Also: Choosing which tire you want doesn’t equal reinventing it. And also: thank good people reinvented the wheel so many times… imagine EVs on rolling stones or wooden wheels.
SQL does support code reuse and building layers of abstractions. If you only use SQL through an ORM you won’t get to use things like CTEs and views and user-defined functions, because ORMs by definition deform the relational model and SQL to fit OOP.
In 40+ years programming SQL expertise has paid the bills and kept me employed more reliably than any other language or tool I have mastered.
A framework with all the bells and whistles isn't that great when I want a framework with a piano.
Changing someone else's (meaning an external third-party) code can be as easy and fun with the right tooling, but the tooling around supporting that tends to be really bad in most ecosystems. There is a common assumption found around dependencies that their code is theirs and shouldn't be touched except by the hand of the original author.
Not impossible to overcome, of course, but with enough friction that you have to seriously consider if it beats simply writing your own. A little copying is better than a little dependency, but a where there is a lot of copying...
Both PHP and Go already provide the framework as part of the standard installation. Everything else you need should be pluggable libraries. If developers are pulling shenanigans with those libraries to try and make them frameworks, beware.
I meant to make the point that frameworks come with a cost, which may get deferred for a while. Maybe that doesn’t matter. For PHP and Go specifically I don’t see the point since the languages have everything you need out of the box.
Bootstrap 3 is a perfect example of why you wouldn't pick a UI framework, if you have demands for pixel-perfect design or custom animations you'll be immediately battling the framework in those areas. That doesn't mean all frameworks are bad, like graphic designers rarely use MS Paint and draw each pixel because it would take forever, i.e. you're not being an efficient engineer. If you're building a house, why make bricks yourself, chop trees for wood, or forge custom roof tiles?
To me, PHP / Go are themselves abstractions of an enormous amount of complexity, so why stop there, why not go as high as you can imho, higher = less code?
When you work without a framework, you invent your own framework. It won't be as well thought through - guaranteed. When changes come in, the sheer amount of code means mistakes will be made and your code will slowly turn into spaghetti. If this is a custom FFMPeg conversion service - totally worth it. If it's CRUD, like how 90% of apps are CRUD, then it's probably a mistake.
As I told another programmer, using a framework doesn't mean you are a "semi-skilled" programmer (what elitism). It means you know you aren't special, you aren't smarter than other programmers, you know your own limitations, and know that using a framework other people understand (and keeping the amount of code to a minimum) is the best for your company and the project.