<?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/"
		>
<channel>
	<title>Comments for splat operator</title>
	<atom:link href="http://splatoperator.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://splatoperator.com</link>
	<description>:computering =&#62; *&#039;a&#039;..&#039;z&#039;</description>
	<lastBuildDate>Wed, 18 Jan 2012 15:58:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>Comment on Defining Functions Inline Is Just Fine by Lashell</title>
		<link>http://splatoperator.com/2012/01/defining-functions-inline-is-just-fine/#comment-494</link>
		<dc:creator>Lashell</dc:creator>
		<pubDate>Wed, 18 Jan 2012 15:58:33 +0000</pubDate>
		<guid isPermaLink="false">http://sidewaysmilk.com/?p=353#comment-494</guid>
		<description>&lt;p&gt;Bookmarked, I love your site! :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Bookmarked, I love your site! :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Performance: Iterating over Arrays with Holes by Christian Iversen</title>
		<link>http://splatoperator.com/2012/01/javascript-performance-iterating-over-arrays-with-holes/#comment-493</link>
		<dc:creator>Christian Iversen</dc:creator>
		<pubDate>Sat, 14 Jan 2012 11:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://sidewaysmilk.com/?p=363#comment-493</guid>
		<description>&lt;p&gt;If you look for a sorted list of integers in a sorted list of integers, you can do that in O(n+m) time, which is O(n) when m is a constant or &quot;always smallish&quot;. It&#039;s certainly better than O(n^2). Do this simply by sorting each list, and stepping the index of the list with the smaller value. If it&#039;s the same value, you&#039;ve found an element, and you step both indices. This is a very simple algorithm, that is actually very efficient.&lt;/p&gt;

&lt;p&gt;I agree though, if you never have more than 100 records(ish), no complex solution will ever beat the simple one, because of the rather large constants involved in setting it up. JavaScript is (thankfully) rarely a langauge for large dataset processing anyway :)&lt;/p&gt;

&lt;p&gt;And yes, I completely agree with the main point: the &quot;good enough&quot; solution takes maybe 20% of the time of the &quot;best&quot;, so it&#039;s vastly better overall.&lt;/p&gt;

&lt;p&gt;And yes, a break; (or even just a return) would be appropriate :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If you look for a sorted list of integers in a sorted list of integers, you can do that in O(n+m) time, which is O(n) when m is a constant or &#8220;always smallish&#8221;. It&#8217;s certainly better than O(n^2). Do this simply by sorting each list, and stepping the index of the list with the smaller value. If it&#8217;s the same value, you&#8217;ve found an element, and you step both indices. This is a very simple algorithm, that is actually very efficient.</p>

<p>I agree though, if you never have more than 100 records(ish), no complex solution will ever beat the simple one, because of the rather large constants involved in setting it up. JavaScript is (thankfully) rarely a langauge for large dataset processing anyway :)</p>

<p>And yes, I completely agree with the main point: the &#8220;good enough&#8221; solution takes maybe 20% of the time of the &#8220;best&#8221;, so it&#8217;s vastly better overall.</p>

<p>And yes, a break; (or even just a return) would be appropriate :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Performance: Iterating over Arrays with Holes by force</title>
		<link>http://splatoperator.com/2012/01/javascript-performance-iterating-over-arrays-with-holes/#comment-492</link>
		<dc:creator>force</dc:creator>
		<pubDate>Fri, 13 Jan 2012 17:44:28 +0000</pubDate>
		<guid isPermaLink="false">http://sidewaysmilk.com/?p=363#comment-492</guid>
		<description>&lt;p&gt;Very interesting! Thanks for the thorough reply. Addressing point &lt;strong&gt;2&lt;/strong&gt;, I actually did consider indexing the IDs (they are unique) and using them for lookup. This is an approach that I have used in the past, binary search and all. But then I weighed the complexity and readability against possible performance implications, and I decided not to write it. I should probably have set some more parameters. The jsPerf that I made really only tells us anything about fairly small data sets. For the problem that inspired this blog, I can be certain that we&#039;ll never have more than 100 records so that&#039;s sort of what I was looking at. The main goal in my jsPerf was to see if skipping a bunch of undefined array elements by doing a simple &quot;if (this)&quot; was negligibly cheap. The novelty for me was the realization that I should use the simplest solution rather than try to optimize the hell out of every part of the application. Of course, I spent more time thinking about it, constructing the jsPerf and writing about it than I saved implementing a lookup solution. But I&#039;ll still call it a win since I think I&#039;m getting better at learning when the &quot;good enough&quot; solution is better than the &quot;best&quot; solution.&lt;/p&gt;

