My last post

April 22, 2017

If you hit this blog you will probably realize very quickly that it is not updated very frequently.  Or rather, not updated at all.

The last time I wrote anything here we where at Dojo version 1.8 and now we are up to 1.12 and 2.0 seem to (finally) be in sight, even if I do not recommend to hold your breath..

My project is very much on it’s way with something like 100k+ loc Dojo/javascript plus another 18k+ loc html templates used by the dojo code. All backed up with 80kloc php and 33kloc sql code in the backend. We also started to use d3.js for graphs. D3.js is great for svg generation and way more flexible than the dojox/gfx stuff, albeit a tad more complex to use.

When this is written we are still running Dojo 1.11 and we will upgrade to 1.12 after our next release.

Dojo 2.0

I look forward to Dojo 2.0 with a combination of dread and anticipation. I like what I see when I peek at 2.0 but I do NOT think that “porting” 100000 loc from 1.x to 2.0 well be quick and easy. Also 2.0 will use TypeScript and, I imagine, some features from ECMAScript 2015 something I look forward to.

It would be nice to use Dojo 2.x in the “next generation” of our product where we make a fresh start and remove some quirks that exist purely for historical reasons. But I fear that this is more fantasy than reality since rewriting code is very very rarely good business strategy. Sadly.

Still happy

Dojo documentation is still not top notch but by far but better than before.

But the bottom line is that I am still happy with the choice of Dojo and I have nothing to add to what I said back in 2012. Dojo make it easy, or at least feasible,  to write your own widgets and re-use them. We have created over 400 where some are, a combination of many widgets to form an editor for some complex object and some are simply buttons with some icon. Other widgets may be a graph that fetch data from the backend etc and some are extensions of dijit/form widgets that can handle our specific representation of data.

The last post

As the title indicate I expect this to be the last post on this blog. I make no promises but considering the post frequency so far I think the odds are that it will be.


Dojo or JQuery

April 6, 2012

I do not wish to discuss jQuery here but apparently no Dojo blog is complete without a discussion about jQuery vs. Dojo so to get this out of the picture I post this as early as possible.

Many men, wiser than me, have written about this but here is my take on the subject. I think it is very similar to other answers you can find on the internet.

NOTE 1:  I have not used or looked at jQuery since mid 2011 and things may have changed.
NOTE 2:  Dojo and jQuery are not the only games in town, but I am  not qualified to talk about any of the other libraries.

Dojo or jQuery, quick answer

  • JQuery if you are new to javascript/web programming and only want to jazz up your pages a little. Also, if your project is only a few months and/or only a few hundred lines, pick JQuery. It will get you there faster.
  • Dojo if you have a large project and can spend time on a very steep learning curve and want to be able to create and re-use widgets, data connections and whatnot.

This answer do not take into account the “fun factor”. If your aim is to have fun JQuery will give you a quick fix but Dojo will be more rewarding in the long run. Your choice.

Dojo or jQuery, not so quick answer

First I want to point out that the question is kind of silly, really, and if you even ask you probably want to use jQuery. Dojo and jQuery are for different problem domains. Dojo is really a superset of jQuery and solve some problems that a beginner jQuery user did not even know existed.

But here is a comparison between JQuery and Dojo anyway:

JQuery vs. Dojo, round 1: Documentation

JQuery documentation wins hands down. No contest. Dojo documentation has improved enormously since I first looked at it a few years ago but it is far from good. Sometimes the only information you can get is the name of the widget. This is, in fact, my main concern with Dojo and a big part of the reason I started this blog. I hope it will somewhat ease the learning curve at bit.

The explanation is probably that Dojo is open source and contributors do not get paid to write documentation. This is, however, also true for JQuery but that project must have some magic way to get its contributors to produce documentation.

I will speak more about Dojo documentation. In the future. I have opinions.

Now, you could argue that JQuery documentation is really only good for the JQuery core and JQuery UI and Dojo contains so much more. This could be a valid argument but in reality JQuery documentation is much much easier to grasp, understand and use.

JQuery vs. Dojo, round 2: Learning Curve

Dojo does not really have a learning curve, it’s more of a step or even a Dirac-pulse. There are many things you must get right before you can even begin. It’s not easy to sneak some Dojo into your page, unless you already know Dojo quite well.

jQuery, on the other hand have a, I would say, quite flat learning curve. You just need to learn to find your way around in the documentation.

This round goes to jQuery.

JQuery vs. Dojo, round 3: Code organization

This is something Dojo does and jQuery don’t. Dojo more or less force you to organize your code and make modules (classes and widgets). As far as I know jQuery do not address this at all so you get no help here.

For a small project this may not be a problem during development, but Dojo is not only for small projects. From a maintenance point of this will probably be a problem for jQuery projects.

This is not to say a jQuery project cannot organize the code, only that jQuery do not help you with it.

Round to Dojo.

JQuery vs. Dojo, round 4: Code re-use and modularization

