<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.developerdotstar.com/community" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>developer.* Blogs - Request to my readership for clarification concerning C# - Comments</title>
 <link>http://www.developerdotstar.com/community/node/129</link>
 <description>Comments for &quot;Request to my readership for clarification concerning C#&quot;</description>
 <language>en</language>
<item>
 <title>strcspn redux</title>
 <link>http://www.developerdotstar.com/community/node/129#comment-219</link>
 <description>&lt;p&gt;I will ask Eric. &lt;/p&gt;
&lt;p&gt;But you confirm my point.&lt;/p&gt;
&lt;p&gt;I don&#039;t think its possible for a language designer to claim (by implementing strspn and not its mathematical inverse) that he has any knowledge of what programmers need, for the very good reason that he is both sensing and creating needs.&lt;/p&gt;
&lt;p&gt;It is in fact common to want to find the first non-letter, the first non-digit, etcetera and even in the era of Unicode, the boundaries of the universal character set are known. &lt;/p&gt;
&lt;p&gt;The practical problem, I think the C# designers faced, is that as opposed to ASCII, it is not simple and efficient to represent character set complements by means of a string.&lt;/p&gt;
&lt;p&gt;However, I maintain that mathematics is probably the only universal grammar in the pragmatic sense. In a given culture, a programmer may more naturally think in terms of searching for &quot;anything except a favored set of characters&quot;.&lt;/p&gt;
&lt;p&gt;Furthermore, providing only strspn will bias the code, of lazy coders, into providing false representations of inverse sets as strings of characters, easily available on their keyboards.&lt;/p&gt;
</description>
 <pubDate>Tue, 22 Feb 2005 17:27:57 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 219 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>strcspn</title>
 <link>http://www.developerdotstar.com/community/node/129#comment-218</link>
 <description>&lt;p&gt;After reading your last couple comments, I thought for sure I had missed something in your original post. So then I went back and read it again. Then I went and Googled the function you refer to (strcspn) and got this definition:&lt;/p&gt;
