On the horrific state of JavaScript frameworks
Is it just me or are Javascript frameworks among the most horrendous libraries in software development right now? I've tried several Javascript MVC frameworks and the glue libraries that come with them (Angular, Backbone, Sails, Waterline, etc.) and the one common theme among all is that they have the absolute minimum feature set to put together a simple application like a TODO app but completely fall apart when developing a real-world rich client application. To give an example, most ORMs like Waterline have extremely basic relational support with little or no support for querying beyond basic operators against numeric or string properties. Waterline can't query an object based on a property of a child association, for example, and is thus almost useless in real world scenarios.
The state of debugging is also shockingly terribad. How can people seriously debug a client side application in Chrome or Firefox's developer tools?
What am I doing wrong? Are Javascript client frameworks really this bad?
17 comments
[ 3.5 ms ] story [ 45.6 ms ] threadYou just can't compare the JS libary ecosystem to something like e.g. the Java ecosystem which had much more time to grow and mature.
On SailsJs I tried for a bit, but all the NodeJs frameworks are in a different league, so I think you shouldn't really compare them.
Some tips, there's this website called echojs.com (like hacker news for the js world), there's also frontendmasters.com with really good learning resources for a small monthly fee from experts all around the world.
I've been working as a Full Stack Developer for a long time and now decided to do just front end development and I couldn't be happier with the state of tools we have nowadays, specially for debugging: Chrome, Firefox, etc. For example, have you checked the new Firefox feature that allows you to get the list of event listeners attached to a DOM element ? That's sick! What about remote javascript debugging ?
In the end of the day, maybe javascript is not for you or you need some more time.
The new kid on the block is famo.us! Have a look!
The new kid on the block is famo.us! Have a look!
That's sort of my problem with these frameworks. A neverending explosion of new frameworks that haven't been thoroughly field tested. Meanwhile existing frameworks move on from their 5 minutes of fame and fall into obscurity / deprecation.
Try to go for a more loosely coupled approach and look beyond MVC[1] frameworks in general. I'd suggest trying React for the front end. It's not a framework, but it will definitely influence the general architecture of your app. That is, you'll probably end up using some form of 'Flux'. http://facebook.github.io/react/docs/flux-overview.html
[1] Nothing wrong with MVC as an architecture, but most attempts to reify in a framework don't work out IMO. Pretty much same goes for OOP.
They're both too complex and too simplistic at the same time. BackBone and Angular in particular demand a lot of code to do simple things and still fall apart in large scale production.
The best I've seen is https://muut.com/riotjs/ which is basically just a collection of JS-objects and a router. But it's far from useable because they've tried to cut corners, and lacks all sorts of documentation.
The best framework I found back then was RobotLegs, which was an MVC(s) framework which I loved because it was more of a set of patterns you followed. Dijon.js https://github.com/creynders/dijon is a port of Robotlegs to JS which seems cool. It just provides dependency injection and leaves the MVC part up to you.
Flux seems like the way to go, IMHO. It is more of a set of patterns rather than a "framework". It's a lot to grok at first though.
I'd look at Fluxor http://fluxxor.com/, or Reflux https://github.com/spoike/refluxjs, which both seem to make Flux a bit simpler.
(I do agree with you that the state of frameworks now is ridiculous)
I used to be like you. I was out at every meetup -- flirting with all the new frameworks in town. We would start off hot-n-heavy, staying up late into the night, making big plans. But just as things were about to get serious, I back-peddled and started to better-deal -- thinking there is a "better framework" out there. I didn't want to make the wrong choice.
Backbone was the hot new sexy, and we got along great. We breezed through TODOMVc, and everything just "clicked." She showed me a better way to javascript. This was great! I took the relationship to the next level, and we were off on our enterprise app. Sad to say, the romance ended the moment I realized what two-way data-binding was, memory leaks when destroying views, and the need for good message passing. Backbone had none of it, and I told her about it. Then one day she came home dressed as Marionette (marionettejs.com), and I hardly recognized her. I found her to be complex and abstract. She was no longer the simple and elegant framework I knew, and so I moved on...
And soon enough, there I was out at the meetups again. That was when I met Angular. I found her opinionated, and a really domineering. However, she was from a well known and respected family. Besides, I was happy to be with someone who took care of so many things. But that comfort came with a price. She wanted me to do things her way, and do it without much documentation. She just wanted to me to "get it." But it didn't click. And so I gave her the "its not you, its me" talk, and I moved on.
See a pattern here? I think many devs can relate. Let me explain:
TL;DR
Frameworks are like relationships. The only way you can get the most out of it is to fully commit yourself to it -- using the good parts and working around the bad. The sooner you realize this the better, because you will stop wasting your time with frameworks who don't do more than offer a weekend thrill with TodoMVC.
BTW: I'm now in a polyamorous relationship with Flux and ReactJS, and it is wonderful.
Now on a Fluxxor+ReactJS stack moving from Backbone... couldn't be happier.
Big lesson kids: When learning a new toolkit or framework, build a toy project you can discard when it is over. That way there is no technical debt, and you will be better able to analyze and decide if this is right for the Big Project(tm) ahead.
That is what I did for React and Flux. I took some hours at work and at home to get up to speed with a small PhoneGap app. Once I was satisfied, I presented to my team. There were some questions and feedback, and it made evangelizing much easier -- it sold itself.
Sometimes you have to take down the "rails" and chart your own path.