<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: Implementing the Sizzle Selector Engine in&#160;MooTools</title> <atom:link href="http://davidwalsh.name/mootools-sizzle/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/mootools-sizzle</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 14:01:31 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Henrik Lindqvist</title><link>http://davidwalsh.name/mootools-sizzle#comment-7773</link> <dc:creator>Henrik Lindqvist</dc:creator> <pubDate>Thu, 12 Feb 2009 18:16:22 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7773</guid> <description>Don&#039;t trust benchmarks, especially an unmodified Slickspeed.What many seems to forget when using it, is that it only runs the query once. On a fast computer that almost always gives a 0 ms result. That doesn&#039;t mean it&#039;s instant, only that it took less that 1 ms. The problem is that timing in JavaScript is limited to milliseconds. So to get a true measurement the query must be run so many times that the total time takes a few ms, then divide the time by iteration count.When testing our &lt;a href=&quot;http://llamalab.com/js/selector/&quot; rel=&quot;nofollow&quot;&gt;selector&lt;/a&gt; we use a modified &lt;a href=&quot;http://llamalab.com/js/selector/slickspeed/index.php&quot; rel=&quot;nofollow&quot;&gt;Slickspeed&lt;/a&gt;. The results are quite interesting.</description> <content:encoded><![CDATA[<p>Don&#8217;t trust benchmarks, especially an unmodified Slickspeed.</p><p>What many seems to forget when using it, is that it only runs the query once. On a fast computer that almost always gives a 0 ms result. That doesn&#8217;t mean it&#8217;s instant, only that it took less that 1 ms. The problem is that timing in JavaScript is limited to milliseconds. So to get a true measurement the query must be run so many times that the total time takes a few ms, then divide the time by iteration count.</p><p>When testing our <a
href="http://llamalab.com/js/selector/" rel="nofollow">selector</a> we use a modified <a
href="http://llamalab.com/js/selector/slickspeed/index.php" rel="nofollow">Slickspeed</a>. The results are quite interesting.</p> ]]></content:encoded> </item> <item><title>By: Mark</title><link>http://davidwalsh.name/mootools-sizzle#comment-7765</link> <dc:creator>Mark</dc:creator> <pubDate>Thu, 12 Feb 2009 16:52:38 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7765</guid> <description>@John:&lt;blockquote&gt;
Again, you’re getting way too caught up in the particular example.
&lt;/blockquote&gt;How could I not? It&#039;s the only one you gave? Besides, my college debate professor always told us that you always go for the kill with your first shot--so I assumed you we&#039;re trying to go for the kill with that one.. I was wrong, I guess.. :PAnyway......&lt;blockquote&gt;
Developers should write selectors how they wish and they engines should work to improve. Libraries are there for the user and should implement what the users want - not the other way around.
&lt;/blockquote&gt;I agree completely. And I think the Mootools devs do too, which is why they gave us, the users, the power to do something like this: http://paste.mootools.net/f5a08747c (Thanks to Simo [worrcu] from #mootools for this one).What&#039;s that? It&#039;s an implementation of the &quot;&lt;&quot; selector. Yes, one of the examples you gave. It&#039;s incomplete, since it was just written in the span of a few minutes in between volleys in this thread, but it&#039;s fully functional.So what does this mean? In terms of extensibility of selectors, Mootools is at par with JQuery/Sizzle--those examples can be implemented in Mootools just as they can in Jquery/Sizzle. Of course, you could show us a real example of something Mootools can&#039;t do (no syntax issues please.. :P ), but within the unix timestamp of this reply, Mootools and Sizzle/JQuery is even.Now, one might argue that the example is too complex. &quot;A regular user can&#039;t do that!&quot; But of course! We have to remember that these things--whether it&#039;s a good thing or not--is not within the grasp of regular devs. It will be the intermediate and advance devs that will do these stuff, and they are the ones who actually know how to do it. I don&#039;t know about you guys, but when I started using Mootools, I never had the urge to say, &quot;Gee Golly Wiz! I do wish I could implement a new selector!&quot; (I honestly don&#039;t sound like that in real life..)And for that matter, if you&#039;re an intermediate or advance dev who&#039;s been using Mootools for quite some time, you&#039;ll probably know just how to do these stuff--because you&#039;re already thinking the mootoolsian way.. :)But--and this is the biggie--if extending Sizzle is way easier than this (and by way easier I mean that someone who&#039;s a total noob can do it without banging their head on the table and praying to the Gods of Firebug), then I&#039;ll zip it and have my peace.. :D</description> <content:encoded><![CDATA[<p>@John:</p><blockquote><p> Again, you’re getting way too caught up in the particular example.</p></blockquote><p>How could I not? It&#8217;s the only one you gave? Besides, my college debate professor always told us that you always go for the kill with your first shot&#8211;so I assumed you we&#8217;re trying to go for the kill with that one.. I was wrong, I guess.. :P</p><p>Anyway&#8230;&#8230;</p><blockquote><p> Developers should write selectors how they wish and they engines should work to improve. Libraries are there for the user and should implement what the users want &#8211; not the other way around.</p></blockquote><p>I agree completely. And I think the Mootools devs do too, which is why they gave us, the users, the power to do something like this: <a
href="http://paste.mootools.net/f5a08747c" rel="nofollow">http://paste.mootools.net/f5a08747c</a> (Thanks to Simo [worrcu] from #mootools for this one).</p><p>What&#8217;s that? It&#8217;s an implementation of the &#8220;&lt;&#8221; selector. Yes, one of the examples you gave. It&#8217;s incomplete, since it was just written in the span of a few minutes in between volleys in this thread, but it&#8217;s fully functional.</p><p>So what does this mean? In terms of extensibility of selectors, Mootools is at par with JQuery/Sizzle&#8211;those examples can be implemented in Mootools just as they can in Jquery/Sizzle. Of course, you could show us a real example of something Mootools can&#8217;t do (no syntax issues please.. :P ), but within the unix timestamp of this reply, Mootools and Sizzle/JQuery is even.</p><p>Now, one might argue that the example is too complex. &#8220;A regular user can&#8217;t do that!&#8221; But of course! We have to remember that these things&#8211;whether it&#8217;s a good thing or not&#8211;is not within the grasp of regular devs. It will be the intermediate and advance devs that will do these stuff, and they are the ones who actually know how to do it. I don&#8217;t know about you guys, but when I started using Mootools, I never had the urge to say, &#8220;Gee Golly Wiz! I do wish I could implement a new selector!&#8221; (I honestly don&#8217;t sound like that in real life..)</p><p>And for that matter, if you&#8217;re an intermediate or advance dev who&#8217;s been using Mootools for quite some time, you&#8217;ll probably know just how to do these stuff&#8211;because you&#8217;re already thinking the mootoolsian way.. :)</p><p>But&#8211;and this is the biggie&#8211;if extending Sizzle is way easier than this (and by way easier I mean that someone who&#8217;s a total noob can do it without banging their head on the table and praying to the Gods of Firebug), then I&#8217;ll zip it and have my peace.. :D</p> ]]></content:encoded> </item> <item><title>By: Seph</title><link>http://davidwalsh.name/mootools-sizzle#comment-7764</link> <dc:creator>Seph</dc:creator> <pubDate>Thu, 12 Feb 2009 16:24:39 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7764</guid> <description>@seutje: The issue of minor performance enhancements was not the point so yes: 1 ms here and there isn&#039;t the focus. If you refer to the jQuery test that John made you would see it&#039;s not that close a call after all.
I retire my original comment due to accusations on the version of the Sizzle version used in the test. As you see, the test was deemed outdated.As to the actual flexibility of the codebases I cannot give any thorough comments. But arguing about hypothetical features can only lead to hypothetical results. We usually don&#039;t know what&#039;s next.</description> <content:encoded><![CDATA[<p>@seutje: The issue of minor performance enhancements was not the point so yes: 1 ms here and there isn&#8217;t the focus. If you refer to the jQuery test that John made you would see it&#8217;s not that close a call after all.<br
/> I retire my original comment due to accusations on the version of the Sizzle version used in the test. As you see, the test was deemed outdated.</p><p>As to the actual flexibility of the codebases I cannot give any thorough comments. But arguing about hypothetical features can only lead to hypothetical results. We usually don&#8217;t know what&#8217;s next.</p> ]]></content:encoded> </item> <item><title>By: John Resig</title><link>http://davidwalsh.name/mootools-sizzle#comment-7763</link> <dc:creator>John Resig</dc:creator> <pubDate>Thu, 12 Feb 2009 16:20:45 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7763</guid> <description>@Chris: There&#039;s a difference between &quot;not needed&quot; and &quot;not wanted&quot;. All the examples that I outlined are already possible in Sizzle/jQuery &quot;div:has(a)&quot;, &quot;[id^=foo]&quot;, etc. Like I said &quot;The extensibility requirements for Prototype, Dojo, YUI, and jQuery was much higher, so Sizzle was written accordingly.&quot;Why should developers be forced to work around limitations in selector engines? Developers should write selectors how they wish and they engines should work to improve. Libraries are there for the user and should implement what the users want - not the other way around.As to your statement: &quot;For example .classname will always be slower than tag.classname, thats a fact.&quot; Maybe that&#039;s the case in MooTools, but it&#039;s not the case in Sizzle/jQuery. In Firefox 3, Safari, and Opera - which all implement getElementsByClassName - it is faster to just do &quot;.classname&quot; than to do &quot;tag.classname&quot; (since it requires extra post-processing).</description> <content:encoded><![CDATA[<p>@Chris: There&#8217;s a difference between &#8220;not needed&#8221; and &#8220;not wanted&#8221;. All the examples that I outlined are already possible in Sizzle/jQuery &#8220;div:has(a)&#8221;, &#8220;[id^=foo]&#8220;, etc. Like I said &#8220;The extensibility requirements for Prototype, Dojo, YUI, and jQuery was much higher, so Sizzle was written accordingly.&#8221;</p><p>Why should developers be forced to work around limitations in selector engines? Developers should write selectors how they wish and they engines should work to improve. Libraries are there for the user and should implement what the users want &#8211; not the other way around.</p><p>As to your statement: &#8220;For example .classname will always be slower than tag.classname, thats a fact.&#8221; Maybe that&#8217;s the case in MooTools, but it&#8217;s not the case in Sizzle/jQuery. In Firefox 3, Safari, and Opera &#8211; which all implement getElementsByClassName &#8211; it is faster to just do &#8220;.classname&#8221; than to do &#8220;tag.classname&#8221; (since it requires extra post-processing).</p> ]]></content:encoded> </item> <item><title>By: seutje</title><link>http://davidwalsh.name/mootools-sizzle#comment-7762</link> <dc:creator>seutje</dc:creator> <pubDate>Thu, 12 Feb 2009 16:11:48 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7762</guid> <description>am I the only one who doesn&#039;t care about a 2ms speed increase on a selector that&#039;s virtually only used in test suites?especially because these test suites return a different result every time, sometimes it&#039;s over 20% differenceseriously, what&#039;s next? &quot;omg, my thingy was 1 nanosecond faster in 1/1 000 000 tests&quot;?come on now</description> <content:encoded><![CDATA[<p>am I the only one who doesn&#8217;t care about a 2ms speed increase on a selector that&#8217;s virtually only used in test suites?</p><p>especially because these test suites return a different result every time, sometimes it&#8217;s over 20% difference</p><p>seriously, what&#8217;s next? &#8220;omg, my thingy was 1 nanosecond faster in 1/1 000 000 tests&#8221;?</p><p>come on now</p> ]]></content:encoded> </item> <item><title>By: Chris</title><link>http://davidwalsh.name/mootools-sizzle#comment-7761</link> <dc:creator>Chris</dc:creator> <pubDate>Thu, 12 Feb 2009 16:10:35 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7761</guid> <description>Half of them are not needed in MooTools, apparently MooTools is so powerful we don&#039;t need custom selectors for that. $$(&#039;*[id^=foo]&#039;) gets all elements with a name starting with foo. CSS3 ftw.$$(&#039;a&#039;).getParent(&#039;div&#039;) returns an array with the first div parent of all a elements on the page. You could also probably implement the div:color(red) thing with just checking in your custom selector if color contains red and not only equals red (referring to my blog post from above, this is easily possible). I have no idea what you are doing with a &amp; b but we still have Array.filter so we can do $$(&#039;selector&#039;).filter(fn) to match all needs. So clearly, there is no need for custom selectors, as said. Also, I think adding a custom Syntax doesn&#039;t make it any easier, MooTools sticks with the :name(property) selector so it still looks natural.I want to add that it is not a good idea to optimize the selectors the people use but rather to advocate the recommended usage. For example .classname will always be slower than tag.classname, thats a fact and you (as in: the application developer) should optimize the selectors where appropriate. Given the nature of jQuery to appeal to people not knowing a thing about javascript this might not be possible for you, luckily for us MooTools states it is for the &quot;intermediate to advanced developer&quot; only, so we can :)</description> <content:encoded><![CDATA[<p>Half of them are not needed in MooTools, apparently MooTools is so powerful we don&#8217;t need custom selectors for that. $$(&#8216;*[id^=foo]&#8216;) gets all elements with a name starting with foo. CSS3 ftw.</p><p>$$(&#8216;a&#8217;).getParent(&#8216;div&#8217;) returns an array with the first div parent of all a elements on the page. You could also probably implement the div:color(red) thing with just checking in your custom selector if color contains red and not only equals red (referring to my blog post from above, this is easily possible). I have no idea what you are doing with a &amp; b but we still have Array.filter so we can do $$(&#8216;selector&#8217;).filter(fn) to match all needs. So clearly, there is no need for custom selectors, as said. Also, I think adding a custom Syntax doesn&#8217;t make it any easier, MooTools sticks with the :name(property) selector so it still looks natural.</p><p>I want to add that it is not a good idea to optimize the selectors the people use but rather to advocate the recommended usage. For example .classname will always be slower than tag.classname, thats a fact and you (as in: the application developer) should optimize the selectors where appropriate. Given the nature of jQuery to appeal to people not knowing a thing about javascript this might not be possible for you, luckily for us MooTools states it is for the &#8220;intermediate to advanced developer&#8221; only, so we can :)</p> ]]></content:encoded> </item> <item><title>By: david</title><link>http://davidwalsh.name/mootools-sizzle#comment-7760</link> <dc:creator>david</dc:creator> <pubDate>Thu, 12 Feb 2009 16:00:26 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7760</guid> <description>&lt;p&gt;Getting back to the point of the article....&quot;and that is how you implement Sizzle in MooTools IF YOU WISH TO.&quot;&lt;/p&gt;</description> <content:encoded><![CDATA[<p>Getting back to the point of the article&#8230;.&#8221;and that is how you implement Sizzle in MooTools IF YOU WISH TO.&#8221;</p> ]]></content:encoded> </item> <item><title>By: John Resig</title><link>http://davidwalsh.name/mootools-sizzle#comment-7758</link> <dc:creator>John Resig</dc:creator> <pubDate>Thu, 12 Feb 2009 15:57:20 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7758</guid> <description>@Mark: Performance is only one piece of the puzzle. You can have awesome performance if you sacrifice extensibility - which is, obviously, something that neither jQuery nor MooTools wishes to do.Again, you&#039;re getting way too caught up in the particular example. Just to give some examples of the type of selectors that we&#039;ve been discussing as possible plugins since we have an extensible engine.&quot;div &lt; a&quot; - Find all divs that are a parent of an anchor.
&quot;a &amp; b&quot; - Find all anchors and bold words - but only if they both exist.
&quot;#foo*&quot; - Find all elements that have an ID that begins with foo.
&quot;div{color*=red}&quot; - Find all divs whose style color property contains the color red.Obviously there is some disagreement as to if adding in new selectors is useful - I say that it is (it empowers the user to create the selectors that best suit their use cases). But, again, while MooTools is extensible - it is so for a limited subset of functionality. The extensibility requirements for Prototype, Dojo, YUI, and jQuery was much higher, so Sizzle was written accordingly.</description> <content:encoded><![CDATA[<p>@Mark: Performance is only one piece of the puzzle. You can have awesome performance if you sacrifice extensibility &#8211; which is, obviously, something that neither jQuery nor MooTools wishes to do.</p><p>Again, you&#8217;re getting way too caught up in the particular example. Just to give some examples of the type of selectors that we&#8217;ve been discussing as possible plugins since we have an extensible engine.</p><p>&#8220;div &lt; a&#8221; &#8211; Find all divs that are a parent of an anchor.<br
/> &#8220;a &amp; b&#8221; &#8211; Find all anchors and bold words &#8211; but only if they both exist.<br
/> &#8220;#foo*&#8221; &#8211; Find all elements that have an ID that begins with foo.<br
/> &#8220;div{color*=red}&#8221; &#8211; Find all divs whose style color property contains the color red.</p><p>Obviously there is some disagreement as to if adding in new selectors is useful &#8211; I say that it is (it empowers the user to create the selectors that best suit their use cases). But, again, while MooTools is extensible &#8211; it is so for a limited subset of functionality. The extensibility requirements for Prototype, Dojo, YUI, and jQuery was much higher, so Sizzle was written accordingly.</p> ]]></content:encoded> </item> <item><title>By: Mark</title><link>http://davidwalsh.name/mootools-sizzle#comment-7757</link> <dc:creator>Mark</dc:creator> <pubDate>Thu, 12 Feb 2009 15:42:55 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7757</guid> <description>@John: Your example is compelling--but I have to ask, &quot;What?!&quot;&lt;blockquote&gt;
The syntax may not be to your liking but the fact remains.
&lt;/blockquote&gt;This statement is too weird. What fact? That Mootools can&#039;t implement something that looks so... uh, I dunno.. &quot;unnatural&quot;?So what if Mootools can&#039;t do a &quot;div{color=red}&quot;? As Chris showed us, it&#039;s fully capable of doing a &quot;div:color(red)&quot;--which I assume is exactly the same thing, but somehow looks more like native selectors and, in my vote, is certainly more appealing syntax-wise.Please remember that syntax has nothing to do with how extensible Mootools or Sizzle is. Suppose the Mootools team decides to allow something like &quot;div:c:o:l:o:r:{&amp;r&amp;e&amp;d}&quot; which has the same capabilities as your example (God I hope not). Would it be justifiable if Val told you that Mootools is more extensible than Sizzle just because it can do that, even if &quot;the syntax may not be to your liking&quot;? I don&#039;t think so.Don&#039;t pass judgement solely on syntax, because whatever syntax the engine uses, it&#039;s whether or not it could correctly parse the DOM that matters. And Mootools has already shown that--it just so happens that Mootools prefers code that actually looks good.So let&#039;s get back on what really matters: whether or not Sizzle really outperforms Mootools.</description> <content:encoded><![CDATA[<p>@John: Your example is compelling&#8211;but I have to ask, &#8220;What?!&#8221;</p><blockquote><p> The syntax may not be to your liking but the fact remains.</p></blockquote><p>This statement is too weird. What fact? That Mootools can&#8217;t implement something that looks so&#8230; uh, I dunno.. &#8220;unnatural&#8221;?</p><p>So what if Mootools can&#8217;t do a &#8220;div{color=red}&#8221;? As Chris showed us, it&#8217;s fully capable of doing a &#8220;div:color(red)&#8221;&#8211;which I assume is exactly the same thing, but somehow looks more like native selectors and, in my vote, is certainly more appealing syntax-wise.</p><p>Please remember that syntax has nothing to do with how extensible Mootools or Sizzle is. Suppose the Mootools team decides to allow something like &#8220;div:c:o:l:o:r:{&amp;r&amp;e&amp;d}&#8221; which has the same capabilities as your example (God I hope not). Would it be justifiable if Val told you that Mootools is more extensible than Sizzle just because it can do that, even if &#8220;the syntax may not be to your liking&#8221;? I don&#8217;t think so.</p><p>Don&#8217;t pass judgement solely on syntax, because whatever syntax the engine uses, it&#8217;s whether or not it could correctly parse the DOM that matters. And Mootools has already shown that&#8211;it just so happens that Mootools prefers code that actually looks good.</p><p>So let&#8217;s get back on what really matters: whether or not Sizzle really outperforms Mootools.</p> ]]></content:encoded> </item> <item><title>By: John Resig</title><link>http://davidwalsh.name/mootools-sizzle#comment-7756</link> <dc:creator>John Resig</dc:creator> <pubDate>Thu, 12 Feb 2009 15:02:00 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1454#comment-7756</guid> <description>@Chris: I like your demo - definitely a compelling extension. Valerio was looking for an example of something that couldn&#039;t be done with the MooTools selector engine - so I showed him one example. The syntax may not be to your liking but the fact remains. (If it can be done, I&#039;d love to be corrected - but I don&#039;t see an obvious way to make the extension.)</description> <content:encoded><![CDATA[<p>@Chris: I like your demo &#8211; definitely a compelling extension. Valerio was looking for an example of something that couldn&#8217;t be done with the MooTools selector engine &#8211; so I showed him one example. The syntax may not be to your liking but the fact remains. (If it can be done, I&#8217;d love to be corrected &#8211; but I don&#8217;t see an obvious way to make the extension.)</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/7 queries in 0.009 seconds using disk: basic
Object Caching 805/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 10:36:36 -->
