<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ashutosh Mehra's Blog &#187; Humor</title>
	<atom:link href="http://ashutoshmehra.net/blog/category/humor/feed/" rel="self" type="application/rss+xml" />
	<link>http://ashutoshmehra.net/blog</link>
	<description>Notes on Math, Computer Science &#38; Programming</description>
	<lastBuildDate>Sat, 27 Feb 2010 14:22:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RtlWriteDecodedUcsDataIntoSmartLBlobUcsWritingContext and Other Long Function Names</title>
		<link>http://ashutoshmehra.net/blog/2010/02/long-function-names/</link>
		<comments>http://ashutoshmehra.net/blog/2010/02/long-function-names/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 14:21:27 +0000</pubDate>
		<dc:creator>Ashutosh</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=633</guid>
		<description><![CDATA[Every reader should ask himself periodically &#8220;Toward what end, toward what end?&#8221; &#8212; but do not ask it too often lest you pass up the fun of programming for the constipation of bittersweet philosophy.
&#8211; Alan J. Perlis [foreword to SICP]


I find long functions names charming &#8212; I think they impart a certain personality to the [...]]]></description>
			<content:encoded><![CDATA[<p><i>Every reader should ask himself periodically &#8220;Toward what end, toward what end?&#8221; &#8212; but do not ask it too often lest you pass up the fun of programming for the constipation of bittersweet philosophy.<br/>
<p style="text-align:right">&#8211; Alan J. Perlis [<a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-5.html">foreword to SICP</a>]</p>
<p></i></p>
<div class="alignright" style="margin-left: 5px"><img border="0" src="http://ashutoshmehra.net/images/posts/funcnames/RtlWriteDecodedUcsDataIntoSmartLBlobUcsWritingContext.png" width="250px" alt="RtlWriteDecodedUcsDataIntoSmartLBlobUcsWritingContext (53 characters)"></div>
<p>I find long functions names charming &#8212; I think they impart a certain personality to the API and add to the <i>fun</i> of programming. And while I try to avoid excessively long names in my own code at work (unless they add to clarity), I never fail to get a good kick seeing such names used by other programmers! <span id="more-633"></span></p>
<p>I&#8217;ve often wondered what the longest names would look like. So I decided to explore a large system &#8212; the system DLLs in <tt>C:\Windows</tt> directory &#8212; and dig up some of the biggies. My plan was to write a script that walked through the installed DLLs and looked at their exported functions list for interesting candidates.</p>
<h4>The Winners</h4>
<p>Here are the longer ones I could find:</p>
<ul>
<li><tt>RtlWriteDecodedUcsDataIntoSmartLBlobUcsWritingContext</tt> [wcp.dll], with 53-characters, was the longest one (but this function is not documented)</li>
<li>(52) <a href="http://msdn.microsoft.com/en-us/library/aa376397%28VS.85%29.aspx"><tt>ConvertSecurityDescriptorToStringSecurityDescriptor{A,W}</tt> [advapi32.dll]</a>, the function that <a href="http://en.wikipedia.org/wiki/Raymond_Chen">Raymond Chen</a> admitted was the reason for <a href="http://blogs.msdn.com/oldnewthing/archive/2004/03/12/88572.aspx">his post on security descriptors</a>.
<li>(52) <a href="http://msdn.microsoft.com/en-us/library/aa376397%28VS.85%29.aspx"><tt>ConvertStringSecurityDescriptorToSecurityDescriptor{A,W}</tt> [advapi32.dll]</a>, the complement of the above.</li>
<li>(50) <a href="http://msdn.microsoft.com/en-us/library/aa446582%28VS.85%29.aspx"><tt>CreatePrivateObjectSecurityWithMultipleInheritance</tt> [advapi32.dll]</a>, another security function.</li>
<li>(50) <a href="http://msdn.microsoft.com/en-us/library/aa376038%28VS.85%29.aspx"><tt>CertCreateCTLEntryFromCertificateContextProperties</tt> [crypt32.dll]</a>.</li>
<li>(50) <a href="http://msdn.microsoft.com/en-us/library/bb204685%28VS.85%29.aspx"><tt>EapHostPeerQueryUIBlobFromInteractiveUIInputFields</tt> [eappcfg.dll]</a>.</li>
<li>(49) <a href="http://msdn.microsoft.com/en-us/library/aa374843%28VS.85%29.aspx"><tt>AccessCheckByTypeResultListAndAuditAlarmByHandle{A,W}</tt> [advapi32.dll]</a>, yet another security API &#8212; I guess the security API programmers get a good kick from long names, just like me!</li>
<li>(47) <a href="http://msdn.microsoft.com/en-us/library/dd692949%28VS.85%29.aspx"><tt>GetNumberOfPhysicalMonitorsFromIDirect3DDevice9</tt> [Dxva2.lib]</a>.</li>
<li>(43) <a href="http://msdn.microsoft.com/en-us/library/aa377432%28VS.85%29.aspx"><tt>SetupRemoveInstallSectionFromDiskSpaceList{A,W}</tt> [Setupapi.dll]</a>.</li>
</ul>
<p>And just so that no one thinks I&#8217;m making these up, I&#8217;ve linked to their documentation!</p>
<p>Curious on seeing these names, I dug through the other &#8220;operating system&#8221; I had access to &#8212; GNU EMACS. The longest interactive command there is <tt>slime-compiler-notes-default-action-or-show-details/mouse</tt>: Counting punctuations, this beats the longest Windows export by 4 characters.</p>
<h4>The Method</h4>
<p>I used the <a href="http://code.google.com/p/pefile/">pefile Python library</a> to parse all DLLs in my <tt>windows</tt> directory. I only considered &#8220;system&#8221; DLLs (ignoring any third-party drivers etc.) by checking for &#8220;Microsoft&#8221; in the DLL copyright-string. In addition, I discarded any C++-ish exports, because the <a href="http://en.wikipedia.org/wiki/Name_mangling">C++ name-mangling</a> skewed the results too much and I was too lazy to hook in a &#8220;undecoratify&#8221; procedure.</p>
<p>Finally, on my 64-bit windows installation, there are both 32-bit and 64-bit versions of many core DLLs (in <tt>System32</tt> and <tt>SysWOW64</tt> directories respectively), and I encountered duplicates. A similar thing happened with <a href="http://msdn.microsoft.com/en-us/library/aa376307%28VS.85%29.aspx">SxS</a> DLLs.</p>
<p>Using <a href="https://gist.github.com/230c3f53261a20340118">this Python script I coded</a>, I generated a delimitered text-file with around 1500 entries that I manually scanned (I had some time to waste!) for &#8220;interesting&#8221; names. Below is a histogram of the function-name lengths. The rough bell shape gives me confidence that script wasn&#8217;t totally off the mark.</p>
<p><a href="http://ashutoshmehra.net/images/posts/funcnames/histogram_large.png"><img border="0" src="http://ashutoshmehra.net/images/posts/funcnames/histogram_large.png" alt="A histogram of the length of functions names exported by system DLLs in the Windows directory"></a></p>
<h4>Functions Taking Lots of Parameters</h4>
<p>A second axis to dig &#8220;interesting&#8221; functions would be to count the <i>number of function params</i>. </p>
<p>This one is a bit of fuzzy due to questions like &#8220;Do you count <i>deep</i>&#8220;? In that when a function accepts a pointer to a struct, do you count the struct members as inputs too? For instance, <a href="http://msdn.microsoft.com/en-us/library/dd183501%28VS.85%29.aspx"><tt>CreateFontIndirectEx</tt> [gdi32.dll]</a> takes a pointer to <a href="http://msdn.microsoft.com/en-us/library/dd162628%28VS.85%29.aspx"><tt>ENUMLOGFONTEXDV</tt></a> structure that holds about two dozen items (all things considered).</p>
<p>Counting params is also more work, at least for DLL exports (where you need to cross-reference with documentation/headers if the export is, at all, public). Otherwise, the problem can be approached differently by forgetting DLL exports entirely and instead using a crawler that walks the the locally installed MSDN and parses the &#8220;Syntax&#8221; section to count the number of params &#8212; just assuming <tt>num_params = num_commas + 1</tt> might be good enough.</p>
<p>Anyway, manually browsing through some of MSDN, I chanced upon a few gems:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa374843%28VS.85%29.aspx"><tt>AccessCheckByTypeResultListAndAuditAlarmByHandle</tt></a>, our friend from above, true to its character, takes 17 parameters!</li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms690529%28VS.85%29.aspx"><tt>OleCreateFromFileEx</tt></a> takes in a filename, interface ID, flags, sink, connection, site&#8230; 13 in all.</li>
</ul>
<h4>On a Serious Note</h4>
<p>Well named functions (just like well named variables) are good instant documentation. <i>Descriptive</i> function are important when:</p>
<ul>
<li>Such functions all belong to a flat namespace (DLL exports or C code)</li>
<li>Several of them have very similar purpose (like the six or so <tt>AccessCheck*</tt> APIs)</li>
</ul>
<p>Such names become even more relevant when they define the public API of your library/system.</p>
<p>Some people (&#8220;constipated by bittersweet philosophy&#8221;?) dislike long function names, and I wonder why. The argument that longer functions take longer to type seems mostly dud: Visual Studio with the awesome <a href="http://www.wholetomato.com/">Visual Assist X</a> addon does Intellisense beautifully; Emacs with <tt><a href="http://www.emacswiki.org/emacs/HippieExpand">hippie-expand</a></tt> does some good magic (the brave also have <a href="http://cedet.sourceforge.net/intellisense.shtml">CEDET</a>); Eclipse, BBEdit, and Vim surely have their own thing. So typing isn&#8217;t a problem. And with machines so fast and powerful, the (JIT)compilation/linking-time for longer function names should be irrelevant in most cases.</p>
<h4>Links</h4>
<p>While researching for this entry, I came across the post <a href="http://blogs.msdn.com/brada/archive/2005/01/09/349678.aspx">&#8220;Best&#8221; method names ever</a> by <a href="http://blogs.msdn.com/brada/default.aspx">Brad Abrams</a> that has some interesting content/comments.</p>
<p><i>[Note: Lest someone should give a wicked twist to the whole point of this post, I should add that I have most sincere respect for Microsoft engineers, enjoy using their programs every day and working with their APIs.]</i></p>
]]></content:encoded>
			<wfw:commentRss>http://ashutoshmehra.net/blog/2010/02/long-function-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read wrote Wright&#8230; Graph Theorists playing with words</title>
		<link>http://ashutoshmehra.net/blog/2009/03/read-wrote-wright/</link>
		<comments>http://ashutoshmehra.net/blog/2009/03/read-wrote-wright/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 01:38:31 +0000</pubDate>
		<dc:creator>Ashutosh</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=271</guid>
		<description><![CDATA[
I was going through the first chapter of the book Graphical Enumeration by Frank Harary and Edgar M. Palmer when I chanced upon this perplexing footnote:
Read wrote Wright that both Read [R2]1 and Wright [W3]2 were wrong. So Read and Wright wrote a joint erratum [RW1]3 to set things right. This may be wrong since [...]]]></description>
			<content:encoded><![CDATA[<div class="alignleft" style="margin-right: 5px;"><a href="http://owpdb.mfo.de/detail?photo_id=4390"><img src="http://ashutoshmehra.net/images/posts/readwrotewright/frank_harary_oberwolfach_1972.jpg" alt="Frank Harary, Oberwolfach (1972)" width="130px" /></a></div>
<p>I was going through the first chapter of the book <i>Graphical Enumeration</i> by <a href="http://www.cs.nmsu.edu/fnh/">Frank Harary</a> and <a href="http://genealogy.math.ndsu.nodak.edu/id.php?id=5534">Edgar M. Palmer</a> when I chanced upon this perplexing footnote:</p>
<blockquote><p>Read wrote Wright that both Read [R2]<sup>1</sup> and Wright [W3]<sup>2</sup> were wrong. So Read and Wright wrote a joint erratum [RW1]<sup>3</sup> to set things right. This may be wrong since Wright asserts that Wright wrote Read first.</p></blockquote>
<p><span id="more-271"></span><br />
It appears on Pg. 17 in reference to k-colored graphs. Read and Wright are, of course, the mathematicians <a href="http://en.wikipedia.org/wiki/Ronald_Read">Ronald C. Read</a> and <a href="http://en.wikipedia.org/wiki/E._M._Wright">Edward M. Wright</a>!</p>
<p>A quick glance at the bibliography confirms that the above footnote describes, even if humorously, a true incident. However, I can&#8217;t say what the last sentence means: <q>This may be wrong since Wright asserts that Wright wrote Read first</q>. Does it mean:</p>
<ul>
<li>There is a genuine priority dispute as to who figured the error out [I don't think this is the case]. Or,
<li>Since [RW1] paper has Read as the first author (so, in that sense, &#8220;Read wrote first&#8221;), Wright couldn&#8217;t have written first. Or,</li>
<li>Since &#8220;write&#8221; must happen before &#8220;read&#8221;, Wright wrote first. Or,</li>
<li>It doesn&#8217;t mean anything &#8212; the authors are just playing around with words!</li>
</ul>
<p>I could not find anything relevant by searching the phrase &#8220;Read wrote Wright&#8221; on Google.com. I&#8217;ll be eager to learn any other clues the reader might have as as to the meaning of the last sentence of the footnote.</p>
<p><i>Aside</i>: It is sad that the <i>Graphical Enumeration</i> book, which was published by Academic Press, New York (1973), has apparently gone <a href="http://www.amazon.com/Graphical-Enumeration-Frank-Harary/dp/0123242452">out of print</a>. I&#8217;ve added it to the <a href="http://outofprintmath.blogspot.com/">out of print math blog</a>.
<ol class="footnotes">
<li id="footnote_0_271" class="footnote">[R2] R.C. Read, The number of k-colored graphs on labelled nodes, Canad. J. Math. <b>12</b>, 409&#8211;413 (1960).</li>
<li id="footnote_1_271" class="footnote">[W3] E.M. Wright, Counting coloured graphs, Canad. J. Math. <b>13</b>, 683&#8211;693 (1961).</li>
<li id="footnote_2_271" class="footnote">[RW1] R.C. Read and E.M. Wright, Coloured graphs: A correction and extension, Canad. J. Math. <b>22</b>, 594&#8211;596 (1970).</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://ashutoshmehra.net/blog/2009/03/read-wrote-wright/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Certain autorickshaw phenomena</title>
		<link>http://ashutoshmehra.net/blog/2008/12/autorickshaw-phenomena/</link>
		<comments>http://ashutoshmehra.net/blog/2008/12/autorickshaw-phenomena/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 22:20:29 +0000</pubDate>
		<dc:creator>Ashutosh</dc:creator>
				<category><![CDATA[Humor]]></category>

		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=17</guid>
		<description><![CDATA[

Some time back, I had read a hilarious piece by Shashank, a friend of mine from the days at BITS, Pilani. The auto-podal-tow phenomena that he describes has to be seen to be believed: an autorickshaw towing another with one of the drivers using his leg as a connection! A good soul captured the moment [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ashutoshmehra.net/blog/wp-content/uploads/2008/12/auto-podal-tow.jpg"><br />
<img src="http://ashutoshmehra.net/blog/wp-content/uploads/2008/12/auto-podal-tow-300x225.jpg" alt="The auto-podal-tow" title="auto-podal-tow" width="200" height="150" class="size-medium wp-image-20" style="float:left;padding:8px"/></a></p>
<p>Some time back, I had read <a href="http://shankaholic.blogspot.com/2008/08/auto-podal-tow-and-other-phenomena-on.html">a hilarious piece</a> by Shashank, a friend of mine from the days at <a href="http://www.bits-pilani.ac.in/">BITS, Pilani</a>. The <i>auto-podal-tow</i> phenomena that he describes has to be seen to be believed: an autorickshaw towing another with one of the drivers using his leg as a connection! <a href="http://www.mattlogelin.com/">A good soul</a> captured <a href="http://www.flickr.com/photos/mattlogelin/121647831/">the moment</a> and licensed it under <a href="http://creativecommons.org/licenses/by-nc/2.0/">Creative Commons Attribution-Noncommercial 2.0 Generic</a>.<span id="more-17"></span></p>
<p>It would have been unfortunate to have left a phenomenon as recurrent as the auto-podal-tow without a name. Shashank did his part, and I&#8217;ll do mine by documenting two other phenomena that deserve to be &#8220;named and conquered&#8221;. People who haven&#8217;t been on Indian roads will have to get their imaginations working (since I couldn&#8217;t find images for them).</p>
<p>First there is, what we&#8217;ll call, the <i>autorickshaw-big-v-formation</i>: In a 2-lane road, a bunch of auto-rickshaws (usually three to five in number) do a <a href="http://en.wikipedia.org/wiki/V_formation">V-formation</a> that&#8217;s impossible for anything but a motor-bike/scooter to breach. While the V-formation is the most commonly sighted one, other <a href="http://www.snowbirds.forces.gc.ca/site/airshows/formations_e.asp">tactical formations</a> are also deployed to advantage.</p>
<p>Second, there&#8217;s a phenomenon known as <i>differential-velocity-autorickshaw-overtake-maneuver</i>. To a casual observer it would appear that two or three autorickshaws are engaging in a line-abreast formation; but in all probability, something more subtle is under way. What&#8217;s really happening is that one of the autorickshaws is running just a little bit faster than the one alongside it (any non-zero <img src="http://ashutoshmehra.net/blog/wp-content/plugins/easy-latex/cache/tex_264c27cddc8e1cffd6e8ccb80f01011c.png" title="\delta" style="vertical-align:-20%;" class="tex" alt="\delta" />, no matter how small, would be sufficient for our purpose); and the <img src="http://ashutoshmehra.net/blog/wp-content/plugins/easy-latex/cache/tex_264c27cddc8e1cffd6e8ccb80f01011c.png" title="\delta" style="vertical-align:-20%;" class="tex" alt="\delta" />-faster autorickshaw is doing the only reasonable thing to under such circumstances &#8212; overtake the slower one. The phenomenon usually lasts for a good one-two minutes before the &#8220;formation&#8221; is broken.</p>
]]></content:encoded>
			<wfw:commentRss>http://ashutoshmehra.net/blog/2008/12/autorickshaw-phenomena/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
