惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
J
Java Code Geeks
I
InfoQ
腾讯CDC
Vercel News
Vercel News
IT之家
IT之家
V
Visual Studio Blog
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 叶小钗
有赞技术团队
有赞技术团队
月光博客
月光博客
Martin Fowler
Martin Fowler
量子位
L
LangChain Blog
B
Blog
Last Week in AI
Last Week in AI
博客园 - 司徒正美
Microsoft Security Blog
Microsoft Security Blog
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Your Backend Should Be a Compiler, Not a Collection of Ha...
Drew Marshal · 2026-05-09 · via DEV Community

Most backends are built the same way.

You define routes.
You write handlers.
You wire everything together.

Over time, you end up with dozens—sometimes hundreds—of functions that all follow similar patterns but live in different places.

It works.

But it doesn’t scale cleanly.


The Handler Mindset

A typical backend looks like this:

  • Route definition
  • Controller or handler
  • Validation logic
  • Database query
  • Response formatting

Repeat that structure across your entire application.

Even if you organize it well, you still end up with:

  • Repeated patterns
  • Slight inconsistencies
  • Logic spread across multiple files

You’re not building a system.

You’re assembling one manually.


The Realization

Most handlers don’t do anything unique.

They follow a pattern:

  1. Accept input
  2. Validate it
  3. Execute some operation
  4. Return a result

The structure is always the same.

Only the data changes.


So Why Are We Writing Them Over and Over?

Instead of writing handlers, what if we defined behavior?

Not in code first…

…but as a contract.


Thinking Like a Compiler

A compiler takes a definition and turns it into execution.

It doesn’t care about your specific use case.

It cares about:

  • Structure
  • Rules
  • Transformation

Now imagine your backend doing the same thing.

Instead of this:

app.post('/users', async (req, res) => {
  const { name, email } = req.body;

  if (!name || !email) {
    return res.status(400).json({ error: 'Invalid input' });
  }

  const user = await db.users.insert({ name, email });

  return res.status(201).json(user);
});

Enter fullscreen mode Exit fullscreen mode

You define this:

create:
  user:
    CreateUser:
      input:
        name: string
        email: string
      insert:
        name: $input.name
        email: $input.email
      response:
        id: number
        name: string
        email: string

Enter fullscreen mode Exit fullscreen mode

No handler.

Just a definition.


What the Backend Becomes

Instead of a collection of handlers…

Your backend becomes a compiler.

It:

  • Reads definitions
  • Validates structure
  • Builds execution logic
  • Runs it through a pipeline
  • Returns a response

The code you write once replaces hundreds of repeated patterns.


The Execution Flow

Every request follows the same path:

Request → Load Definition → Validate Input → Build Operation → Execute → Format Response

Enter fullscreen mode Exit fullscreen mode

Nothing is hidden.

Nothing is scattered.

Everything is predictable.


Why This Is Better

Consistency

Every endpoint behaves the same way.

No surprises. No deviations.


Maintainability

Change the system once, and every endpoint benefits.

You’re not hunting through files to fix the same bug.


Clarity

You can read the system without digging through code.

Definitions describe behavior directly.


Scalability

As your application grows, complexity doesn’t explode.

It stays structured.


“But What About Custom Logic?”

Not everything fits into a strict pattern.

That’s fine.

A compiler-based backend can still support:

  • Custom steps in the pipeline
  • Extension points where needed
  • Escape hatches for complex cases

The difference is:

Custom logic becomes the exception, not the default.


Code Moves Up a Level

You’re still writing code.

Just not the same code over and over again.

Instead of writing handlers, you write:

  • The compiler
  • The pipeline
  • The rules of the system

You move from:

“Implement this endpoint”

to:

“Define how endpoints work”


This Is About Leverage

Handler-based systems scale linearly.

More features = more code.

Compiler-based systems scale differently.

More features = more definitions.

The engine does the heavy lifting.


The Bigger Picture

This idea doesn’t stop at APIs.

It connects to everything:

  • UI driven by structure
  • APIs driven by contracts
  • Infrastructure driven by configuration

Each layer becomes:

  • Predictable
  • Composable
  • Aligned

Final Thought

Handlers feel powerful because they give you control.

But they also force you to repeat yourself.

A compiler feels restrictive at first.

But it gives you something better:

Leverage.

That’s why I stopped building backends as collections of handlers…

…and started building them like compilers.