1

jQuery is a Javascript library and framework, but when we are programming with jQuery into DOM problems/solutions, we can practice a style quite different of programming... We can read about jQuery at Wikipedia,

The set of jQuery core features — DOM element selections, traversal and manipulation —, enabled by its selector engine (...), created a new "programming style", fusing algorithms and DOM-data-structures

This question is similar to the "subquestion-3" of this question but not so generic. The focus here is about this new kind of "programming style"... So, the question:

Is the "jQuery programming style in DOM context" a new paradign? Or it is more one example of reactive programming (not "cell-oriented" but "DOM-node oriented") or another one?


We have no "standard taxonomy of paradigms", so, please, in your answer, indicate also your "best choice for Wikipedia Paradign".

Example: if you understand that "jQuery programming DOM" is like "awk filtering data", your choice can be event-driven.

  • JQuery = functional paradigm + chained methods. Existing concepts used by J Resig create a library that deals with DOM elegantly – OnesimusUnbound Jul 2 '13 at 12:53
  • "chained methods", for me, is like a UNIX pipeline, so, it is a dataflow. "functional paradigm" is something so generic... "functional paradigm + chained methods" describe syntax features, but not indicate the "new paradigm", based on selectors ... The jQuery selectors are like XSLT template selectors, or AWK events. – Peter Krauss Jul 2 '13 at 12:58
  • jQuery selectors are like XSLT template selectors to be precise, they're CSS Selector + JQuery-specific. Anyway, I agree chained method simulates UNIX piping. My point is that JQuery used existing paradigms to create an elegant way to deal with DOM. – OnesimusUnbound Jul 2 '13 at 13:03
  • Ok, you understand the point... I edited to suggest that answer indicates exactly the "best choice" for paradigm. – Peter Krauss Jul 2 '13 at 15:41
  • it's monadic. you have a bunch of things that act on stuff in a box, and each one returns a box with stuff in it, so you can compose them using monadic composition. Haskell has shown, the kleisli triple is a paradigm :) – Jimmy Hoffa Jul 2 '13 at 15:45
3

If there is a paradigm in use in jQuery, it is functional programming, with some Fluent Interface sprinkled in for good measure. It is the fluent interface pattern that provides for the method chaining capability.

Beyond that, it's simply clever and deliberate application of an API. Under the hood, there's a lot of jiggery going on to insure cross-browser compatibility, but the foundational ideas behind jQuery are relatively simple. Just goes to show you how useful a well-designed API can be.

| improve this answer | |
  • See @OnesimusUnbound comments: "chained methods" are pipelines... And I undertand "fluent interface" as "chain method" synonymous, is not it? About jQuery, the focus of the question is only "jQuery working with DOM", where a selectors are used. – Peter Krauss Jul 2 '13 at 18:47
  • 1
    How is jQuery "functional"? The selector parts of it might be, but most methods do mutate state in a very unfunctional way. – Bergi Mar 22 '14 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.