Late to the JQuery Party
You may be wondering what happened to my usual Monday post.
Well, I was having my head rearranged by JQuery. I have to admit, I am pretty late to the party. I haven’t really been using JQuery at all the past few years.
I missed a lot.
Goodbye type safety
This part scares me a little bit. I already made a few typos that were pretty hard to detect.
But, the trade-off just might be worth it.
What we are losing in type safety, we are making up for in productivity and speed. It is really fast to manipulate a page using JQuery and to hook up events.
Perhaps some kind of Script# / JQuery bastard child?
I like the functional thinking paradigm. One of my co-workers was saying that he likes JQuery because it helps him to write Lamba expressions and LINQ queries. I tend to agree with him.
I’ve said it before, but I believe the next high abstraction of programming is thinking functionally.
So many pieces of code that I would have used code generation to produce in the past, I can now produce with Lambda expressions.
It’s not all roses
Bleeding all the way through the stack
The downfall of this is that it is a very leaky abstraction. Abstractions are good because they allow us to think at a higher level.
Leaky abstractions are bad because they force us to context switch from a higher level of thinking down to a lower level.
Think for a second about all the “languages” or technologies you have to know to develop an ASP.NET web page using JQuery and MVC.
- ASP.NET MVC
- C# or Visual Basic
- Web Services / Rest
- HTTP (You need to be able to debug all the coolness you are flinging back and forth.)
When you have it all working, it is pretty slick. Very slick indeed, but it is not a sustainable model. It is complex and sprinkled with errors and gotchas.
Debugging / readability
When I am writing JQuery, although I feel like it is magical and cool, I also feel a little bit dirty.
Well, as clean as you try to write JQuery code, it can be pretty nasty. There is a lot of magic going on and it is not very easily understandable.
Perhaps I’ll get better at expressing my intent clearly in JQuery code, but I am pretty sure it has to due in part with the leakiness of the abstraction layer, and that can’t really be cleaned up easily.
Debugging is also hell. I tried debugging through the validation library to see why my error messages weren’t showing up, and it was no picnic.
One of the things I really enjoyed while writing JQuery code was putting the view logic where it really belongs. It is nice to have a language and a server separating the view logic from the model and presentation.
JQuery really allows you to put all the code that manipulates the view in one place, and on the client side, where it really belongs.
JQuery will make your HTML code so much cleaner and helps to actually plug the leaks in the HTML abstraction layer. (Although it isn’t perfect, especially when working with ASP.NET Web Forms.)
Better late then never at all
So I know I’m really late to the JQuery party, but I’m here now and I am liking it.
Overall, I’d recommend taking a look at JQuery if you are like me and hadn’t really used it until now. It definitely is a valuable skill to develop and is growing at an extremely rapid pace.