#StandWithUkraine

Three ages of WordPress code

I begun to think about my progression with WordPress development as couple of major hops. It is not something I felt as it happened, but retrospective brought some clarity to it.

So what where the hops between? I came to define it as ages of WordPress code, both for timeline and progress aspects.

After some pondering I had come up with three.

Procedural age

Procedural (consisting of functions) code is old and fundamental layer of WordPress core. Commitment to backwards compatibility had kept it in focus and growing for many years.

It influenced WordPress extensibility with hooks system and theme development with Template Tags API.

I credit Template Tags API with much of WordPress success. It offers low learning curve and makes it trivial to start tinkering.

But procedural code encourages mere memorization and code reuse over actual development. It had spawned thousands of functions and endless plague of code snippets.

Procedural breakdown

Pro

  • easy to get started with
  • gets things done

Con

  • verbose
  • hard to document
  • technically shallow

Faux OOP age

Once you dig a little deeper there is a layer of class/object code in WordPress too. The nuance is — it is far from what would actually be considered object–oriented.

WordPress core (and code in general) tends to use classes as pseudo namespaces. The code is rife with god objects and permeated with global state/variables.

It is an incremental improvement over procedural ways. Yet the resulting blend of code is close to procedural and just short of more conventional OOP. It makes a challenging learning curve hike and falls short on delivering benefits.

Faux OOP breakdown

Pro

  • improvement in code organization
  • transition to development

Con

  • is not actual OOP
  • high code complexity
  • spike in learning curve

Modern age

In these circumstances the modern code can only happen in extension space.

It is driven by more freedom, more relevant workflows, influence of larger PHP ecosystem.

It happens as WordPress developers start to make sense of how larger PHP world works. Or PHP developers get involved with WordPress.

The two directions are quite distinct and rarely see it the same way. Diverging trends between and inside communities make it hard for dominant style to emerge.

That and lack of technical leadership from core creates a landscape of flavor–driven code. It is a relative improvement (again), and another major spike in learning curve.

Modern breakdown

Pro

  • real PHP and its ecosystem
  • access to modern practices and experience

Con

  • extreme fragmentation
  • disconnect from core development

Ecosystem impact

I had heard it said many times that “WordPress is a gateway drug to development”. I might have repeated it myself in the past.

I had come to believe that it is wrong statement. WordPress is a fantastic and empowering at initial involvement with coding and tinkering.

Learning curve goes up from there in inconvenient spikes and bubble of legacy code base. That works against progression towards serious development competence.

This doesn’t mean everyone has to be a developer. It fascinates me that small groups have leverage to empower many others with technology.

But there needs to be enough developers and I feel WordPress is falling short.

The amount of contributors to each release of WordPress core is in low hundreds. That is tiny number for the project that claims to power quarter of the web and aspires to power more than half.

At WordPress Stack Exchange the lack of expertise remains our main problem and challenge. At the moment top 135 users (0.25%) hold 30% of total reputation.

This imbalance created ecosystem of code, held together by duck tape and positive thoughts.

What is next?

I believe that future of WordPress code is in combination of its own power with that of PHP ecosystem.

It is important to take that blooming growth of modern PHP. It is important to keep that wonderful simplicity of involvement that WordPress offers.

Collaboration and finding that right blend, over competition and knee–jerks over right ways.

We need code that not only gets things done, but educates people and pushes them forward.

I aspire to find code like that, I aspire to write code like that. I hope to look back one year and see an age of code like that.

Related Posts

5 Comments

  • Julien Maury #

    Great read, I feel related to this... you know some way :) We (team work) use now composer, autoloading, namespaces and it's great, we have our plugin generator and project generator so we save time or at least we do not spend time for boring things anymore :) But this core thing is a huge concern to me. As you said "disconnect from core development" could be the price for a "better/faster/stronger" code. Who's the culprit ? When you look into the core files you see choices. What's the best way ? "low barrier to entry" or "Pure technical thing" ? I guess we cannot have it both ways, maybe something more like "half way". If it's about me I push my ambitions to the limit even if it seems already lost, but I've started to teach WordPress and I realized even very simple PHP code is difficult to understand for some students. So how you do this... pushing them forward because it's always better, ok, I agree with you but kinda elitist what about the other 70% ? Not sayin I'm the truth, in fact it's hard to choose but to note that we have to.
  • Weston Ruter #

    Once you dig a little deeper there is a layer of class/object code in WordPress too. The nuance is — it is far from what would actually be considered object–oriented. […] In these circumstances the modern code can only happen in extension space.
    The Customizer actually has quite a bit of “modern” OOP code.
  • Andrey “Rarst” Savchenko #

    I think it's telling how you put it — “teach WordPress”. :) Not PHP, not web development. WordPress. That's perfectly fine. I touch on this in the post — not everyone has to become a developer. Just enough. We need to make it easy it for people who have aptitude for it so that we are heading towards that enough. Core isn't doing it. Core development takes pride in making life hard for (would be) developers, for the sake of catering to users. I think the trick is to bend that spiky uneven learning curve into something more meaningful. I estimate that it takes between one and two years of people using WP loop to get what is happening in it. The flowchart I made for it is probably one of the most famous and appreciated WP things I've ever done. It breaks the wall between being a “user” of code and helps you move toward actually being a developer, with conscious understanding of that code. We need learning materials that accomplish that. More so we need code that accomplishes that and isn't a black box clusterfuck.
  • Andrey “Rarst” Savchenko #

    Hadn't looked at that subsystem, so no opinion. Not a fan of customizer for myself. It's user-centric (as usual), I am talking that more things need to be developer-centric and that core isn't doing it. Somewhat case in point. :)
  • Julien Maury #

    @rarst : As you said "uneven learning curve ", "not everyone has to become a developer", that's undeniable, could not agree more. Still, I cannot teach WP tricks without PHP. Is that a good thing that people with no basic PHP knowledge start with WP, I don't know, I'm gonna go with "not at all". But at the end of the day "the sake of catering to users" is quite the same thing.