jQuery is translating/interpreting that new language
for you. jQuery is more than just JavaScript it's an
interpreter/compiler for a new language.
What? Care to explain what does jQuer "compile" your "new language" to? The fact that jQuery uses CSS syntax to target
DOM elements does not turn it into compiler. Or are you saying that it somehow runs the selector?
Because jQuery's selectors are a superset of CSS, there is no browser that supports them. So something must must be parsing them and interpreting their meaning.
That means jQuery has a built in interpreter. Now, if jQuery ever turns that selector text into a slightly more efficient internal representation before it gets executed, then it has compiled the selector language to some intermediate form.
Another example is regular expressions. For example, any time you use a regular expression, your expression gets compiled into a NFA or DFA. Your input text is then is "run" on that machine.
Sorry, but you are talking nonsense. jQuery uses CSS3 syntax (most browsers understand this syntax just fine) plus some extra. Selector in jQuery is just a parameter.
If I tic-tac-toe which has function t3(position, value) and pass call it t3("top left", "x") would you claim that "top left" somehow is compiled and executed?
Really, how do you execute CSS selector?
jQuery uses sizzle (http://sizzlejs.com) as CSS selector library, it parses CSS and returns elements matched but it does not run anything.
Or do you think that Apple really did ban parsing of parameters passed to JavaScript functions?
On the other hand I'd love to see iPhone app written in CSS selectors.
If you look at the source code for Sizzle, and know something about compilers and virtual machines, you'll see that the Expr object is modeled as as set of VM instructions. chunker is a regular expression that "tokenizes" the selector into sets of instructions. The appropriate VM instruction is then run for each chunk inside a loop in the Sizzle function.
That's my explanation for how these selectors are, in fact, a language that is compiled and executed.
Sorry, but if you knew what you are talking about, you would not call a parser with callbacks a compiler with VM. Maybe SAX parsers are also compilers and run some VM?
What does parsed CSS selector compile to? Where is that VM and what does it run? Bytecode?
Sizzle is just a parser what parses given selector into parts, gets matchin DOM elements, filters them and returns what matches. There is no compilation or virtual machines involved, just some string parsing, callbacks and DOM API.