<?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>çetin's blog</title>
	<atom:link href="http://www.cetinkoca.com/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cetinkoca.com/blog</link>
	<description>pronounced as chat-in ;)</description>
	<lastBuildDate>Sat, 19 Feb 2011 18:08:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Nature by Numbers</title>
		<link>http://www.cetinkoca.com/blog/index.php/2011/02/nature-by-numbers/</link>
		<comments>http://www.cetinkoca.com/blog/index.php/2011/02/nature-by-numbers/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 16:44:53 +0000</pubDate>
		<dc:creator>çetin</dc:creator>
				<category><![CDATA[Entertaining]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[nature]]></category>

		<guid isPermaLink="false">http://www.cetinkoca.com/blog/?p=117</guid>
		<description><![CDATA[I just came across this short movie by Cristóbal Vila. It presents an attempt to show how nature and math are related in an artistic and beautiful manner. You can see familiar stuff like Fibonacci series, golden ratio, Delaunay triangulation, Voronoi diagrams in it. It has great visuals as well as a great choice of [...]]]></description>
			<content:encoded><![CDATA[<p>I just came across this short movie by Cristóbal Vila. It presents an attempt to show how nature and math are related in an artistic and beautiful manner. You can see familiar stuff like Fibonacci series, golden ratio, Delaunay triangulation, Voronoi diagrams in it. It has great visuals as well as a great choice of music. I simply loved this video and I cannot give enough credit to it!</p>
<script type='text/javascript'>  
window.onload = document.write("<iframe width='600' height='366' marginwidth='0' marginheight='0' scrolling='auto' frameborder='0'  src='http://www.youtube.com/embed/kkGeOWYOFoA?rel=0&amp;amp;hd=1' ></iframe> "); 
 </script>
]]></content:encoded>
			<wfw:commentRss>http://www.cetinkoca.com/blog/index.php/2011/02/nature-by-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Null Encryption</title>
		<link>http://www.cetinkoca.com/blog/index.php/2011/01/null-encryption/</link>
		<comments>http://www.cetinkoca.com/blog/index.php/2011/01/null-encryption/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 17:11:27 +0000</pubDate>
		<dc:creator>çetin</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[IPsec]]></category>
		<category><![CDATA[RFC]]></category>

		<guid isPermaLink="false">http://www.cetinkoca.com/blog/?p=106</guid>
		<description><![CDATA[There is a Null Encryption Algorithm supported by the IPsec, which you can use to encrypt IPsec packets, and I had a lot of fun reading its RFC yesterday. As you may have already guessed from its name, what it does is nothing. If you wonder how someone could have written a document of 1400+ [...]]]></description>
			<content:encoded><![CDATA[<p>There is a <em>Null Encryption Algorithm</em> supported by the IPsec, which you can use to encrypt IPsec packets, and I had a lot of fun reading its RFC yesterday. As you may have already guessed from its name, what it does is nothing. If you wonder how someone could have written a document of 1400+ words specifying something that literally does nothing then I suggest that you read <a href="http://www.faqs.org/rfcs/rfc2410.html">RFC 2410</a>.<span id="more-106"></span> Here are some bits and pieces from the document:</p>
<blockquote><p>NULL is a block cipher the origins of which appear to be lost in antiquity.  Despite rumors that the National Security Agency suppressed publication of this algorithm, there is no evidence of such action on their part. Rather, recent archaeological evidence suggests that the NULL algorithm was developed in Roman times, as an exportable alternative to Ceaser ciphers. However, because Roman numerals lack a symbol for zero, written records of the algorithm&#8217;s development were lost to historians for over two millennia.</p></blockquote>
<blockquote><p>Like other modern ciphers, e.g., RC5 [RFC-2040], the NULL encryption algorithm can make use of keys of varying lengths.  However, no measurable increase in security is afforded by the use of longer key lengths.</p></blockquote>
<blockquote><p>The NULL encryption algorithm combines many of the best features of both block and stream ciphers, while still not requiring the transmission of an IV or analogous cryptographic synchronization data.</p></blockquote>
<blockquote><p>The NULL encryption algorithm is significantly faster than other commonly used symmetric encryption algorithms and implementations of the base algorithm are available for all commonly used hardware and OS platforms.</p></blockquote>
<blockquote><p>The following is a set of test vectors to facilitate in the development of interoperable NULL implementations.</p></blockquote>
<pre>test_case =      1
data =           0x123456789abcdef
data_len =       8
NULL_data =      0x123456789abcdef

test_case =      2
data =           "Network Security People Have A Strange Sense Of Humor"
data_len =       53
NULL_data =      "Network Security People Have A Strange Sense Of Humor"</pre>
<blockquote><p>For purposes of IKE [IKE] key extraction, the key size for this algorithm MUST be zero (0) bits, to facilitate interoperability and to avoid any potential export control problems.</p></blockquote>
<blockquote><p>At the time of this writing there are no known laws preventing the exportation of NULL with a zero (0) bit key length.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.cetinkoca.com/blog/index.php/2011/01/null-encryption/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EvilInput(TM)</title>
		<link>http://www.cetinkoca.com/blog/index.php/2009/04/evilinputtm/</link>
		<comments>http://www.cetinkoca.com/blog/index.php/2009/04/evilinputtm/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 19:28:50 +0000</pubDate>
		<dc:creator>çetin</dc:creator>
				<category><![CDATA[Technical Articles]]></category>
		<category><![CDATA[DirectInput]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://www.cetinkoca.com/blog/?p=93</guid>
		<description><![CDATA[DirectInput has been one of the commonly used components of game engines, especially the ones developed by hobbyists which easily cloaks the fact that it&#8217;s actually quite deprecated. I believe that the reason DirectInput is so commonly used is not its ease of use. It is rather the amount of tutorials available on the Internet [...]]]></description>
			<content:encoded><![CDATA[<p>DirectInput has been one of the commonly used components of game engines, especially the ones developed by hobbyists which easily cloaks the fact that it&#8217;s actually quite deprecated.<span id="more-93"></span></p>
<p>I believe that the reason DirectInput is so commonly used is not its ease of use. It is rather the amount of tutorials available on the Internet and also the amount of ready-to-use code written on top of DirectInput.</p>
<p>It has quite a bit of evil running under the hood, though. First of all, DirectInput creates a second thread to read data from input devices and process it. Having a separate thread for input processing running in the background may not be significant, which is relative to the application. It nevertheless has an unnecessary overhead. Another important point is that DirectInput is low level. But we want low level stuff when developing 3D applications, right? That&#8217;s not always true. DirectInput, for example, lacks the following features because it is such a low level API:</p>
<ul>
<li>It does not apply pointer ballistics (i.e. pointer acceleration)</li>
<li>It does not process shifted input, such that you need to process input like &#8220;&lt;shift&gt; + a&#8221; so that it is interpreted as &#8220;A&#8221;.</li>
<li>It does not detect the state of caps lock but only detects whether caps lock key was pressed.</li>
<li>It cannot give you the absolute coordinates of the cursor. Instead you get a bunch of delta coordinates and have to process these along with the initial coordinates to compute the absolute coordinates at a given time.</li>
<li>It does not support key maps other than US English.</li>
</ul>
<p>Some of the issues mentioned above may not sound as serious to you but they are indeed DirectInput issues. All of the features mentioned above are available when you handle standard Win32 input messages. The reason DirectInput doesn&#8217;t have these is because they are processed by the operating system at a higher-level layer than that of DirectInput. If you would like to spend time and implement such stuff in your application be my guest! Yeah, I didn&#8217;t think so either. I don&#8217;t even mention that using DirectInput usually requires considerably more code to get things working because of the low-level stuff.</p>
<p>Even <a href="http://msdn.microsoft.com/en-us/library/bb206183.aspx" target="_blank">Microsoft</a> states that DirectInput offers no advantages whatsoever in the general case and its use should be avoided:</p>
<blockquote><p>Overall, using DirectInput offers no advantages when reading data from mouse or keyboard devices, and the use of DirectInput in these scenarios is discouraged.</p></blockquote>
<p>I confess that I have been using an input system based on DirectInput for years, mainly because of the aforementioned reasons, that is the availability of tutorials and code around. I actually implemented it like 5 years ago and did not want to spend time on reimplementing it without DirectInput, until now. I think I&#8217;ll do it sometime soon.</p>
<p>To sum up, try to stay away from DirectInput unless you need exotic features like force feedback or you absolutely need to support special DirectInput hardware. It probably won&#8217;t kill your application but what doesn&#8217;t kill your application may not turn out to make it stronger.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cetinkoca.com/blog/index.php/2009/04/evilinputtm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular Mess</title>
		<link>http://www.cetinkoca.com/blog/index.php/2009/03/regular-mess/</link>
		<comments>http://www.cetinkoca.com/blog/index.php/2009/03/regular-mess/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 22:51:26 +0000</pubDate>
		<dc:creator>çetin</dc:creator>
				<category><![CDATA[Bits & Pieces]]></category>
		<category><![CDATA[Funny]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Regular expressions]]></category>
		<category><![CDATA[RFC 822]]></category>

		<guid isPermaLink="false">http://www.cetinkoca.com/blog/?p=78</guid>
		<description><![CDATA[Regular expressions can actually be quite messy. Don&#8217;t you think so? Well, think not before you see this&#8230; Below is a regular expression used to validate email addresses according to the RFC 822 grammar. I just encountered this while browsing web today. Seriously, what the hell? (?:(?:\r\n)?[ \t])*(?:(?:(?:[^()&#60;&#62;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t] )+&#124;\Z&#124;(?=[\["()&#60;&#62;@,;:\\".\[\]]))&#124;"(?:[^\"\r\\]&#124;\\.&#124;(?:(?:\r\n)?[ \t]))*"(?:(?: \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&#60;&#62;@,;:\\".\[\] [...]]]></description>
			<content:encoded><![CDATA[<p>Regular expressions can actually be quite messy. Don&#8217;t you think so? Well, think not before you see this&#8230;<span id="more-78"></span></p>
<p>Below is a <a href="http://ex-parrot.com/~pdw/Mail-RFC822-Address.html" target="_blank">regular expression</a> used to validate email addresses according to the <a href="http://www.ietf.org/rfc/rfc0822.txt?number=822" target="_blank">RFC 822</a> grammar. I just encountered this while browsing web today. Seriously, what the hell?</p>
<blockquote><p><code>(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]<br />
)+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:<br />
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(<br />
?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[<br />
\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\0<br />
31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\<br />
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+<br />
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:<br />
(?:\r\n)?[ \t])*))*|(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z<br />
|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)<br />
?[ \t])*)*\&lt;(?:(?:\r\n)?[ \t])*(?:@(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\<br />
r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[<br />
\t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)<br />
?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t]<br />
)*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[<br />
\t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*<br />
)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]<br />
)+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)<br />
*:(?:(?:\r\n)?[ \t])*)?(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+<br />
|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r<br />
\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:<br />
\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t<br />
]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031<br />
]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](<br />
?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?<br />
:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?<br />
:\r\n)?[ \t])*))*\&gt;(?:(?:\r\n)?[ \t])*)|(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?<br />
:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?<br />
[ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()&lt;&gt;@,;:\\".\[\]<br />
\000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|<br />
\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;<br />
@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"<br />
(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t]<br />
)*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\<br />
".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?<br />
:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[<br />
\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()&lt;&gt;@,;:\\".\[\] \000-<br />
\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(<br />
?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\&lt;(?:(?:\r\n)?[ \t])*(?:@(?:[^()&lt;&gt;@,;<br />
:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([<br />
^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\"<br />
.\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\<br />
]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\<br />
[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\<br />
r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\]<br />
\000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]<br />
|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()&lt;&gt;@,;:\\".\[\] \0<br />
00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\<br />
.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,<br />
;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|"(?<br />
:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*<br />
(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".<br />
\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[<br />
^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]<br />
]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\&gt;(?:(?:\r\n)?[ \t])*)(?:,\s*(<br />
?:(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\<br />
".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(<br />
?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[<br />
\["()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t<br />
])*))*@(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t<br />
])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?<br />
:\.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|<br />
\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:<br />
[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\<br />
]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\&lt;(?:(?:\r\n)<br />
?[ \t])*(?:@(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["<br />
()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)<br />
?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;<br />
@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[<br />
\t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,<br />
;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]<br />
)*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\<br />
".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?<br />
(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()&lt;&gt;@,;:\\".<br />
\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:<br />
\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[<br />
"()&lt;&gt;@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])<br />
*))*@(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])<br />
+|\Z|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\<br />
.(?:(?:\r\n)?[ \t])*(?:[^()&lt;&gt;@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z<br />
|(?=[\["()&lt;&gt;@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\&gt;(?:(<br />
?:\r\n)?[ \t])*))*)?;\s*)</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.cetinkoca.com/blog/index.php/2009/03/regular-mess/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bit Fields</title>
		<link>http://www.cetinkoca.com/blog/index.php/2009/03/bit-fields/</link>
		<comments>http://www.cetinkoca.com/blog/index.php/2009/03/bit-fields/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 20:29:26 +0000</pubDate>
		<dc:creator>çetin</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Bit fields]]></category>
		<category><![CDATA[C/C++]]></category>

		<guid isPermaLink="false">http://www.cetinkoca.com/blog/?p=56</guid>
		<description><![CDATA[Bit fields are probably one of the least popular language features of C/C++. By using bit fields the programmer can precisely define how many bits are occupied by each member of a struct or class. The syntax for bit fields follows: struct Time { unsigned int pm : 1; unsigned int hour : 4; unsigned [...]]]></description>
			<content:encoded><![CDATA[<p>Bit fields are probably one of the least popular language features of C/C++. By using bit fields the programmer can precisely define how many bits are occupied by each member of a <code>struct</code> or <code>class</code>.<span id="more-56"></span> The syntax for bit fields follows:</p>
<pre class="brush: cpp">
struct Time
{
	unsigned int pm     : 1;
	unsigned int hour   : 4;
	unsigned int minute : 6;
};
</pre>
<p>The member field called <code>pm</code> of the <code>struct Time</code> above occupies only 1-bit, <code>hour</code> occupies 4-bits and <code>minute</code> occupies 6-bits.</p>
<p>Note that the members specified as a bit-field are always treated as integers, so you can omit the keyword <code>int</code> from the definition as follows:</p>
<pre class="brush: cpp">
struct Time
{
	unsigned pm     : 1;
	unsigned hour   : 4;
	unsigned minute : 6;
};
</pre>
<p>Bit fields are accessed just as any other member:</p>
<p><code>
<pre class="brush: cpp">
int main()
{
	Time time;
	time.pm = true;
	time.hour = 10;
	time.minute = 22;

	printf(&quot;The time is %d:%d %sn&quot;,
		time.hour, time.minute, time.pm ? &quot;PM&quot; : &quot;AM&quot;);

	return 0;
}
</pre>
<p></code></p>
<p>Bit fields are actually useful for:</p>
<ul>
<li>Packing several objects into one or more bytes, hence precise control over memory occupation in terms of bits</li>
<li> Creating structs suitable for reading data from, ans possibly writing data to, external file formats as well as transmitting data over network connections</li>
</ul>
<p>Although it is unlikely that you would need to use bit fields in your program, if you ever do so make sure you pay attention to the following:</p>
<ul>
<li>Portability issues</li>
<li>Thread-synchronization issues</li>
</ul>
<p>I will not go into the details here. If you would like to know more about bit fields check following links:</p>
<p><strong>msdn:</strong> <a href="http://msdn.microsoft.com/en-us/library/yszfawxh.aspx" target="_blank">C Bit Fields</a><br />
<strong>msdn:</strong> <a href="http://msdn.microsoft.com/en-us/library/ewwyfdbe.aspx" target="_blank">C++ Bit Fields</a><br />
<strong>Wikipedia:</strong> <a href="http://en.wikipedia.org/wiki/Bit_field" target="_blank">Bit field</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cetinkoca.com/blog/index.php/2009/03/bit-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java is so slow&#8230;</title>
		<link>http://www.cetinkoca.com/blog/index.php/2009/03/java-is-so-slow/</link>
		<comments>http://www.cetinkoca.com/blog/index.php/2009/03/java-is-so-slow/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 23:25:15 +0000</pubDate>
		<dc:creator>çetin</dc:creator>
				<category><![CDATA[Bits & Pieces]]></category>
		<category><![CDATA[allocation]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[deallocation]]></category>
		<category><![CDATA[garbage collector]]></category>
		<category><![CDATA[heap]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[malloc]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[stack]]></category>

		<guid isPermaLink="false">http://www.cetinkoca.com/blog/?p=21</guid>
		<description><![CDATA[&#8230; you would think. Maybe not, but many people seem to agree with that. One interesting fact is that, though, Java&#8217;s allocations are much faster than classic malloc allocations. This is due to the highly optimized nature of allocation in modern JVMs and the way they handle heap allocations and deallocations. Generational collectors is one of [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230; you would think. Maybe not, but many people seem to agree with that. One interesting fact is that, though, Java&#8217;s allocations are much faster than classic malloc allocations.<span id="more-21"></span> This is due to the highly optimized nature of allocation in modern JVMs and the way they handle heap allocations and deallocations. <a href="http://recherche.ircam.fr/equipes/repmus/Rapports/PeterHanappe99/ch1/node3.html" target="_blank">Generational collectors</a> is one of these techniques:</p>
<p> </p>
<blockquote><p>Generational collectors try to benefit from the empirically observed property that most allocated objects live for a very short time, while a small percentage of them live much longer. If an object survives one collection, chances are it will survive many collections. If the collector copies objects or compacts the heap, these long lived objects are copied over and over again. Generational techniques split the heap into several sub-heaps and segregates the objects in the sub-heaps according to their age. New objects are allocated in the first generation sub-heap. When the application runs out of memory, only the first generation sub-heap is scanned. The objects that survive one or more collections are moved to the second generation heap. If most objects are indeed short-lived, most of the first generation heap is freed and few objects need copying to the second generation heap. The older generation sub-heaps are scanned less frequently. Since smaller fragments of the heap are scanned and proportionally more storage space is recovered, the overall efficiency of the garbage collector improves.</p></blockquote>
<p> </p>
<p>Memory allocations are certainly just one aspect of application performance, and Java is still slow for performance-critical applications. Also don&#8217;t forget that programming languages like C and C++ still wins since most of the objects are allocated on the stack, hence free allocations.</p>
<p>Nevertheless, it is surprising to see that allocations in Java are even faster than malloc. Surprising as it is, calling the new operator in Java requires execution of about 10 instructions whereas a malloc call executes 60 to 100 instructions, hence making Java&#8217;s allocations 6 to 10 times faster! Make sure to check the article titled &#8220;<span>Java theory and practice: </span>Urban performance legends, revisited&#8221; by <a href="http://www.ibm.com/developerworks/java/library/j-jtp09275.html" target="_blank">Brian Goetz</a> if you are interested in details.</p>
<p>Finally, I&#8217;d like to share a few funny quotes this article reminds me about Java:</p>
<ul>
<li>If Java had true garbage collection, most programs would delete themselves upon execution. <em>Robert Sewell</em></li>
<li>Java: the elegant simplicity of C++ and the blazing speed of Smalltalk.</li>
<li>Java is high performance. By high performance we mean adequate. By adequate we mean slow. <em>Mr. Bunny</em></li>
<li>Java is, in many ways, <code>C++--</code>.<em> Michael Feldman<br />
</em></li>
</ul>
<p>Take care <img src='http://www.cetinkoca.com/blog/wp-content/plugins/smilies-themer/adiumicons/biggrin.png' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cetinkoca.com/blog/index.php/2009/03/java-is-so-slow/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