&lt;p&gt;P.S. You know, I never apply big O. I don&#039;t know why. Obviously, I need to retrain myself. :)&lt;/p&gt;

&lt;p&gt;P.P.S. I just realized that I don&#039;t break the loop when I find the element in the &quot;complex&quot; result, meaning every single lookup is O(n) instead of averaging like O(n/2). Derp.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Very interesting! Thanks for the thorough reply. Addressing point <strong>2</strong>, I actually did consider indexing the IDs (they are unique) and using them for lookup. This is an approach that I have used in the past, binary search and all. But then I weighed the complexity and readability against possible performance implications, and I decided not to write it. I should probably have set some more parameters. The jsPerf that I made really only tells us anything about fairly small data sets. For the problem that inspired this blog, I can be certain that we&#8217;ll never have more than 100 records so that&#8217;s sort of what I was looking at. The main goal in my jsPerf was to see if skipping a bunch of undefined array elements by doing a simple &#8220;if (this)&#8221; was negligibly cheap. The novelty for me was the realization that I should use the simplest solution rather than try to optimize the hell out of every part of the application. Of course, I spent more time thinking about it, constructing the jsPerf and writing about it than I saved implementing a lookup solution. But I&#8217;ll still call it a win since I think I&#8217;m getting better at learning when the &#8220;good enough&#8221; solution is better than the &#8220;best&#8221; solution.</p>

<p>P.S. You know, I never apply big O. I don&#8217;t know why. Obviously, I need to retrain myself. :)</p>

<p>P.P.S. I just realized that I don&#8217;t break the loop when I find the element in the &#8220;complex&#8221; result, meaning every single lookup is O(n) instead of averaging like O(n/2). Derp.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript Performance: Iterating over Arrays with Holes by Christian Iversen</title>
		<link>http://splatoperator.com/2012/01/javascript-performance-iterating-over-arrays-with-holes/#comment-490</link>
		<dc:creator>Christian Iversen</dc:creator>
		<pubDate>Fri, 13 Jan 2012 11:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://sidewaysmilk.com/?p=363#comment-490</guid>
		<description>&lt;p&gt;Sorry to be a pain, but I&#039;ve had to consider this sort of thing quite a few times while developing pyjaco, so I thought I&#039;d offer my 2 øre ;-)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You use an iteration function that always &lt;em&gt;itself&lt;/em&gt; iterates over the entire dataset, turning your complex solution into O(n^2), while the simple one is using the built-in hash lookup of the javascript engine, which is between O(1) and O(n) on average, depending on the hash details and implementation of the js engine.&lt;/li&gt;
&lt;li&gt;You never exploit the fact that the numeric ID is (I presume?) unique. You could use this to build a index table, so you have id(n) == index[n] and val(n) == value[n].&lt;/li&gt;
&lt;li&gt;If you had this kind of table, you have multiple options, the most obvious being a binary table search for the ID (inline instead of recursive for a constant-time speed bonus). Buckets+linear or buckets+binary would also be viable options.&lt;/li&gt;
&lt;li&gt;If the complex solution wasn&#039;t O(n^2) it would still be unlikely that it would win for datasets this small. Even a very well-tuned implementation will probably need around 100 elements before we can see any real effect of the choice of algorithm.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On a related, but not identical note, here&#039;s the jsPerf results of iterating over sparse arrays&lt;/p&gt;

&lt;p&gt;http://jsperf.com/iterate-sparse&lt;/p&gt;

&lt;p&gt;Now, this is just &lt;em&gt;getting&lt;/em&gt; to the elements at all, without even searching for them, so this is only half the puzzle. But you can see quite clearly that in this case, the simplest solution also wins (for key in array), while competing solutions are only marginally slower though. I have an (unprooven) feeling that some of these sparse-array implementations would lend themselves well to fast searching, too.&lt;/p&gt;

&lt;p&gt;&quot;Fun&quot; fact: I went through something similar when implementing Python dictionaries in Pyjaco. Keys can be any hashable object (pretty much any python object at all), so JavaScript can&#039;t even &lt;em&gt;store&lt;/em&gt; the key, unless I do something like this, using the object as the ID. Now, I ended up using a (key, value) array-of-arrays, and just searching through it linearly when looking for a value!&lt;/p&gt;