This is also something Dojo do and jQuery don’t. It is not only simply re-use of code that you written once but you can, for example, write some code that retrieve data from and update to on your server and let Dojo-front ends like lists and pulldown menus use this code to interact with your server.  (I’m not saying this is necessarily easy, but by design it is possible)

Dojo wins.

JQuery vs. Dojo, round 5: Page design in mark-up.

When you do things in jQuery you do it in javascript. When you work with Dojo you tend to do things in html since most widgets are as easy or even easier to specify in mark-up than in javascript. Dojo parse the html after load and modify it.

This might sound strange but it is actually very powerful and, if you have the widgets you need, you can create quite complex javascript applications without a single line of javascript (well, that is not really true, but almost). This will also encourage you to write your own widgets and you cannot do that without modularization.

Dojo win by default.

JQuery vs. Dojo, round 6: API Stability.

I cannot say for sure but the Dojo APIs seem far more  volatile than the jQuery API. The Dojo developers seem to delight in adding a new feature only do declare it deprecated a few releases later.

For example, the changes between 1.6 and 1.7 broke much of my code. Badly. I then rewrote it for the AMD API and that changed even more. I fear the 2.0 release but I must confess that I also like the new features so changes in the API is not all bad. It can sometimes also be argued if it is the API or inner workings that have changed. Such an argument would be easily solved by looking the documentation, you would think, but alas, not for Dojo.

I guess, for API stability, jQuery gets this round.

JQuery vs. Dojo, round 7: Performance.

Well, I cannot tell and from my perspective this is not a very interesting issue. I mean the difference is not big enough to be a major factor.

To me, this round is a draw.

Result: jQuery or Dojo?

It’s all up to you and your needs and preferences. Choosing Dojo comes with a cost but also with some long term benefits.

Some have suggested, as a solution to this Gordian Knot, that you can use both. While this is probably possible you will no doubt reduce your performance and double your page load times. The only reason I can see is to re-use some jQuery code in a Dojo environment but since Dojo can do (almost?) everything jQuery sort of doubt this is a good idea.

Who am I to say all this?

So I have opinions about Dojo and jQuery. Who am I and why should you trust my opinions?

Well, for starters, you should not trust anything you read on the internet and you should also remember that an advice is worth exactly what you paid for it, but here is my story:

2-3 years ago I started working on a web project that is really a REST-based web service with various clients connected to it. One client type, the main type, should be web applications written in javascript (we did a short, and expensive, excursion into Silverlight land, but I imagine you can all understand how that played out). I started working with Dojo but after banging my head against the keyboard for 2-3 months with really nothing to show for it I wen’t for jQuery. It was a very different experience and I hacked happily along and started to add functionality to my jQuery application.

After a year and a half or so (I have other tasks, so it is not 2000 hour of coding) I started to suspect I had problems. Whenever I let the project rest for a few days I noticed that it became more and more difficult to pick it up again.

So productivity went down, rather than up, over time and that is a sure sign of bad design or some built in problems in the environment. It is possible that with more experience in javascript development I could have made better but I did not. That said, I had recognized some problems and had actually built me javascript code environment, in PHP,  that packed all code into one file and made sure no file was added twice etc. I also had some code organization and file naming conventions in place, after all, after 20+ years in software you learn some things the hard way.

But it did feel like re-inventing the wheel and it did not feel comfortable to make all this that should really have been there from start.

Some 8-9 months ago I decided to take a new peek at Dojo. I noticed that the documentation looked better, much better and as a result I started to understand some things that I could not figure out last time I looked and what hooked me was the modularization and re-use aspects. I finally said “f*ck this” and told my colleges that I had to start again from scratch on the web application because I could not maintain it any longer (we all know a real programmer can write an application that is 2-3 times the size he can maintain). So I started with Dojo and have not looked back att jQuery once. I do not blame jQuery for my failure. I had no experience with javascript development and did not really have any idea on how to go at it.

Hello world!

April 4, 2012


My idea with this blog is to provide help to people NOT experts in javascript and Dojo. I do not consider myself an expert and do not really aspire to be one. I just want to get the job done and in the simplest way possible that generate high quality code that is reasonably maintainable by myself and others.

So this blog is for people like me and if I manage to make it what I want to I know it is missing today. Exactly what and why I feel it is missing is something I will elaborate further on in later posts.

The future will tell if I succeeded in my mission and if I discover I was wrong about the “missing” part I may simply cease blogging.

Boring Facts About Me

Swede. Not a native English speaker so if my English is bad, please forgive me and feel free to correct me. I do not mind at all.

M.Sc. Electrical Engineering KTH (Royal Institute of Technology) way back when. My studies focused on signal processing, something I have never worked with professionally. Became a “hacker” during my studies at KTH, in those days a hacker was somebody who simply liked to play with computers and not somebody writing malicious code to break down the internet, or whatever. A true nerd.

Went on to work as an electrical engineer for a few years but soon drifted into software engineering and never really left except for some brief excursions as a manager for teams and projects.

For more information relevant to the Dojo topic, check about the About tab.