r/PHP • u/lordmyd • Sep 25 '21
Developing with procedural PHP.
Not all of us are fans of OOP boilerplate and ceremony. PHP is a perfectly fine procedural language and a well-organised procedural codebase can be easier to manage in many ways. So, is anyone developing with procedural PHP beyond single-file scripts?
30
u/Otterfan Sep 25 '21
Could you point to an example of some well-crafted procedural PHP? That would help us have common ground for discussion.
4
u/Hjine Sep 25 '21
Could you point to an example of some well-crafted procedural PHP
I have procedural project still ashamed publishing it :)
2
0
-16
u/lordmyd Sep 25 '21
I was thinking of client projects of my own so the code is proprietary.
6
u/therealgaxbo Sep 25 '21
It would be pointless anyway, because (as you're probably discovering) most people here believe that anything that isn't OOP is bad axiomatically.
Demonstrating good procedural code would be as fruitful as Leela demonstrating she has the will of the warrior.
-16
u/lordmyd Sep 25 '21
Yes, you get the impression with some OOP die-hards that they don't even know an alternative exists.
23
u/Sentient_Blade Sep 25 '21
Calling people "die hards" is not going to win you any arguments here.
You have so far failed to provide any evidence to back up your implicit claim that OOP is wasteful and convoluted ("not fans of OOP boilerplate and ceremony").
Saying you have code to prove it, but you can't show it, is not meaningful evidence in a public debate.
1
5
u/Nerwesta Sep 25 '21
Usually you get to learn how procedural coding work before switching to OOP, I'm sure those "die-hard" are well aware on procedural coding in a way.
That's how I learnt PHP at least.
-1
u/lordmyd Sep 25 '21
Not really. There are a lot of developers who learned Java, C# or PHP5+ as their first language and went straight into industry without any awareness of alternatives.
3
u/Nerwesta Sep 25 '21
That's the problem when we talk about our experiences, I seriously doubt your developers tops the gigantic number of juniors who started the well known HTML/CSS/PHP combo back in the days.
Of course what you say is still true, hence my "usually" on my previous comment. On a serious school however, they get to know what procedural coding is on their first step into PHP, in Western schools at least.
16
u/chevereto Sep 25 '21
PHP is a perfectly fine procedural language
As any* language, but the problem as someone already mentioned is that to maintain those codebases is a pain. But this is not black and white stuff as in any subtle complex system you have to embrace several paradigms... Why stick to one paradigm in a language which support multiple paradigms?
0
u/lordmyd Sep 25 '21
I simply asked who was developing in procedrual PHP, that's all.
7
u/chevereto Sep 25 '21 edited Sep 25 '21
Sure. I did procedural for a lot of time, the first 5 years or so of my journey I delivered only procedural code. Back then I never saw the point of OOP. Just as many peers who also hated/feared OOP.
At one point my codebase was so big that procedural became a nightmare. I didn't jump in right away to OOP, I was stubborn many years against it.
My statement came from real use case of software that I sell directly to my customers, which I deliver myself. I don't know your context.
1
u/HorribleUsername Sep 25 '21
Have you ever seen any procedural lisp code? Let alone perfectly fine procedural lisp. Most languages maybe, but I think any is a stretch.
1
u/sgtssin Sep 26 '21
It is litterally the stuff of nightmare. Unfortunately, i have worked in such a nightmare.
18
u/AegirLeet Sep 25 '21
Personally, I've never seen a procedural codebase that wasn't a complete mess.
So until someone can prove to me that it's possible to write procedural code that isn't utter dogshit, I will assume that all procedural code is, in fact, utter dogshit.
3
Sep 25 '21
Good procedural codeebase tend to adopt some concepts from OOP, but not all of them.
There's a reason why bigger codebase are usually built with OOP... lol
-5
5
u/OMG_A_CUPCAKE Sep 26 '21
well-organised procedural codebase can be easier to manage in many ways
name one
0
1
Sep 27 '21
SQLite: https://github.com/sqlite/sqlite
PHP: https://github.com/php/php-src
BoltDb: https://github.com/boltdb/bolt/
Almost any large scale, quality golang project.
Almost any large scale quality C project (see Linux Kernel).
42
u/Sentient_Blade Sep 25 '21
Leaving powerful and well-understood capabilities on the table is not something to be proud of.
You have said that "well-organised procedural codebase can be easier to manage in many ways", so the floor is all yours, prove it.
3
u/Notimecelduv Sep 25 '21 edited Sep 26 '21
The thing with PHP is that it doesn't have modules. You can't just define all your functions in one place and import only the ones you need elsewhere. You have to require the entire file even though you might already have required it another file that you're requiring. OOP with its namespace system solves this issue for you.
-3
3
u/d0nth4x Sep 25 '21
What? Give us one purpose to use php procedural. How can I write tests for that apps?
5
u/lordmyd Sep 25 '21
The same way developers test in other procedural languages such as C and Golang. There's nothing about OOP which makes testing easier. In fact well-designed functions are arguably easier to test.
12
u/therealgaxbo Sep 25 '21
SQLite is rather famous for being one of the most thoroughly tested pieces of software out there, and is written procedurally in plain old C.
Why on earth would one think that OOP is somehow a prerequisite for testing?
0
u/AndrewSChapman Sep 25 '21
Indeed. Yes of course you can test functions, but you can't mock a damn thing without classes, meaning you're going to be integration testing a lot of things rather than unit testing. This may be fine for small code bases, but once you start having to wait 30 minutes for your test suite to finish every time you refactor something, you'll be hating your life choices.
2
u/lordmyd Sep 25 '21
What? You only needs mocks because you opted for OOP. How do you think developers test large C codebases? I think you've been living in an OOP bubble for too long.
1
u/MorphineAdministered Sep 25 '21
How do you remove side-effects from your (procedural php) tests then?
1
u/AndrewSChapman Sep 25 '21
Say you have function A. Function A has business logic you want to test, but it also calls functions B and C. How do you prevent the calls to function B and C? In a unit test we want to test only 1 function at a time.
1
u/przemo_li Sep 27 '21
Pass B and C as arguments.
Assuming you actually have to. In OOP we have classes and it make sense to test those separately. Procedural can follow coherency. Tightly related can be tested together regardless where stuff is.
This pattern of providing "dependencies" as arguments extends easily to whole program, check "Handler pattern".
This also similar (but different) to Dependency Injection.
At least testing is the same- good codebase encapsulates externalities you don't want to test, and tests cohesive units is code together. When even more granular testing is needed, then lower level later can be extracted and tested directly.
1
u/AndrewSChapman Sep 30 '21
This sounds a bit nasty in the context of procedural programing. I've never seen functions being passed around as method parameters in PHP where it doesn't significantly increase the cognitive load when you try and read the code to see how to use it. Do you have an example of this that you think is a good example?
1
u/przemo_li Oct 02 '21
Functions passed to other functions have to follow contract.
By default PHP do not let us specify such contract in any meaningful way :( But that is on PHP quirky development process.
Use any type checker out there and suddenly each argument that must be a function, can have its arguments specified and return type too. Its like interfaces but for functions. (That's why Java got "functional interfaces", but please do not use that name. "Functions type" already is native to PHP and is precisely what function argument/return type are!)
With that out of the way, (and if we disregard autoloading), functions are no different then accepting whole object that implement single method interface. Take that argument, in turn prepare its arguments, run it with those, do something with returned value you got. That description holds true weather we use callable, or explicit object with method.
Above is separate topic to dependency management. Pretty much any good OOP codebase will have some dependency management. They are of similar complexity to that idea of passing callables to functions. Though passing dependencies around in procedural code by necessity is explicit, where as good dependency containers will remove big chunk of that from OOP codebase.
1
u/crabmusket Sep 27 '21
Pass in B and C as dependencies to A, same as you would if A, B and C were objects.
0
Sep 25 '21
[deleted]
1
u/AndrewSChapman Sep 25 '21
That's a good thought, though this sounds a bit cumbersome to manage in a large code base and my end up creating the boilerplate and ceremony that was originally stated as the motivation to not use OOP. Do you know an example project where this method of testing is done?
0
11
u/BradChesney79 Sep 25 '21
I am perfectly happy writing procedural code for something throw away or a proof of concept or anything small that will never need to be bigger.
Basically anything that needs little to no maintenance for its entire life. Okay.
But, outside that sliver of work in the pie chart, OOP for me.
4
u/cerad2 Sep 26 '21
Sure but I still enjoy the ceremony. I always wear robes when programming and burn plenty of incense. Used to sacrifice a goat before final deployments but they seem to be getting harder to find.
1
u/wherediditrun Oct 02 '21 edited Oct 02 '21
You can write procedural-esque code with OO semantics just fine. See PHP doesn't have polished module system and uses DI / OO encapsulation to achieve that result.
And that's essentially what a lot of programmers do. Using stateless services and inertic data on which the procedures defined in stateless services operate.
The only thing which is OO in that set up is late function binding (new keyword is required in instantiate the function).
I think you're mistaking something which is commonly known just as spaghetti code for procedural paradigm.
1
1
u/scottrichardson Nov 24 '22
Yes. Absolutely. I run a boutique web design and development studio, and we specialise in actual 'custom' websites. No WordPress, no Shopify. Actual, hand coded websites. Over the years we have developed our own PHP front end framework/boilerplate/starting point, along with a PHP CMS framework for managing the websites.
It's all procedural, and it's actually beautifully coded. Small, concise functions which call on other, small functions, with easy to understand naming conventions. We built our own database abstraction layer for most queries so we don't have to repeat tons of common query code, and we handle CSRF and other middleware security tasks. We have separated out our page controllers from our templates, and we have separate functions files for each page or section on a site/app.
HTML templates are just PHP files mostly consisting of HTML and references to dynamic content by way of a page content array such as $text[] or $images[]. The templates often include some spaghetti PHP for looping through items or calling on functions to render shared blocks or blocks of content with some complex logic required.
We have a startup.php file that works like a bootstrap/autoloader on each page which loads in globally required functions such as asset handling, session stuff, database stuff, and other things we need on every page.
We have built a solid business model around building custom solutions. And our websites typically load considerably faster than competitor Wordpress sites, and our markup is insanely lean and clean, free from huge class selectors and nested divs. Even just comparing a typical Wordpress 'contact' page with some contact info and a form, the rendered markup lines of code is about 3000-5000 versus about 300-500 for ours.
Anyway, I know you posted a year ago, but came across this when searching for other procedural PHP frameworks and felt compelled to comment and add some of our own experiences with it.
Cheers, and happy coding.
Scott
1
u/lordmyd Nov 24 '22
Great to see someone has managed to buck the everything-OOP trend. Curious, though, how you compete with the massive WP plugin ecosystem.
5
u/zmitic Sep 25 '21
well-organised procedural codebase can be easier to manage in many ways
To be honest, I doubt you understood the point of OOP. You could put procedural functions in classes and call it OOP but that is not the point of all.
Not all of us are fans of OOP boilerplate and ceremony
This is not a matter of being a fan of something, it is a matter of maintenance and readability. Use some existing library as reference, not those famous and useless class Dog extends Animal examples.
1
u/boringuser1 Sep 26 '21
I've never seen a good example of OOP in production code. Also, never seen anybody like yourself coherently elucidate the philosphical difference between procedural code and OOP. There isn't one.
3
u/zmitic Sep 26 '21
I've never seen a good example of OOP in production code
That doesn't mean it doesn't exist, it only means that you haven't seen it.
I did.
1
u/WikiSummarizerBot Sep 26 '21
An argument from anecdote is an informal logical fallacy, where anecdotal evidence is presented as an argument; without any other contributory evidence or reasoning. This type of argument is considered as an informal logically fallacy as it is unpersuasive - since the anecdote could be made up, misconstrued or be a statistical outlier which is insignificant when further evidence is considered. This fallacy can often be found in conjunction with the hasty generalisation fallacy - where the hasty generalisation is made from unsubstantiated anecdotes.
[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5
3
Sep 26 '21
[removed] β view removed comment
0
u/boringuser1 Sep 26 '21
A philosphical difference. It's an illusory difference.
3
Sep 26 '21
[removed] β view removed comment
-1
u/boringuser1 Sep 26 '21
It's more than a little irritating that you're calling me a "beginner" when I'm a literal professional developer. It makes me doubt that you are.
3
Sep 26 '21 edited Sep 26 '21
[removed] β view removed comment
2
u/boringuser1 Sep 26 '21
All programs follow a "procedure". There are no exceptions to this. The notion that there could be a program that doesn't follow a series of steps to carry out goes against basic philosophical logic.
The only difference is that OOP is a methodology that forces loosely favorable procedural conventions. This is more or less not offensive and maybe even acceptable, but to claim that significant, irreplicable advantages are derived from this is wrong. Often, class syntax is overly verbose, has its own conventions syntactically different from the language, and is overloaded with features that good developers don't use.
Yes, OOP in PHP is more or less necessary because the language isn't designed with proper support for other programming patterns. This doesn't mean that OOP is philosophically advantageous, just that the literal class syntax has home field advantage.
If OOP had proper functional support, factory functions are far more intuitive and flexible than class based syntax.
6
0
u/Hjine Sep 25 '21
0 points (48% upvoted)
Interesting a lot of OOP lovers.
-4
u/lordmyd Sep 25 '21
Zealots might be more accurate. I'm watching my door for the arrival of the Spanish Inquisition.
0
u/Hjine Sep 25 '21
I'm watching my door for the arrival of the Spanish Inquisition
OMG, you should be Youtuber, not Redditor, believe me such comment will lead thousands of subscribers to you, people loves drama .
3
2
u/gordonv Sep 25 '21
With advanced sequences, I make the process modular. Sometimes spanning different programming languages.
Like, I gather system and network info in powershell. I output it to JSON. Read it in with PHP and render my graphs.
Ironically, the powershell scripts are OOP. I'm dealing with multi-threading. The process manager itself is Powershell for the data. The "view" is in PHP and static HTML (This is mostly rendered from the powershell).
2
u/BradChesney79 Sep 25 '21
...I do piecemeal also.
But my base is native bash. That might call a nodejs script for Internet calls or a python script that handles some math or spin up a temporary PHP websocket for a quick bidirectional secure data negotiation. Computers negotiate so much faster than people. The terms are already set before the two systems "talk".
Right tool for the job. Single responsibility principle.
2
u/boringuser1 Sep 26 '21
OOP often feels like a fake facade for good code.
A REST API isn't complex. Fin.
1
2
Sep 27 '21
Really disappointing to see yet another example of hive mind in the comments.
Do you people honestly feel like there are no procedural codebases out there which are tidy?
Have you seen any large OOP projects? If you have, you would have also seen some of them are a complete mess.
No matter which one you use, if you are a shit programmer, the code will be organised badly.
3
u/AegirLeet Sep 27 '21
Do you people honestly feel like there are no procedural codebases out there which are tidy?
Just show us one. Shouldn't be too hard if they actually exist, right?
1
Sep 27 '21
As in procedural code in general?
There are plenty of non-php examples.
That is kinda the point OP is making, procedural PHP codebases are now fairly rare and if they exist they often are at private.
For non-php examples, the PHP codebase (written in C) is well organised, as is SQLite:
https://github.com/sqlite/sqlite
Also, look at just about any Golang codebase, as golang is most procedural.
2
u/AegirLeet Sep 27 '21
This thread is about procedural PHP, so I'm obviously looking for good procedural PHP code - not code in some other language.
Yes, OOP is way more popular these days. But with 300k+ packages on Packagist, surely, there must be one good procedural codebase among them. Just one.
2
Sep 27 '21
Procedural is just a style of coding, it is pretty irrelevant if it is in PHP or a language you made up yesterday.
You are saying clean procedural codebases do not exist, which I have demonstrated is totally false.
The OP position was expressing disappointment that OOP mindset dominates PHP.
2
u/AegirLeet Sep 27 '21
Procedural is just a style of coding, it is pretty irrelevant if it is in PHP or a language you made up yesterday.
Nonsense. Not all languages are the same. Different languages are geared towards different programming paradigms. Why would you do OOP in a language that has no notion of objects or functional programming in a language without first-class functions? Just try and do some purely functional programming in PHP. Hint: It won't work very well.
So the choice of language is very much relevant. This is a thread about procedural programming in PHP, so clearly, we should be looking at what procedural programming in PHP looks like. Why should someone writing PHP care about what kind of programming paradigm works or doesn't work in some other language? It's irrelevant to the question at hand.
You are saying clean procedural codebases do not exist, which I have demonstrated is totally false.
I am saying that I have never seen a good procedural PHP codebase. I'm not making any claims about procedural programming in general or about any language other than PHP.
It's entirely possible that good procedural PHP codebases exist. According to you and some other people, they do. OK, fine - show us.
1
Sep 27 '21
Fair, but the point still remains. In some languages you have the flexibility to go either procedural or OOP. PHP is one of those.
Something like Java for example, you are forced into using OOP.
I am saying that I have never seen a good procedural PHP codebase. I'm not making any claims about procedural programming in general or about any language other than PHP.
You didn't make that clear.
It's entirely possible that good procedural PHP codebases exist. According to you and some other people, they do. OK, fine - show us.
You know I don't have an example in PHP, I have already explained this. OOP is how most code since PHP 5 has been written. Whilst you can write procedural code in PHP, most new tutorials etc take you down the OOP path.
The whole post is why there isn't more procedural code given it is possible to write procedural code in PHP and it would avoid some of the OOP messes that can be written in PHP.
So do we agree:
Procedural code can be well written and organised, as exhibited by the examples, albeit in other languages.
There isn't a strong candidate that we both know in the PHP language.
Have I got that correct?
2
u/AegirLeet Sep 27 '21
Procedural code can be well written and organised, as exhibited by the examples, albeit in other languages.
Probably.
There isn't a strong candidate that we both know in the PHP language.
Yes.
2
u/cerad2 Sep 27 '21
My takeaway of the OP's position was somewhat different. To me it seems they fell under the heading of "my way is better than your way but I am not going to show you my way". Oddly reminiscent of several other posters here.
I'm perfectly willing to accept PHP procedural code might have advantages over OOP. But not when there is a refusal to show any code.
1
u/serialmasturbator Sep 07 '24
I'm programming in one form or another for 30+ years and I've had the privilege to work mostly alone. I've been a freelance developer, then made my own publishing company and now I run several successful online stores built on my own platform - with all the modern bells and whistles. I've always coded procedurally in PHP, but I've permanently forced myself to learn new things.
I understand OOP and I've dabbled in it, but I've never had the need to switch to OOP. My code is fast, tested and secure. Everything I've ever wanted to code I was able to, I've maintained very large codebases I wrote, I've made very large and trafficked websites that ran fine on underpowered hardware and all that without using any OOP. I've taken it to such extremes that if I ever need to use a library I usually take the parts I need from it and rewrite them procedurally using the simplest features of the language. In the end it all boils down to discipline, making some sane conventions and following them.
To me OOP always looked like a religion - something people take for granted and never question. While OOP might be a fine way of doing things, it's not the only way. Unfortunately the industry is too set in its ways. Radical changes would hurt productivity too much and we wouldn't want that. Programming seems more and more like a factory job nowadays rather than the art form it used to be - just take pre-made pieces and assemble them like Lego or Ikea furniture.
1
u/usernameqwerty005 Sep 27 '21
What's harder to write: A good class or a good function? A coherent collection of class methods, or a collection of functions that are composable and testable?
Also mocking.
1
u/ltscom Sep 27 '21
Still managing some big legacy procedural code. It can be a highly productive paradigm but I generally prefer a well structured OOP project to a well structured procedural project
That said, I'd probably prefer a well structured procedural project over a spaghetti mess OOP project.
1
u/maus80 Sep 27 '21 edited Sep 27 '21
I've written a lot of procedural PHP and I still do, but judging from the hostile comments in the thread I'd rather not admit that. You may make classes in namespaces with static methods to act as function libraries. That scales really well and there is IMHO no technical reason this is worse than coupling your data and your procedures. Here is an example of a Templating class that I wrote (that way):
https://github.com/mintyphp/core/blob/main/src/Template.php
One could also write this code in an OOP way, but I don't see the benefit of doing that.
NB: No-one can explain this topic as well as Brian Will: https://www.youtube.com/watch?v=IRTfhkiAqPw
1
u/benelori Sep 27 '21
Not really, procedural code doesn't scale well in my experience. Not in php anyways. Functional programming is also fun, and I try to use it as much as possible in PHP
1
u/crosenblum Sep 29 '21
I prefer a balanced approach.
Not a fan of oop myself, but it has it's use-cases, like for code reusability.
I create classes with functions to have regularly used functions accessible to any of my php files.
I am not using any framework, just vanilla php, with classes/functions.
I do plan to learn some framework, someday soon.
P.S. I have zero to no interest in getting involved in a flame-war about oop vs procedural. I am just sharing my opinion, your free to share yours. But no wars or flaming please.
Thanks
1
u/ryantxr Oct 03 '21
Itβs not at all about being a fan of anything. Itβs about getting more done, improving reusability, and making collaboration easier.
1
u/mission_2525 Oct 13 '21 edited Oct 13 '21
For many years I did not really get the purpose of OOP and was sticking to a strictly procedural, PHP functions based programming. I simply could not wrap my mind around the OOP concepts. Once I got it, I continued to develop most of my code-base in a procedural-esque fashion but with a heavy use of classes, inheritance, polymorphism, method overriding, design patterns and the implementation of a passive MVP architecture (model, view, presenter). Everything is now multi-layered, modularized and the code is quite DRY (don't repeat yourself). This switch saved my mental health in a code-basis which consists now of 1000+ proprietary classes and thousands of classes from external libraries. In my understanding it would be impossible to achieve the same results without making use of OOP functionality although the underlying domain logic is still quite sequential and procedural-esque.
1
Sep 25 '21
A lot of projects are written just fine without OOP. Besides purely procedural there are also purely functional written projects. The biggest example of a procedural project is perhaps the Linux Kernel another PHP itself. If you want to learn something look at the conventions for example the Kernel uses to make procedural code more maintainable.
1
u/przemo_li Sep 27 '21
Linux kernel is special case.
It really, really, really needed reliable compilers everywhere. C++ just want there, at the time. LK did not shy from OOP concepts though, with multiple subsystems making good use from object model available in Kernel. You just don't see keyword "class" anywhere ;)
Linux Kernel is mixed paradigm code base.
1
u/hoopdizzle Sep 25 '21
So much of our infrastructure is powered by C. But so much of everything on top of our infrastructure is powered by Java. There's a time and place and personal preference for everything
1
u/mildweed Sep 25 '21
Not for anything I need to maintain long term. Writing automated tests for procedural is muey difficult.
1
u/brazorf Sep 25 '21
You should maybe add some evidence to back your point, otherwise this is just kind of /r/unpopularopinion which leaves a reader with that meh feeling and does nothing constructive
0
Sep 25 '21
[deleted]
-15
u/lordmyd Sep 25 '21
So, by your reasoning, anyone who dislikes OOP boilerplate and ceremony is simply inexperienced? Let me see, that would include the creators of Clojure (Rich Hickey) and Erlang (Jo Armstrong). I think you're on shaky ground.
15
u/Otterfan Sep 25 '21
Clojure and Erlang are far from procedural.
-11
u/lordmyd Sep 25 '21 edited Sep 25 '21
Your argument was directed at anyone who dislikes OOP boilerplate and ceremony, not practitioners of procedural programming per se. Venn diagrams can be useful.
0
Sep 25 '21
[deleted]
6
u/Notimecelduv Sep 25 '21
I wish more of the PHP ecosystem was written in a procedural way.
PHP started off as a fully procedural language. When OOP features were introduced, people willingly started using them even though they could keep writing entirely procedural PHP if they wanted to. I don't think you realize just how ignorant your comment is.
-5
u/lordmyd Sep 25 '21 edited Sep 25 '21
Top-to-bottom style a la Facebook is imperative rather than procedural.
The hate is because OOP, especially the Java/C#/PHP variety, is like religious fundamentalism and questioning it is akin to blasphemy.
I think Ruby is close to Alan Kay's vision of OOP though not perfect.
7
Sep 25 '21
The hate is because OOP, especially the Java/C#/PHP variety, is like religious fundamentalism and questioning it is akin to blasphemy.
If you drop comments like this and don't understand why people "hates" your opinion, there's nothing we can say that will make you realise the agressive tone you're using...
OOP is not the brainchild of some random developer who simply wanted to make everything complex. There's a reason it exists. It does not make procedural bad... but if you're trying to force procedural in scenarios where OOP is better, you are going to face opposition.
-1
u/lordmyd Sep 25 '21
If you re-read the thread you'll see the "hate" reference was quoted from the parent.
2
Sep 25 '21
Thanks for proving my point.
The issue isn't "hate", but you seeing it as a blasphemy to talk against OOP. You're entering the discussion with the opinion that people will attack you. Which, in return, make you agressive from the start.
THe parent comment does not talk about "the blasphemy of talking against OOP" at all. Re-read it, re-read yourself.
0
Sep 25 '21
[deleted]
1
u/Sentient_Blade Sep 25 '21
Can you explain "language's brand of OOP".
PHP OOP is comparable to most other languages with the exception of generics and maybe accessors. Please provide examples.
21
Sep 25 '21
[removed] β view removed comment
-4
u/Hjine Sep 25 '21
Take a look at the Wordpress codebase
yes WP codebas are terrible but for some small tasks users can easily get into it core and modify it functionality
9
Sep 25 '21
And create a maintenance nightmare which will lead to security issues in a couple of months/years by the lack of updates.
"Well managed procedural" usually looks like OOP but without "deeper" OOP concepts. There's a reason why complex codebase tend to do that...
2
u/dirtside Sep 25 '21
Yeah. People often conflate OOP with "uses classes and objects." They're not precisely the same thing; in my experience going with "pure, real" OOP usually creates more headaches than it solves, but refusing to use classes and objects at all is just insanity.
1
Sep 25 '21
in my experience going with "pure, real" OOP usually creates more headaches than it solves,
That usually happens when a dev tries to force a concept that is not really needed in a problem.
Every time I used OOP, it was solving a ton of issues and creating not that much in return... but every time we used some "OOP concepts", we made sure it was required and not just our dev brain who wnated to be fancy.
Good OOP is exactly like good procedural, it's hard to do.
0
Sep 25 '21
[deleted]
2
u/przemo_li Sep 27 '21
Modules. You describe modules rather then namespaces.
Encapsulation is defining feature (and they are trivially autoloadable).
46
u/jpresutti Sep 25 '21
Not willingly. I wrote an IRC services package in PHP 100% procedurally and it was beautiful - for about fifteen minutes. Maintaining it over the past eleven years has been a pain.
Which is kinda ironic since I authored an answer on stack overflow years ago extolling the virtues of procedural code over oop.