Dojo for jQuery Developers: A comprehensive tutorial
dojomonk.com
dojomonk.com
I've just finished quite a large dojo project, and it has been a huge pain in the ass. It is impossible to debug, the AMD changes are confusing as all hell & it is badly documented, but its biggest flaw is that it has a hockey stick learning curve. You can get to jQuery mastery in your own time, but for you to produce anything decent with dojo requires you put a whole heap of unuseful headscratching in at the start.
If you're a great programmer, then maybe dojo is for you. But if you're an average programmer who needs a degree of discoverability in the tools that they use, then I would steer clear.
Another problem is that the framework is currently in a half-finished state (mvc anyone) and it looks like it's going to stay that way for a while.
I think this : https://github.com/rmurphey/dojo-scaffold was posted a while ago, but if you haven't seen it - then it might be worth looking at. Again, I haven't used it, but if I had known about it before starting a dojo project, I would have given it more attention.
Dojo's learning curve is a big problem, and I am trying to do my bit to address that.
The changes are confusing, yes, but what can you do? You can not live with old just to not make things confusing.
I believe the great programmer bit is only another way of saying the documentations are lacking, and not that dojo itself is more "complex" than jquery (of course it does much more, so compare it with jquery+requirejs+backbone+<there is no widget library in jquery i believe>).
Debugging is a pain in the ass, yes. I am not sure what is the answer to that.
I am planning to do a few more articles, covering MVC etc in a little bit more detail.
To me the first question is technology, dojo represents a solid, well thought out technology, secondary is documentation/learning. I would be willing to spend an extra week to learn something with sparse/confusing documentation, if it provides me with an edge when it comes to future work. And in my opinion dojo does.
but in general, i'm beginning to despise monolithic "do everything" toolkits/frameworks like Rails, Meteor and Dojo - the level of "vendor lock-in" is hellish..
just stick to plain old HTML5, OO Javascript and simple, specialised libraries which can be mixed in as and where required.. make the libraries depend on your code, not the other way around.
What I highly recommend if use dojo's declare way of doing object oriented javascript.
Specialized libraries are always going to beat general purpose libraries, but the reason big frameworks are popular is because they give a structure to the project. The dojo project I did will look quite similar and familiar to any other dojo developers, we will use same way to build our builds, same way to represent data using object stores, our classes will be compatible with each other, and our widgets will look familiar.
There is value in it.
Well if you're using the AMD syntax, that's what you're doing, albeit initially limited to the (extensive) dojo library.
I personally find the dojo core relatively simple to use. Each individual module is small enough to grok in a few minutes.
The arguments about being able to do all kinds of crazy stuff without bloating code size just don't make me happy at all. Should we include an extra build step and production pipeline complexity for web, something that is supposed to have flexibility and speed-to-deployment as its evolutionary strengths? I can't even remember how much time I ended up spending on JUST the silly require boilerplate, which accomplishes mostly nothing because it's not like I ever want to fetch javascript asynchronously. CDN JQuery is a 304-not-modified and my code is gzipped by nginx if the page is over 4kb. Hey look, it's really fast and I didn't work at it.
JQuery 2.0 is about to be out, so goodbye old IE bloat. I'm happy with ever increasing internet speeds, ever faster browsers, and a plethora of small libraries ideally suited for various legs of the journey. I've never used underscore, knockout, or angular, but I know that if I ever run into a problem that requires more architecture, I should go find out what they do. This can be one's approach towards almost all problems in web. Which comes first: a focused javascript library or an implementation of it on top of the Dojo (or any other) API?
jQuery is good for another 20 years. But is backbone? or angular? or Would it be the new components thing google released?
Remember dojo is not just jquery, its jquery+backbone+requirejs and few things put together.
I really like larger web frameworks like Django because a lot of what those frameworks provide is only won at a high-cost to the programmer if not done as part of the architecture. Going more micro means more work in those cases. Going more macro with JS when 99% of pages need a contact form is not making me feel empowered.
JS libraries are to me like single-celled organisms. Sure they spring up and die a lot, but out of all that change and natural pressure to remain small and decoupled, it's not necessary to tie one's future to any one of them if they act up. Dojo 1.8ish made me greatly loathe not being able to swap out that one misbehaving part because of commitment to the larger scheme.
I am getting your point. I would prefer if dojo lowered the marketing on the rich set of existing widgets, as very few people will every use dijit/Button over native button.
But dojo's object store/MVC, dojo's widget system itself, the build system/AMD, they have proven themselves over a period of time.
Don't use dijit widgets, but do create widgets using dijit/_WidgetBase is my recommendation to everyone learning dojo. And none of the grids, and layouts and SVG etc etc. They inclusion in dojo code base is one of the reasons so many developers get put off by dojo.
A lot is happening in dojo, the dojo development has picked up pace lately and dojo2.0 is going to be a huge step forward for simplicity and richness.
I have mentioned at the beginning, if you just want a jquery like work, Google's CDN is available for dojo too, and the CDN has all the modules required to get jquery level functionality baked in.
I'm basically resistant to any and all JS compilation. It's like multi-threading in pure Python. It's more complex, doesn't leverage the existing strengths, and in the end doesn't even really do what it says it does.
If a project is just a few lines copy pasted here and there, then sure, but for any more complex project you have to build.
Dojo will unnecessarily increase the development time of your application to a factor of 4. My recommendation is to avoid it at all costs.
After using dojo for at least one big project I am have a different experience. For the first time I started thinking about software engineering principles when I used dojo in client side. All my previous projects were in jquery and while they work, jquery has not helped me one bit in managing complexity.
I have written my experience about how to use dojo right. Do not use too much of dojo, don't use dojo for page layout, do not use dijits that may not be as well tested as the core.
I would highly recommend you give the tutorial a try.
It's interesting you mention complexity. When you're developing a very rich client-side complex system, at what point do you stop and realize "maybe I'm taking this too far"? I'm beginning to notice that people are developing web applications the same way we did when we were writing desktop applications about 15 years ago. I personally think that we should absolutely not be trying to rewrite desktop applications for the web.
Once the web application gets so complex that you need to reach for Dojo is when I think the application should be rethought and rewritten from scratch.
The streamlined AMD loading makes it really easy to write modularized, structured projects and build it into release bundles. The store concept and compliant widgets are excellent, and while admittedly much of the dojox stuff is fragile, the dijits in general are very well made. The charting and drawing modules, with fallbacks (SVG, canvas, VML, Silverlight) have also been great to work with in my experience.
Can you give some examples of things you find unintuitive or confusing? What makes it more difficult to debug than other Javascript libraries? How do you find the documentation lacking? (The latter has become quite a bit better in recent years, you may want to look at it again if you haven't in a while).
I can understand that dojo may seem daunting at first. After all, something as simple as
$('#foo').html('<div>foo</div>').css(...).click(function(....
in jquery, takes a fair bit more effort in dojo. This, and I suspect, quite a few of the other grievances you have, stem from dojo's insistence on modularization. This seems unnecessary at first, but in my experience, pays off as your code base grows.My recommendation is to seriously consider it for any complex javascript application.
I use dojo layouts a lot, as i could not code the necessary css in a million years. Yes it cheats and uses Javascript to resize components, something that apparently makes Web purists cry, but for me it was just another quick solution that worked.
Similarly dojo 2d charts -- there may be better solutions out there, but with dojo they are built in and just work for the most part.
I think the Ajax model works pretty well, although the whole promises/futures took a bit to get used to.
There its definitely a learning curve, and if i just wanted a bit of dom manipulation i would probably still just use jquery-- but i found dojo to be invaluable when it came to developing more complex client side apps that could make use of a batteries included framework.
Things i didn't like - a lot of the documentation seemed to relate to a prior version (i started with 1.8 i think), so finding the appropriate way to do something could take a bit of work. Also debugging was often difficult, as the error was often raised in some anonymous function created deep within dojo. Sometimes the stack traces were useful, sometimes not.
All I expect from jquery is Dom manipulation thats consistent among browsers.
I applaud competition, but Dojo is not for me.
Going forward client is only going to get more and more rich, and dojo has a cohesive and consistent solution for handing these "rich" aspects.
Dojo has been great for managing our very complex UI - I certainly wouldn't want to do it in jQuery, but that said, I wouldn't necessarily choose dojo for some brochureware website job.
In other words: the right tool for the job.
It's a good read especially for developers who want to do cross-platform mobile apps with phonegap and such. All this knowledge applies there.
For a new project, give dojo 1.9 a try.
And changing the way you access a method (from global variable to requiring them through AMD) is not relearning everything.
many jQuery users don't want to improve, they want to believe into theirselves knowledge.
In my experience many of jQuery fans don't care about large client side apps, most of them are graphic designers not developers: they can cut-and-paste code but they are not able to write more than 25 lines of source code and understanding what they are doing.
I appreciate your article, thank you.