&lt;p&gt;It wont scale up to many elements, but for the rather small datasets I&#039;ve worked with for now, it&#039;s actually the fastest solution (and by far, the simplest). Lesson? Don&#039;t ever prematurely optimize. So yes, I do agree with your point, even if I don&#039;t entirely agree with your findings :-)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Sorry to be a pain, but I&#8217;ve had to consider this sort of thing quite a few times while developing pyjaco, so I thought I&#8217;d offer my 2 øre ;-)</p>

<ol>
<li>You use an iteration function that always <em>itself</em> iterates over the entire dataset, turning your complex solution into O(n^2), while the simple one is using the built-in hash lookup of the javascript engine, which is between O(1) and O(n) on average, depending on the hash details and implementation of the js engine.</li>
<li>You never exploit the fact that the numeric ID is (I presume?) unique. You could use this to build a index table, so you have id(n) == index[n] and val(n) == value[n].</li>
<li>If you had this kind of table, you have multiple options, the most obvious being a binary table search for the ID (inline instead of recursive for a constant-time speed bonus). Buckets+linear or buckets+binary would also be viable options.</li>
<li>If the complex solution wasn&#8217;t O(n^2) it would still be unlikely that it would win for datasets this small. Even a very well-tuned implementation will probably need around 100 elements before we can see any real effect of the choice of algorithm.</li>
</ol>

<p>On a related, but not identical note, here&#8217;s the jsPerf results of iterating over sparse arrays</p>

<p><a href="http://jsperf.com/iterate-sparse" rel="nofollow">http://jsperf.com/iterate-sparse</a></p>

<p>Now, this is just <em>getting</em> to the elements at all, without even searching for them, so this is only half the puzzle. But you can see quite clearly that in this case, the simplest solution also wins (for key in array), while competing solutions are only marginally slower though. I have an (unprooven) feeling that some of these sparse-array implementations would lend themselves well to fast searching, too.</p>

<p>&#8220;Fun&#8221; fact: I went through something similar when implementing Python dictionaries in Pyjaco. Keys can be any hashable object (pretty much any python object at all), so JavaScript can&#8217;t even <em>store</em> the key, unless I do something like this, using the object as the ID. Now, I ended up using a (key, value) array-of-arrays, and just searching through it linearly when looking for a value!</p>

<p>It wont scale up to many elements, but for the rather small datasets I&#8217;ve worked with for now, it&#8217;s actually the fastest solution (and by far, the simplest). Lesson? Don&#8217;t ever prematurely optimize. So yes, I do agree with your point, even if I don&#8217;t entirely agree with your findings :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Delete a Line from a File by Its Line Number by force</title>
		<link>http://splatoperator.com/2011/09/delete-a-line-from-a-file-by-its-line-number/#comment-438</link>
		<dc:creator>force</dc:creator>
		<pubDate>Mon, 28 Nov 2011 19:23:53 +0000</pubDate>
		<guid isPermaLink="false">http://sidewaysmilk.com/?p=187#comment-438</guid>
		<description>&lt;p&gt;Do you mean that supplying the IP address instead of the host or domain name fixes this? I will give that a try the next time it comes up. Thanks!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Do you mean that supplying the IP address instead of the host or domain name fixes this? I will give that a try the next time it comes up. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Delete a Line from a File by Its Line Number by Alex</title>
		<link>http://splatoperator.com/2011/09/delete-a-line-from-a-file-by-its-line-number/#comment-437</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Mon, 28 Nov 2011 18:17:54 +0000</pubDate>
		<guid isPermaLink="false">http://sidewaysmilk.com/?p=187#comment-437</guid>
		<description>&lt;p&gt;Actually, the easier way is to do this:
ssh-keygen -R 192.168.0.1&lt;/p&gt;

&lt;p&gt;---Alex&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Actually, the easier way is to do this:
ssh-keygen -R 192.168.0.1</p>

<p>&#8212;Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Shift + Scroll = Horizontal Scroll in Linux by Jacob</title>
		<link>http://splatoperator.com/2010/01/shift-scroll-horizontal-scroll-in-linux/#comment-210</link>
		<dc:creator>Jacob</dc:creator>
		<pubDate>Wed, 22 Jun 2011 00:40:49 +0000</pubDate>
		<guid isPermaLink="false">http://sidewaysmilk.com/?p=48#comment-210</guid>
		<description>&lt;p&gt;This is exactly what I was looking for, thank you so much!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This is exactly what I was looking for, thank you so much!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

