If you haven’t yet read my ode to why Node.js is awesome, stop and go do so now. It should be no surprise by now that I am giddy like a school girl over the idea of using server-side JavaScript to revolutionize the web application stack. And perhaps no other project has captured more of the imagination and zealotry from the JavaScript developer community as Node.js has over the last 6-9 months. It’s undeniable that Node.js will continue to be one of the most important players in this emerging “market”.
But silver-bullet or the second-coming of the web? I’m not so sure Node.js can quite claim that status. Here, we’ll investigate the counter-point to Node.js, especially as it relates to practical usage in the middle-end. Raining on the parade may not be fun, but if we’re gonna gulp down the delicious Node.js grape kool-aid, we’re also gonna have to stomach a healthy amount of that ick-tasting Node.js cough syrup (that’s right, I just mixed 3 metaphors in one sentence!). We owe this topic some intellectual honesty and debate.
Brad Pitt in “Interview with a devil”
I want to (re)introduce you to a good friend of mine. He’s exceedingly well known, and I’m sure you’ve met him many times before. He’s not a popular guy by any means — probably more infamous than famous — but he can be very assistive in times when the hype of something new clouds our judgement of the things we already knew well.
Me: Devil’s Advocate (“DA”), welcome to the show. I’m glad you could join us for this discussion today.
DA: Thank you for inviting me over for some tea and a lively discussion. You know how much I enjoy calmly reminding people of reality, and in the process spoiling a lot of their fun.
Me: DA, are you saying you like being the least popular guy at the party? A lot of people think you are a Contrarian… that you just like to disagree for the sake of disagreement, and that you don’t really help the discourse very much. What do you think of that characterization?
DA: Well, that’s true that most people probably think of me that way. But that’s ok, I am secure in my manhood and it doesn’t bother me that much. I’m used to intellectual rejection. I mean, look at how hard I’ve been working to try and wake people up to Apple’s antics with the iPhone 4 antenna, and yet the masses still cling to Jobs’ every word like he’s a prophet or…
Me: Ok, DA. Let’s not get off on that tangent here. That is a fun topic, but we’ve got more important things to deal with today.
DA: Sorry, sometimes I just get carried away. But I do think my methods are helpful in encouraging people to question certain assumptions and make sure that all sides of a topic have been examined thoroughly.
Hello World
Me: That’s good. Let’s jump right in. I know you read my previous post where I gushed over how awesome Node.js is and where I explored how it might fit with the middle-end concepts I’m advocating for.
DA: Of course. I wrote that little editorial sidebar as a preview of our discussion today.
Me: Right. So, tell the readers, what do you think of Node.js?
DA: It’s awesome. Really it is. But it’s awesome for a specific set of tasks and for a specific kind of scenario. We have to be careful to remember that even though it’s very exciting for developers to jump on board and start experimenting with a new implementation like Node.js, that doesn’t mean in any way that it’s going to work for everyone.
Me: Obviously not, no one technology is ever right for everyone. I don’t think anyone is suggesting that. Seems like you’re just chewing on the soggy cheerios.
DA: No, it’s more than that. I’m actually trying to help people realize exactly what Node.js is and is not, so that we can have productive discussions not only about Node.js and its uses, but also about other alternatives for the rest of the crowd.
Me: Don’t you think it’s just too early to be judging what Node.js can and cannot do? I mean, isn’t it possible that it’ll grow to be useful in more parts of the stack as time goes on?
DA: It’s entirely possible and likely that Node.js will continue to grow in popularity, and more and more waves of developers will find innovative uses for it. But I don’t necessarily think that means it will ever win over the minds of conservative, established and slow-to-change development teams — and especially their bosses and IT support staff.
Me: Why not?
DA: It’s purely pragmatism, I feel. I’m considering the majority of the web application universe to be of the sort that is not naturally bleeding-edge (even if the bleeding edge is awesome) and often follows well behind the curve, and sometimes never follows at all. I’m thinking of the millions of PHP shops, and the Java shops, and lord knows the .NET shops… all of them out there, chugging along in their own little world. That world is not likely to be “rocked” (as you called it) by Node.js or even server-side JavaScript.
The payoff for them re-writing most or all of their current code base (whatever language it is) into server-side JavaScript would have to be epic and enormous, almost beyond adequate description in words, to convince them it’s worth all the time, money, and risk such a venture would entail.
Change you can believe in?
Me: OK, fair enough, a lot of them might be resistant to change. But aren’t all new technologies up against that same battle at first? The ones that eventually prevail do so despite the nay-sayers (like you) from the early days.
DA: On the surface, you’re correct. But again, I’m talking about something much deeper and more fundamental than just: will the masses ever accept server-side JavaScript?
In fact, I think that’s really your biggest question to answer as you try and convince people to embrace the middle-end with server-side JavaScript as the driving technology. Yes, the middle-end as a concept doesn’t require JavaScript, but the biggest payoffs in the middle-end come if people will accept server-side JavaScript into the stack. You’ve got a big uphill battle even trying to convince people that a little tiny piece of the stack can be done adequately with server-side JavaScript.
Me: Thank you for reminding me just how challenging this is.
DA: My bigger point is, Node.js at its fullest is much broader than I think most people realize. I think it represents a paradigm shift, not just the introduction of an existing technology into a new environment.
I think I’d liken this concept to trying to convince a company that makes desktop video-editing software that the new age will be their software web/cloud-based and mobile. Noone would argue that the mobile and cloud movements are huge and clearly represent the future. But the desktop application company is probably still likely to adhere to their core competency and continue to serve and rely on the paradigm of desktop application and hardware.
And they may rightly argue that the payoff for being able to take even part of their awesome video-editing functionality and stick it on a tiny screen device with 1/100th the CPU power probably doesn’t justify the efforts to try and get on the bandwagon with “everyone else”.
Me: A paradigm shift? Can you elaborate?
DA: Here’s what I mean: Node.js is not just an execution environment for server-side JavaScript. In theory, you could just run JavaScript on the server in an on-demand way, as needed. And I bet Node.js would be pretty decent at that task.
But by even thinking about Node.js in that light, you’ve drastically missed the point of what it’s trying to do. Node.js is trying to leverage the asynchronous power of JavaScript at a deeper level than on-demand application logic. Node.js is trying to become the network server itself, so that the server-side JavaScript you write for your application can be interpreted in a much more natural and almost native way.
Let’s look at this in light of some more established existing functionality. Consider a PHP web application. Now consider there’s some additional “module” for some task, like for instance doing OpenSSL encryption/decryption. There’s multiple ways your PHP code could accomplish this task. We know there’s command-line utilities (written in C and compiled to binaries) for managing OpenSSL. So, from our PHP, we can call out to those binaries by executing them as sub-processes.
But this isn’t necessarily the most efficient way to do things. It certainly can make code look less graceful and more complicated to maintain (more moving parts). Instead, we’d like it if someone could write a PHP “extension” that brings the capabilities of the OpenSSL engine natively into our PHP code. Coding against a PHP API for OpenSSL feels more natural than executing a binary sub-process, and it’s also likely to be a lot more performant.
Me: That sounds about right.
I can’t speak for the designers of Node.js, but I’d venture that among their various motivations, they wanted to do something similar (but in a much broader sense) for server-side JavaScript in the web stack. They wanted to make coding your entire application in JavaScript on the server as natural and native and built-in feeling as doing any other task in the web server, including listening for requests on port 80, doing file I/O, etc.
You see, the different paradigm that Node.js is bringing to the table is the idea that the web server and the application become almost synonymous. I think more than anything, that is the truly compelling story for Node.js. I’m not saying that Node.js is the first to do this, but I do think that Node.js is the most radical approach in this area that we’ve seen thus far.
Vive la Révolution!
Me: Ok, so that does sound pretty revolutionary. But I missed the part about how this doesn’t fit well with the middle-end.
DA: Well, you certainly are the primary advocate for the middle-end, so I won’t try to speak for you. But, I think you and I have some parallel thoughts in mind at this point, even if you don’t realize it. You have a vested interest (by virtue of your efforts to call attention to the middle-end) in convincing the “world” to adopt middle-end architecture as an intentional and carefully planned layer. The more applications/teams that do so, the more you will “prove” that middle-end architecture needs to be its own discipline and not just an after-thought of existing platforms/frameworks.
I’m trying to suggest that Node.js represents a fundamental shift in how people will think about web servers and applications, not as separate functional units but as conjoined parts of the same whole. A web application no longer has to be thought of as a set of business logic code and pretty HTML that relies on a web server to send it to users. A web application is fully self-contained and capable of doing everything it needs from within itself. And it uses a consistent language (JavaScript) to do everything throughout.
This idea is so radical that I think most web applications and platforms and companies will have a hard time swallowing it, at least any time in the relevant future. Thus, I submit that a “middle-end” that relies on Node.js will be less palatable to the masses than a “middle-end” that is more agnostic and flexible.
Me: Right, I’ve tried to make the point that the middle-end as an architectural pattern doesn’t have to have JavaScript on the server involved. Really, the primary reason for why server-side JavaScript offers an interesting answer to the middle-end is the idea that we can write code once and re-use it in both server and browser. No other language/technology can ubiquitously offer that.
DA: Exactly. You see, Node.js represents a particular narrowed down implementation of the broader middle-end concept into one specific form. That form happens to be increasingly exciting to the bleeding edge of the web development community, but I foresee problems in truly convincing the establishment that both Node.js and the middle-end together will be right for them.
Take the Chrome browser for example. It’s got a huge percentage of market-share among open web developers. Along with Firefox, Chrome is quite obviously becoming a web developer’s browser of choice. But when taken in the overall context of the web, Chrome’s percentage is still pretty low. There’s an established momentum around browsers like IE and Safari, and Chrome is not likely to completely overtake them any time in the foreseeable future.
Node.js is an amazing piece of technology. But it’s almost too amazing for the middle-end. It certainly will be more radical to convince existing applications to embrace the fullness of what Node.js is than it would be to suggest, as you have many times, that a more simple, stripped down approach to server-side JavaScript is possible, and in fact warranted.
Army of none
Me: Why isn’t using Node.js in a more limited fashion (like on-demand or per-request as you suggest) a valid usage of Node.js?
DA: I wouldn’t call it invalid. I’d just say that it’s a lot like driving a tank down to the corner store to buy some drinks. Can it get you there? Sure. Will it get the task done? Yes. Is that an effective mode of transportation? Perhaps not.
Some people like to argue that because Node.js has all this amazing capability built into it, it’d be foolish to not use it for your server-side JavaScript tasks because of all the extra stuff you’d miss out on if you ever decided later you needed it. This is kind of like arguing for taking the tank for the trip down to the corner store because you want to be prepared in case an invading army of aliens attacks. “Look, I’m better prepared to fight off the bad guys in my tank than I am on my little scooter.”
Me: Don’t you think that’s just a little bit of an exaggeration?
DA: Well, maybe a little hyperbole there. But my point remains, Node.js is way overkill for the simple middle-end tasks at hand. If someone is trying to shoehorn using Node.js into doing simple per-request on-demand JavaScript execution (the likes of which you’ve argued for in the middle-end), they are really missing the point of Node.js.
To put it another way: they’re using a sledge hammer to drive in a thumbtack.
Me: Isn’t there something to be said for using a project like Node.js for our tasks, because at least it’s pretty well known and has a lot of active developers and a vibrant support community?
DA: No question, it seems like using Node.js would be the obvious choice for this task. And perhaps a developer might be better able to convince their boss to try Node.js at first than some much less known project like your BikechainJS option.
But in the long run, I think that using the right tools for the job always wins out in terms of efficiency and maintainability over using the more popular or hyped solutions and later on finding it’s not a good fit.
Me: If one of those “established” companies was going to broaden their horizons, isn’t it riskier for them to venture off into the wilderness and choose an unknown project/option as compared to sticking closer to home with something more people know better?
DA: It may appear riskier. And definitely perception is hugely important in this game. But in reality, Node.js is actually asking an existing team/platform to put more of their eggs in the server-side JavaScript basket than what you’ve argued for in the stripped-down middle-end approach.
Like I said earlier, Node.js is a fundamental paradigm shift. This means that companies are going to have to retool a big portion of their web stack. They’re going to have to train IT support staff on a whole new set of technologies in the web stack. They throw out their 5, 10, 15 years of experience supporting and performance tuning traditional synchronous web servers like Apache, and now they have to learn it all again with a radically different asynchronous server-side JavaScript web server. I shouldn’t have to point out what a “shock” that would probably be to most organizations.
And the risk doesn’t stop there. Node.js itself is ever-changing. It’s stabilizing more recently, but it’s been incredibly volatile. I’d say right now it’s like walking over a bed of molten volcano lava that only a few hours ago started cooling and hardening into volcanic rock. How much do you trust that an inch of cooled volcanic rock is enough to protect you (and your 800 lb elephant) from the river of lava just below the surface?
Me: Doesn’t CommonJS offer us hope of stability and compatibility?
DA: Absolutely, it promises that. But it may be literally years before there’s consensus in the server-side JavaScript world on how all these API’s should really look and function. In fact, if the browser API’s have taught us anything, we may never fully have agreement.
Now, certainly the browser irregularities didn’t sideline 10′s of millions of companies from leaping into web applications, but most of them didn’t dare venture into the game until there was at least some sort of reasonable “gap fill” like any of the various JavaScript frameworks, which normalize differences across browsers and provide a stable foundation for companies to build upon.
So it may be awhile before CommonJS and/or some set of server-side JavaScript “frameworks” are able to secure a stable footing. If you look at Node.js right now, it represents a significant super-set of the small amount that CommonJS participants have “agreed” on. So, marrying yourself to Node.js right now is risky because it’s like marrying your web application to only FF and hoping that its rampant popularity will be enough to drive everyone else to commonality.
Fatalism: a cruel mistress
Me: So can we really do anything with server-side JavaScript at this point, given the immaturity and instability across the board?
DA: Of course! I’m not at all suggesting Node.js is bad to use because its unstable. I’m suggesting it has its places where it’s a natural fit (like in prototypes, developer experiments, and other flexibile-to-change dev environments), and then it also has places it’s not a good fit (like established teams with slow-to-change environments).
The same would be true of any server-side JavaScript option at this point, in my opinion. Of course there’s the obligatory “use-at-your-own-risk” label on all such things. But the smaller, more independent, and more custom your server-side JavaScript implementations are, the more likely you are to be able to adjust as the “industry” matures and changes.
At this point, if you were to go out and re-write your entire application in Node.js’s flavor of server-side JavaScript, you could be painting yourself in a corner if what evolves over the next few years is not in line with how Node.js is currently doing things.
My point is that the smaller the footprint of your server-side JavaScript at this point, the more insulated you are from these risks. Whereas Node.js represents a pretty big footprint conceptually, using stripped-down, per-request, on-demand JavaScript solutions represents a much smaller footprint both technologically and conceptually. Companies are more easily able to integrate such things little-by-little, and also strip them out if problems arise. A re-architecture to Node.js and server-side JavaScript would both be more comprehensive and also more difficult to undo.
Parting shots
Me: We’re almost out of time… do you have any final thoughts to share or clarify with the audience regarding Node.js and the middle-end?
DA: I think your idea of using Node.js as a go-between “proxy” for middle-end tasks is an interesting one. I think it represents probably the best possible scenario in which Node.js fits in with your “middle-end”.
But I’ll close by saying this: you must realize that Node.js may in fact be ushering in, at least for those (few) who are inclined and capable of taking up the banner, a new era of web applications. This era will be one defined by a blurring of the lines between front-end, middle-end, and back-end code. It will be a new class of web applications that is built end-to-end in JavaScript. In such a world, the middle-end tasks become the all-end tasks. So, more than anything, I think Node.js may mean there’s no need for a middle-end any more.
However, I think the reality is there will only ever be a select enlightened few who ever get to fully explore that new paradigm. For the overwhelming majority “rest of us”, the “middle-end” will still be a valid and important reality for our web applications, and as such, we should embrace this discussion.
Me: Well said. I have nothing more to add, except a thank you to DA for joining us today. I know you’re a busy guy, so I’ll let you get on to other pressing debates.


Middle-ware
There are only two ends.
I fully admit the name “middle-end” is contrived. but when talking about “front-end” and “back-end” (both extremely common terms in this industry), I need a term that fits well consistency-wise with them. “middle-end” fits the bill. You say it and immediately know what it means. And the fact that it’s also a bit strange means it’s a sticky concept that will stay with you. Also, “middleware” is a term with much baggage (good and bad) and I don’t want my concept of the middle-end to be associated with that baggage, as it’s a new approach. For all the reasons, and others, I still believe “middle-end” is the right term.
Side note: if you think about the stack diagram as a triangle instead of a vertical line, then there are 3 points, aka 3 “ends”. Actually, visualizing the interplay between them as a triangle rather than a line has some good advantages. Perhaps I’ll make up such a diagram for the next time I write or talk about the “middle-end”.
Thanks @getify. Those are good points — kind of playing devil’s advocate myself
. Wonderful article!