Tight Stack, Lazy Stack
Sam Boyer @sdboyer
Hi everybody, my name is...
Title of my talk is...
In talking about Full Stack Engineering, it's important to recognize the difference between the sort of full stack we like - trim, tight, and focused - and a full stack that's lazy.
So that's what I'm gonna do. And I'm gonna do it by picking on Drupal.
how many people in the crowd have used Drupal? how many would consider themselves "Drupalistas?"
OK, back up. Lazy stack? Tight stack?
Let's get meta!
So, this distinction is my key point here. Every functioning application encompasses the full stack, somehow.
So when we talk about being an FSE, we mean, "how well do you handle the whole stack?". The hidden issue there, though, is the quality of the stack you're handling. So let's talk about that!
PART ONE: KNOW YOUR USE CASE
"Full stack" starts long before bytes hit vim
The whole point of learning the full stack is so that you know the full vertical slice for solving a problem. But all that shit is useless if you don't know what problem you're trying to solve.
This is similar, but different, from the role of architect: you don't necessarily have to understand *why* the layers fit together the way they do. It's OK to focus on the *how* first. You should have an intuition about what you do, and don't, want to "get for free," because you can see the inefficiencies in layer interchange.
There are approaches to this!
- UX (kinda sorta)
- Behavior-driven development
- Content strategy
- Domain modeling
DDD
if you don't at least know what these approaches are and what they emphasize, i'd challenge the idea that you're an FSE
in particular, domain modeling tells us about creating a shared vocabulary, right off the bat.
Drupal has AAAALL its own words. Good luck modeling.
Terminology is really important in domain modeling, but Drupal gets that wrong immediately.
Forces use of Drupal nomenclature and concepts - entities, content types, taxonomy, view modes - to talk about major domain concepts.
Content model is *really* flexible, though.
But because that all ends up being interface-driven, Drupal ends up as "the system for people who haven't figured out their use case, yet."
This is one of those key ways that the stack makes you lazy: by making it (ostensibly) easier to change data models later, a lazy mess is made of the modeling process.
TODO: drop in a picture of Drupal interface vs. screenie of simple models-as-code.
So, what is Drupal's use case?
Answer: nobody knows. Anything, and nothing. For a web framework, this is mostly fine. For a CMS, it's way less fine.
Again, Drupal's niche is figuring helping you figure out your use case as you go along. In a way, it's kinda a great prototyping rule. Or, it would be, if it didn't take a relaive expert to know what aspects of the prototype were relevant, and what weren't.
PART TWO: LAYERS!
Layers - the heart of FSE. They are the pieces of the stack. What can we say for Drupal? Well, it *has* a stack. jQuery, PHP, MySQL. In D8, a teensie bit of backbone, and a REST interface to content.
Full-stack-ish layers
Now, full stacks are looking increasingly diverse today, but this is still a roughly good picture.
There's the client end, where you may see a frontend framework (or not), and some of what's traditionally serverside might have scooted up there, too.
Then there's the serverside, which has a bunch of stuff we're all accustomed to seeing - models and business logic, sessions, routing, an ORM or DBAL of some kind.
And then finally, the persistence layers, with varying degrees of volatility and canonicality.
The specifics here vary, but most web applications have to answer something like this set of questions.
Drupal's layers
Drupal works from the middle, dictating most of the other layers. Everything in the middle section is bundled in and only some are "swappable".
It significantly dictates output formats, making it harder to swap in a frontend framework. Only the most experienced Drupallers are now experimenting with Angular-driven frontends.
It is, for most practical purposes, incompatible with NoSQL backends for persistent storage. Again, only the most advanced have done it with much success.
A lot of the time, this is fine. But proper FSEs will start chafing at this sooner or later.
Modules and hooks: Drupal's stack-smoosher
Drupal's extensions are called "modules." They are generic, meaning they all can be installed in the same way. This is good.
However, they also generic, meaning they all have equal access to the same mechanisms for mutating behavior and state. This is bad.
The extensive control afforded to modules means that Drupal has gravitated towards, and built itself around, giant anonymous dicts/hashes/arrays of data and instructions as its primary way of doing shit.
So, kinda like LISP, except with a shitty, shitty datastructure instead of a first-class one. And in PHP. Win.
Lazy stacks create bizarre problems (and knowledge)
Features. Oh god, features. Since the very structure of a Drupal instance is at least partially tracked in the database - including content types, fields, and other major systems...
Features is a way of "exporting" it to code. But because it wasn't code in the first place, it gets UGLY. Updates? Changes made in the UI that aren't yet reflected in code? Changes to datastructures from upstream?
A lazy stack takes you off the beaten path. You can't even see how wider, conventional wisdom applies to the situation because it's all so obscured. It makes you *learn irrelevant stuff*.
Drupal 8 improves some of this...
But we still really like letting everything bleed together.
This is improved in D8 - we've finally come around to an idea of "plugins," which participate in formal contracts to solve specific problems (caching, entities).
Of course, we've also conflated all that together. Entities are Plugins. And Config entities are all three.
All that said, lazy stacks can create interesting problems
On the plus side, lazy stacks can create interesting problems, complex programming challenges.
So, while getting something done in Drupal core can be difficult for other reasons, it is a good place to sharpen your skills.
yammer about my rewrite of the way core assets work.
1. multiple actors, not aware of each other, that each need to register CSS/JS assets for delivery
2. need to get them all in the right order
3. need to aggregate them for optimal frontend performance
4. ideally, should aggregate with global optimality in mind...but...
all of this leads to a conclusion.