&lt;p&gt;[quote]The strcspn() function computes the length of the maximum initial segment of the string pointed to by s1 that consists entirely of characters that are not in the string pointed to by s2.[/quote]&lt;/p&gt;
&lt;p&gt;So the way I understand this, in usage it would look something like this (excuse the C# pseudo-code):&lt;/p&gt;
&lt;div class=&quot;codeblock&quot;&gt;
&lt;pre&gt;string _s1 = &amp;quot;Enter the 49 gates of uncleanliness!&amp;quot;;&lt;br /&gt;string _s2 = &amp;quot;Xpg2!@l&amp;quot;;&lt;br /&gt;int _iLength = String.strcspn(_s1, s2);&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The result of _iLength would then be 13, correct? That&#039;s the length of the initial segment in _s1 before any character in _s2 (in this case &quot;g&quot;) is encountered. And you are right that there is no corollary in C# for this (though I can&#039;t speak to whether or not it&#039;s included in the 2.0 Framework). This is a little bit different than my original understanding of what you were describing, but I&#039;ll not muddy the waters by going into that.&lt;/p&gt;
&lt;p&gt;Suffice it to say, I stand by my original post in that I&#039;ve never had the pleasure to encounter a situation where I&#039;ve needed something like this though I&#039;ll concede its use as plausible. However the way to do it in C# would be to write a function yourself to parse _s1 into an array of type char and loop through each character until you found a match...or not...which could be a total pain if the string you&#039;re scanning is on the order of, say, Moby Dick.&lt;/p&gt;
&lt;p&gt;Dunno, there may be a more elegant approach but I&#039;d have to think on it. I wouldn&#039;t consider this omission justification for labelling C# as &quot;flawed&quot; though. You should pose your question to Eric Gunnerson and see if he can speak to it.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://blogs.msdn.com/ericgu&quot; title=&quot;http://blogs.msdn.com/ericgu&quot;&gt;http://blogs.msdn.com/ericgu&lt;/a&gt;&lt;/p&gt;
</description>
 <pubDate>Mon, 21 Feb 2005 18:20:58 -0800</pubDate>
 <dc:creator>trevor.conn</dc:creator>
 <guid isPermaLink="false">comment 218 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Orthogonality</title>
 <link>http://www.developerdotstar.com/community/node/129#comment-217</link>
 <description>&lt;p&gt;In general, if you provide function a, and it is easy to provide its inverse, then you should as a general, local praxis independent way of delivering true &quot;clarity&quot;.&lt;/p&gt;
&lt;p&gt;It is impossible to so write a document that all ordinary people world wide can understand it in their local patois: this is trivially, true.&lt;/p&gt;
&lt;p&gt;&quot;Understandability&quot; of code and ordinary text is an easily corruptible predicate which in Visual Basic praxis is used to excuse all sorts of bugs, potential bugs, and ugliness because &quot;understandability&quot; is interpreted introspectively as &quot;I understand what I code&quot;.&lt;/p&gt;
&lt;p&gt;It should be replaced by universality as seen in the writings of Stroustrup which MEANS that today, the 1970s discourse of &quot;understandability&quot; needs to be globalized.&lt;/p&gt;
&lt;p&gt;In the 1970s, a common accusation was &quot;dis code is written in Sanskrit&quot;. &quot;Dis code is a Chinese Fire Drill&quot;.&lt;/p&gt;
&lt;p&gt;Today, my homeys on the job in China at best only appreciate the image of coordinated mass energy constituted in the phrase &quot;Chinese Fire Drill&quot;, and I ran the Shenzhen Fun Run last October. It was a Chinese Fire Drill only in the sense that out of a number of runners (at least 10000!) that would have created chaos in America, and out of what appeared to be in fact Chaos, a 10K run emerged with a great deal of order...in part because they gave everybody the same running attire.&lt;/p&gt;
&lt;p&gt;Therefore, in search of that understandability constituted in universality, &quot;orthogonality&quot; is for me an important guide. I cannot be certain that the VB trained reader will initially see the need for the notion of &quot;scanning, for any one of a set of characters&quot; when VB has traditionally only provided the notion only of &quot;scanning, for a string&quot;...which is completely different.&lt;/p&gt;
&lt;p&gt;But once I see the need for the positive scan, the relative ease of the inverse scan almost forces its implementation, based not on localized cultural considerations but metaphorically by the very idea that if I can get from A to B I should be able to make the reverse journey.&lt;/p&gt;
</description>
 <pubDate>Mon, 21 Feb 2005 14:22:52 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 217 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Reply to the Orthogon and also to Mac MacGrogan</title>
 <link>http://www.developerdotstar.com/community/node/129#comment-216</link>
 <description>&lt;p&gt;Orthogon-man, you need the complement of the set when the clearest way of expressing your purpose is &quot;I needs to get to to the end of a string of characters consisting of characters from a small set of characters&quot;. In my experience, this type of left-to-right moseying occurs all the time in programming.&lt;/p&gt;
&lt;p&gt;[To Mosey is to advance, after the great Union General Cyrus Washington Booker Mosey who at the Battle of Quaker Meeting said to his troops, &quot;men, let us Mosey forth without fear and meet the Rebs. On, Wisconsin! Union or Death!&quot;]&lt;/p&gt;
&lt;p&gt;Let&#039;s be serious. I am concerned with programming what I mean.&lt;/p&gt;
&lt;p&gt;Mac: my experience is that understandability, as a psychological predicate having to do with the phenomenology of code, cannot be treated as a strictly technical issue.&lt;/p&gt;
&lt;p&gt;Wow, wash my mouth out with soap after that one.&lt;/p&gt;
&lt;p&gt;What I mean is that understandibility, in an irreducible way, depends on reader response. &lt;/p&gt;
&lt;p&gt;A mathematically oriented programmer will be delighted to see an expression in a for loop. A non-mathematical programmer will prefer to see that expression broken down.&lt;/p&gt;
&lt;p&gt;Since I think programming is mathematical my tendency will be to place the expression in the For loop in VB and in Java, and, in languages of the C and Java family, simply avoid modifying any variable in the for terminus.&lt;/p&gt;
&lt;p&gt;This is a normative style but in fact many programmers use it. They code what they think their readers SHOULD understand. If it so happens they share cultural background with their mates, then their code is celebrated by the lads as good code. But if their code seems, to the homes, as in any way fancy-schmancy and reflective of a foreign and estranged practice, then the coder is regarded at best as a sacred monster.&lt;/p&gt;
&lt;p&gt;At worst, the brutal demotic enforcement of &quot;proper&quot; speech enters the code review, which becomes a sort of flaying of Marysas based not on &quot;objective&quot; criteria but on local power structures.&lt;/p&gt;
&lt;p&gt;Practices, which make life easier for the lads, are normed in an absolute sense. The question is whether life should be made easier for the lads as a general rule.&lt;/p&gt;
&lt;p&gt;But best practice in Java-like languages is probably to precalculate the expression and even declare it, where possible as const and therefore read-only.&lt;/p&gt;
&lt;p&gt;Basically, I think humanity needs a Character Set Object capable of representing, independent of any one standard, a set of integer values which represents a character set.&lt;/p&gt;
</description>
 <pubDate>Mon, 21 Feb 2005 14:11:01 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">comment 216 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Inefficency and Computer Language</title>
 <link>http://www.developerdotstar.com/community/node/129#comment-215</link>
 <description>&lt;p&gt;I&#039;m with Edward in the importance of trying out new languages in life and in software (if there&#039;s really a difference). And I&#039;ve also tried out my microscopic Chinese vocabulary on cab drivers. I once repeated the Chinese word for &quot;train station&quot; (it&#039;s really a mouthful) five or six times to an incomprehending cabbie outside of Taipei. Finally I just said &quot;train station&quot; in English. He understood right away and laughed and laughed (though the Chinese are supposed to be soooo polite) at my silly way of saying the word in his language.&lt;/p&gt;
&lt;p&gt;When in comes to software development languages, I&#039;m not sure exactly how necessary the sort of deep understand one would require to know off-hand whether variables are passed by-value or by-reference into a for loop really is. In the case of VB, the by-val approach is more forgiving, and many developers in Java have to learn the hard way that if a variable evaluated in the for clause is modified in the loop, craziness can result.&lt;/p&gt;
&lt;p&gt;Well, obviously it&#039;s important, then, but I think less important than being aware of the finer points of a particular language is being aware of the finer points of writing good code, and these finer points are universal.&lt;/p&gt;
&lt;p&gt;I&#039;m not going to look up the exact references, but Steve McConnell, in &lt;i&gt;Code Complete&lt;/i&gt;, regularly disdains placing an emphasis on efficiency over clarity. In the for loop example cited by Edward&#039;s student as inefficient, even if he had been right on the facts he would have been wrong on the importance of the fact. Today&#039;s computers  are (and have been for many years) so fast that an inefficiency like this would have to be a part of a very very big loop (on the order of millions or even billions of iterations) for there to be any noticable delay.&lt;/p&gt;
&lt;p&gt;The real issue is the clarity of the expression &quot;intEnd - 1&quot;. Now, whether this is the clearest way of expressing this value in the method in question, I have no idea. But that&#039;s the point that we, as developers, need to focus on. &lt;/p&gt;
&lt;p&gt;If efficiency were the only factor at play, we&#039;d never create objects or perform method calls. More efficient to just copy all of the code into one super method. In fact, we might have to write all of our code as memory pointers expressed as 1s and 0s.&lt;/p&gt;
</description>
 <pubDate>Mon, 21 Feb 2005 13:51:39 -0800</pubDate>
 <dc:creator>Rob MacGrogan</dc:creator>
 <guid isPermaLink="false">comment 215 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Enter the Orthogon</title>
 <link>http://www.developerdotstar.com/community/node/129#comment-212</link>
 <description>&lt;p&gt;Well, to be frank I understand the functionality you say is lacking, and it sounds cool. But I can&#039;t think of any situation I have ever encountered (or possibly will ever) where I&#039;d need something like that. Can&#039;t say I really miss it. Give a concise example of how you&#039;ve used it and the effect C#&#039;s exclusion of said feature affects your acceptance or lack thereof.&lt;/p&gt;
</description>
 <pubDate>Sun, 20 Feb 2005 17:50:28 -0800</pubDate>
 <dc:creator>trevor.conn</dc:creator>
 <guid isPermaLink="false">comment 212 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Request to my readership for clarification concerning C#</title>
 <link>http://www.developerdotstar.com/community/node/129</link>
 <description>&lt;p&gt;OK, I can see why the designers of C# did not implement the preprocessor of C++ and C. It creates obfuscated code, and its functionality, as I learned several years ago from Number One Son, its functionality is largely replaced by objects.&lt;/p&gt;
&lt;p&gt;For me, furthermore, it doesn&#039;t go far enough. This is because the preprocessor of PL/I was Turing complete in that you could create loops in the preprocessor and, from a logical standpoint, the preprocessor was a full &quot;computer&quot;, allowing you to ship seriously customizable (and, seriously obfuscated) solutions.&lt;/p&gt;
&lt;p&gt;But I find the string model of C# supports the concept of &quot;scan for any one of a SET of characters&quot; that is found in C strspn, but FAILS to support (as far as I can determine) the concept of &quot;scan for any one of the COMPLEMENT of a SET of characters&quot; as seen in strcspn.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.developerdotstar.com/community/node/129&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.developerdotstar.com/community/node/129#comment</comments>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/21">C#</category>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/17">C++</category>
 <pubDate>Sat, 19 Feb 2005 14:48:22 -0800</pubDate>
 <dc:creator>Edward G Nilges</dc:creator>
 <guid isPermaLink="false">129 at http://www.developerdotstar.com/community</guid>
</item>
</channel>
</rss>
