The Cost of Using Express
If you started thinking about the engineering perspective, then you might know that every technology comes with cost.
Every technology gives you certain advantages, but it also introduces the trade-offs.
The real engineering skill is not simply choosing technology because it solves a problem.
It is understanding what you gain, what you give up, and when those trade-offs are worth it.
Express is no different.
It gives a higher-level abstraction over Node.js’s http module.
It makes routing, middleware, request processing, and composition much easier to work with.
But it also comes with cost.
To understand those trade-offs gives better thinking of why I use this technology in a project,
instead of how to use the technology.
The Cost You Pay With:
*) Control
Express sits between Node.js HTTP primitives and the application.
When you use Express, you are no longer working directly with the raw HTTP server model.
Express decides how that request-processing abstraction works,
and your application has to work within that model.
*) Hidden Work
Express implements some work behind the scenes.
Something is happening that you didn’t explicitly write.
The general property of the abstraction is that the less code you write,
the more framework behavior you need to understand.
*) Performance Cost
Express adds a layer of processing on top of Node’s primitives.
That means additional function calls, middleware traversal, and routing logic.
This is additional CPU work and latency compared to doing everything directly at a lower level.
It doesn’t drop that much performance compared to database, external APIs, and networking latency.
*) Complexity
The behavior of the request depends on the middleware chain.
Middleware can modify req, res, and also terminate the request call.
Now, to understand why this behaves this way can require tracing in the middleware chain.
*) Mental Complexity
Now you use Express, so you have to understand Express itself.
Once you choose Express, you need knowledge of middleware, routing, router, middleware,
request/response APIs, framework conventions, and version-specific behavior.
To use Express, you don’t eliminate complexity;
you move some complexity into the framework and its mental model.
*) Dependency Cost
Express becomes part of your application dependency graph.
Now you need to care about:
- Express versions
- Compatibility
- Security updates
- Migration between major updates
The abstraction works beautifully until a problem crosses the abstraction boundary.
Top comments (0)