<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My cognition of things around me! &#187; language</title>
	<atom:link href="http://nithinpb.wordpress.com/tag/language/feed/" rel="self" type="application/rss+xml" />
	<link>http://nithinpb.wordpress.com</link>
	<description>Log of what I can blog about</description>
	<lastBuildDate>Sat, 26 Dec 2009 11:02:46 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='nithinpb.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/35ead5f8bd3adcbb50e22265a14d5245?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>My cognition of things around me! &#187; language</title>
		<link>http://nithinpb.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://nithinpb.wordpress.com/osd.xml" title="My cognition of things around me!" />
		<item>
		<title>Strawman functions in C++ Templates &amp; Meta Programming.</title>
		<link>http://nithinpb.wordpress.com/2009/04/13/strawman-functions-in-c-templates-meta-programming/</link>
		<comments>http://nithinpb.wordpress.com/2009/04/13/strawman-functions-in-c-templates-meta-programming/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 15:40:07 +0000</pubDate>
		<dc:creator>Nithin</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Bangalore]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[STL]]></category>
		<category><![CDATA[strawman]]></category>
		<category><![CDATA[strawman functions]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[Vijayan]]></category>

		<guid isPermaLink="false">http://nithinpb.wordpress.com/?p=194</guid>
		<description><![CDATA[C++, Vijayan way of coding<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nithinpb.wordpress.com&blog=948571&post=194&subd=nithinpb&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I got a very unique opportunity to hear to Dr. Vijayan here in Bangalore. He was training us on Advanced C++ and the 1st session exceeded all my expectation. We discussed Templates for the whole day today. After listening to him for 8 hours straight, I can tell you that he was not done with Templates. I won&#8217;t be shocked if he picks up this topic again tomorrow.</p>
<p>To summarize briefly what I learnt today, we started the discussion with need for Templates in C++, Java and such statically typed languages in comparison with dynamic languages such as Python. Some of the points worth noting for me were,</p>
<p>( I will try to elaborate on these points later)</p>
<ol>
<li><strong>sizeof </strong>is a compile time operation in C++. Hence, sizeof() ends up making C++ Templates very powerful.</li>
<li>Specialization is preferred over generalization in templates. In particular, compiler preference goes with the extent of specialization.</li>
<li>Objects, which are synonymous with variabled are runtime entities and types are compile time entities. Types include User defined types (Classes, C++ Structures), Plain Object Types such as C structures, Built-in types such as int, char etc.</li>
<li>Unless a variable appears in the argument of a template function, it will not be &#8220;deduced&#8221; by default by the compiler.</li>
<li>Default parameters are allowed only for Class Templates and not allowed for Function templates as of C++98.</li>
<li>Only restriction for Template Member is that it cannot be a virtual Function. This is because there is no way that the compiler can deduce the number of translation units for a particular Template&lt; T &gt;. Number of translations of template T will be decided on runtime based on the types defined.</li>
<li>Templates runs through the code only to the extent to which it is required.</li>
</ol>
<p>While discussing a compile time implementation of one of the runtime operation, we discussed <a href="http://en.wikipedia.org/wiki/Metaprogramming" target="_blank">Meta Programming</a>. In this, we needed to make a decision such as,</p>
<p>if ( 1 )</p>
<p>// do something</p>
<p>else</p>
<p>//do something else for value 0</p>
<p>during compile time. We cannot use if &#8211; else statements as they are runtime operations. In such a scenario, where we need to make a decision between two alternatives during compile time, we can use strawman functions with <strong>sizeof</strong> operator such that these strawman functions return different &#8220;return type&#8221; for different alternatives (May be, char for 0 and int for 1) and then, based on these &#8220;return types&#8221; we can use templates to run the code.</p>
<p>I know I am confusing you so stay with me. Consider a piece of code.</p>
<p>Code 1:</p>
<p>int i = 99;</p>
<p>sizeof(++i);   //sizeof will report the size to be 2 bytes or 4 bytes based on the implementation but what would the value of i be, after the execution of this line?</p>
<p>It will remain to be 99 as ++i will not be computed. Since, <strong>sizeof </strong>is a compile time operation and ++i is a runtime operation, ++i will not be evaluated except that &#8220;++i&#8221;s data type will be found out, which is &#8216;int&#8217; in this case.</p>
<p>This means, we can write any function with any code in it and all <strong>sizeof </strong>cares about is the return type. You can officially write that poem you wanted to write in your C++ code without any &#8216;<strong>;</strong>&#8216; (semi-colon) or declaring it as a string. This function, when declared in <strong>sizeof</strong>( //here// ), will not be executed as the execution of a function will be a runtime operation.</p>
<blockquote><p>Such a function whose code will not be executed but whose return type is used to determine the type (data type) during compile time is called a <strong>Strawman </strong>function.</p></blockquote>
<p>Code 2:</p>
<p>Consider two overloaded functions,</p>
<ul>
<li>template &lt;&gt; strawmanFunction &lt;char&gt;  ()  { returns char corresponding to 0 }</li>
<li>template &lt;&gt; strawmannFunction &lt;int&gt; ()  { returns int corresponding to 1}</li>
</ul>
<p>We can now safely use, sizeof ( strawmannFunction ) to determine the values between 0 and 1, based on the specialization of int and char.</p>
<p>If this is still confusing apologies for poor narration. Lastly, Try implementing <strong>factorial </strong>code calculation suring compile time. Usual runtime code would be something like,</p>
<p>Code 3:</p>
<p>int factorial (n ) {</p>
<p>if (n == 1 ) return 1;</p>
<p>return n * factorial (n &#8211; 1) ;</p>
<p>}</p>
<p>When you implement the same logic with templates, you can have the factorial of the number during compile-time itself. It&#8217;s like having a constant which is pre-compiled before even you run your code!</p>
<p>Code 4:</p>
<p>template &lt; typename T &gt; T factorial ( T n ) { return n * factorial ( n &#8211; 1 ); }</p>
<p>Now, this code will instantiate translations for n &#8211; 1 for n. But this will not end with 1 and hence, it will result in <strong>Infinite Loop</strong>. So how do we implement if statement in Templates such that it runs in compile-time? (Remember, if-else is a runtime thing!) Look at the point number 2 above. Specialization is preferred over Generalization. Hence, if we can implement a<strong> Specialized case</strong> for 1 in the above Template definition, we are through. So, here it is.</p>
<p>Code 5:</p>
<p>template &lt; typename T &gt; T factorial&lt;1&gt; ( T n ) { return 1; } // This will be preferred over Code 4. The instantiation of different translations of Template T will end with this code.</p>
<p>Templates were fun. Although, I did realise today that the word easy is very relative. Whenever Mr.Vijayan said easy it took me 10 minutes to understand what&#8217;s going on.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nithinpb.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nithinpb.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nithinpb.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nithinpb.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nithinpb.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nithinpb.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nithinpb.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nithinpb.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nithinpb.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nithinpb.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nithinpb.wordpress.com&blog=948571&post=194&subd=nithinpb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nithinpb.wordpress.com/2009/04/13/strawman-functions-in-c-templates-meta-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7bfe192352229aacb8ad77c45e4af66f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">nythyn</media:title>
		</media:content>
	</item>
		<item>
		<title>ನಮಸ್ಕಾರ. Language barrier and World Wide Web.</title>
		<link>http://nithinpb.wordpress.com/2009/04/12/%e0%b2%a8%e0%b2%ae%e0%b2%b8%e0%b3%8d%e0%b2%95%e0%b2%be%e0%b2%b0-language-barrier-and-world-wide-web/</link>
		<comments>http://nithinpb.wordpress.com/2009/04/12/%e0%b2%a8%e0%b2%ae%e0%b2%b8%e0%b3%8d%e0%b2%95%e0%b2%be%e0%b2%b0-language-barrier-and-world-wide-web/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 11:59:46 +0000</pubDate>
		<dc:creator>Nithin</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Kannada]]></category>
		<category><![CDATA[Softwares]]></category>
		<category><![CDATA[barrier]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[India]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[lipikaar]]></category>
		<category><![CDATA[quillpad]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://nithinpb.wordpress.com/?p=186</guid>
		<description><![CDATA[I am a proud Kannadiga (ಕನ್ನಡಿಗ), not Kannadi or Kannadis as some &#8220;immigrants&#8221; in Bangalore call Kannada speaking people; It&#8217;s Kannadiga. I like the fact that I can use the facilities on Internet such as WordPress, Twitter etc for blogging and micro blogging and facebook, slashdot, lifehacker for information etc. With the population of over [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nithinpb.wordpress.com&blog=948571&post=186&subd=nithinpb&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I am a proud Kannadiga (ಕನ್ನಡಿಗ), not Kannadi or Kannadis as some &#8220;immigrants&#8221; in Bangalore call Kannada speaking people; It&#8217;s Kannadiga. I like the fact that I can use the facilities on Internet such as WordPress, Twitter etc for blogging and micro blogging and facebook, slashdot, lifehacker for information etc. With the population of over 1 Billion, India has just about &lt; 10% (A total irrational guess, it could very well be 9.6305%) Internet users. While the cost to own a Computer or get an Internet connection are a little high for the common man, language barrier according to me is the biggest reason. I cannot expect my mom or my pa to blog on net in Kannada when s/he doesn&#8217;t know how to type in Kannada with an English keyboard. I have been using these blogging services for so many days but I never figured out an obvious way to blog in Kannada.</p>
<p>Recently, a couple of days ago, I came across this site called <a href="http://quillpad.in/" target="_blank">Quillpad</a>. They have an easy way of typing Indian languages in english. What I like the most about this particular site is that it is very intutive unlike Gmail. Gmail&#8217;s Indian language feature, which can be enabled in the Settings -&gt; Labs, in comparision with Quillpad looks very raw to me. Installing Baraha or other desktop softwares and then, typing over wordpress or other applications such as MS Word is the existing way of typing Indian languages.</p>
<p>A simple Google search pointed me to an other website called <a href="http://www.lipikaar.com/">Lipikaar</a>. <span style="text-decoration:line-through;">They too have a similar portal but Lipikaar is far behind Quillpad in it&#8217;s technology</span>. <span style="color:#ff0000;">It was my mistake that concluded little too early</span>. They do not use transliteration and hence, it turned out be faster to type in Lipikaar. <span style="text-decoration:line-through;">A simple experiment of typing &#8220;namaskaara&#8221; gives the following results of Lipikaar (ನಾಮಾಸಕಅರಾ). I tried many times but I still couldn&#8217;t figure out the way to type namaskaara, which by the way on Quillpad results in this (ನಮಸ್ಕಾರ)</span>.  I should have tried nmsxkar on Lipikaar while I tried the Baraha way of typing, which worked well on Quillpad. While I would love to use Lipikaar considering the fact that they already have a firefox plugin, it gives me a feeling like I&#8217;m using Dvorak keyboard &#8211; Very good but different &#8211; against Qwerty, as I am so used to typing with Baraha.</p>
<p>Indian languages on internet is still a long way to go. We need to get Indians educated to use internet. This is a very precise market and a very untouched market. This to me is like the famous  Nike story where a salesman from Nike went to Africa in 1950s to sell their shoes. A market like Indic Languages on Net will still take a long time to catch up but once it does,  it will get saturated very soon with a very few players. A few things Quillpad should do if they already haven&#8217;t thought of it,</p>
<ul>
<li>Easier shortcuts to switch to english. (Something like Ctrl+B for Bold). They can use Ctrl+Q.</li>
<li>Dictionary support for English to native languages and native languages to English  (I know what is Heerekai in Kannada but I didn&#8217;t know what is it called in English. Similarly, I don&#8217;t know what&#8217;s Cricket called in Kannada)</li>
<li>API their Engine. (Charge for the engine or give it for free for other monetary benifits. Upto them!). Why? Twitter hasn&#8217;t caught up like a flame because of the bird or it&#8217;s color. There are more than 800 Twitter and Twitter specific clients. Quillpad needs to jump into the bandwagon and make the most of it. Providing APIs and a few clients in open would invite a huge flock of users to use Quillpad and its services.</li>
<li>Firefox / IE / Safari / Opera / Chrome plugins. What if Gmail has a language tool in it&#8217;s mail compose? It sucks. If quillpad can provide me an alternative, they are in. Getting into the browser is the new way of getting into people&#8217;s houses. It&#8217;s the new way of taking control of PCs.</li>
<li>iPhone app won&#8217;t be too <strong>early</strong> either considering Quillpad itself is a little too early.</li>
</ul>
<p>Communicating with Web developers for web based projects will pile in a bunch of ideas for any organization. Like Guy (Kawasaki) says, a lot of startups fail in a couple of years because they haven&#8217;t been touching base with their end users. I wish Quillpad &amp; Lipikaar, all the best.</p>
<p>I really appreciate the efforts put into these products and the fact that they are open to public.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nithinpb.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nithinpb.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nithinpb.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nithinpb.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nithinpb.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nithinpb.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nithinpb.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nithinpb.wordpress.com/186/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nithinpb.wordpress.com/186/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nithinpb.wordpress.com/186/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nithinpb.wordpress.com&blog=948571&post=186&subd=nithinpb&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nithinpb.wordpress.com/2009/04/12/%e0%b2%a8%e0%b2%ae%e0%b2%b8%e0%b3%8d%e0%b2%95%e0%b2%be%e0%b2%b0-language-barrier-and-world-wide-web/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7bfe192352229aacb8ad77c45e4af66f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">nythyn</media:title>
		</media:content>
	</item>
	</channel>
</rss>