<?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/"
	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>Comments for Attractive Chaos</title>
	<atom:link href="http://attractivechaos.wordpress.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://attractivechaos.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 22 Oct 2009 21:42:43 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on About by Mohammad</title>
		<link>http://attractivechaos.wordpress.com/about/#comment-250</link>
		<dc:creator>Mohammad</dc:creator>
		<pubDate>Thu, 22 Oct 2009 21:42:43 +0000</pubDate>
		<guid isPermaLink="false">#comment-250</guid>
		<description>excellent blog.. i&#039;ve read some of your topics.. i&#039;ve been interested in &#039;em .. and I&#039;ve bookmark-ed it in my firefox browser.. xD
thank you</description>
		<content:encoded><![CDATA[<p>excellent blog.. i&#8217;ve read some of your topics.. i&#8217;ve been interested in &#8216;em .. and I&#8217;ve bookmark-ed it in my firefox browser.. xD<br />
thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C Array vs. C++ Vector by attractivechaos</title>
		<link>http://attractivechaos.wordpress.com/2008/09/19/c-array-vs-c-vector/#comment-244</link>
		<dc:creator>attractivechaos</dc:creator>
		<pubDate>Wed, 30 Sep 2009 20:46:31 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=456#comment-244</guid>
		<description>This post finally becomes the discussion on C++ grammar, or more precisely the STL usage. I admit I misused STL, but I did not do anything wrong in C++. I did not misinterpret the standard STL source code. In addition, what I really want to say here is dynamic vector is bad. What I really want to ask is why vector is that slow while it simply implements a strategy nearly identical to the C code.

@eddieclay

I see why you get SIGABRT. This is because you are using &quot;debug/vector&quot; which is almost entirely different from the standard vector except for the interface. It is less efficient and adds a lot of excessively stringent out-of-boundary assertions to keep your program from potential bugs. I did not have this problem because I always use the command line which links to the &quot;released&quot; version at least by default. If you link to the &quot;release version&quot;, you will not see SIGABRT; valgrind will complain nothing. With the standard STL, there is NO memory problem with the example I have shown. In C++ syntax itself, there is nothing wrong with my program. It is the debug version of STL that imposes the requirement, which is helpful, though.</description>
		<content:encoded><![CDATA[<p>This post finally becomes the discussion on C++ grammar, or more precisely the STL usage. I admit I misused STL, but I did not do anything wrong in C++. I did not misinterpret the standard STL source code. In addition, what I really want to say here is dynamic vector is bad. What I really want to ask is why vector is that slow while it simply implements a strategy nearly identical to the C code.</p>
<p>@eddieclay</p>
<p>I see why you get SIGABRT. This is because you are using &#8220;debug/vector&#8221; which is almost entirely different from the standard vector except for the interface. It is less efficient and adds a lot of excessively stringent out-of-boundary assertions to keep your program from potential bugs. I did not have this problem because I always use the command line which links to the &#8220;released&#8221; version at least by default. If you link to the &#8220;release version&#8221;, you will not see SIGABRT; valgrind will complain nothing. With the standard STL, there is NO memory problem with the example I have shown. In C++ syntax itself, there is nothing wrong with my program. It is the debug version of STL that imposes the requirement, which is helpful, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on C Array vs. C++ Vector by eddieclay</title>
		<link>http://attractivechaos.wordpress.com/2008/09/19/c-array-vs-c-vector/#comment-243</link>
		<dc:creator>eddieclay</dc:creator>
		<pubDate>Wed, 30 Sep 2009 20:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=456#comment-243</guid>
		<description>Running on mac/intel under gdb the error explains it pretty well and concurs with what Tom said that it is &quot; checking that the index parameter is less than size(), which it is not, because the code only calls reserve and not resize. &quot;


Running…
C array, preallocated: 0.950 sec
C array, dynamic: 2.037 sec
C vector, dynamic (kv_a): 1.271 sec
C vector, dynamic (kv_push): 1.794 sec
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/debug/vector:198:
    error: attempt to subscript container with out-of-bounds index 0, but     
    container only holds 0 elements.

Objects involved in the operation:
sequence &quot;this&quot; @ 0x0x7fff5fbff6d0 {
  type = NSt7__debug6vectorIiSaIiEEE;
}
Program received signal:  “SIGABRT”.</description>
		<content:encoded><![CDATA[<p>Running on mac/intel under gdb the error explains it pretty well and concurs with what Tom said that it is &#8221; checking that the index parameter is less than size(), which it is not, because the code only calls reserve and not resize. &#8221;</p>
<p>Running…<br />
C array, preallocated: 0.950 sec<br />
C array, dynamic: 2.037 sec<br />
C vector, dynamic (kv_a): 1.271 sec<br />
C vector, dynamic (kv_push): 1.794 sec<br />
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/debug/vector:198:<br />
    error: attempt to subscript container with out-of-bounds index 0, but<br />
    container only holds 0 elements.</p>
<p>Objects involved in the operation:<br />
sequence &#8220;this&#8221; @ 0&#215;0x7fff5fbff6d0 {<br />
  type = NSt7__debug6vectorIiSaIiEEE;<br />
}<br />
Program received signal:  “SIGABRT”.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on OOP in C? Don&#8217;t go too far. by Amos Wenger</title>
		<link>http://attractivechaos.wordpress.com/2009/09/20/oop-in-c-dont-go-too-far/#comment-240</link>
		<dc:creator>Amos Wenger</dc:creator>
		<pubDate>Tue, 29 Sep 2009 22:03:19 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=674#comment-240</guid>
		<description>I think you might be interested by http://ooc-lang.org/ (and by &#039;you&#039;, I mean both the writer and the readers of this blog)

It&#039;s my attempt to make an OOP language which translates to C and sucks less than C++ (a very unfair description but it puts it into context.)

Anyway - you can learn more about it on the homepage, and this page http://ooc-lang.org/syntax should give you a good fell of its syntax.

Note that it&#039;s still in early development, and ides are welcome (we can be found at #ooc-lang on Freenode)</description>
		<content:encoded><![CDATA[<p>I think you might be interested by <a href="http://ooc-lang.org/" rel="nofollow">http://ooc-lang.org/</a> (and by &#8216;you&#8217;, I mean both the writer and the readers of this blog)</p>
<p>It&#8217;s my attempt to make an OOP language which translates to C and sucks less than C++ (a very unfair description but it puts it into context.)</p>
<p>Anyway &#8211; you can learn more about it on the homepage, and this page <a href="http://ooc-lang.org/syntax" rel="nofollow">http://ooc-lang.org/syntax</a> should give you a good fell of its syntax.</p>
<p>Note that it&#8217;s still in early development, and ides are welcome (we can be found at #ooc-lang on Freenode)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on B-tree vs. Binary Search Tree by attractivechaos</title>
		<link>http://attractivechaos.wordpress.com/2008/09/24/b-tree-vs-binary-search-tree/#comment-239</link>
		<dc:creator>attractivechaos</dc:creator>
		<pubDate>Tue, 29 Sep 2009 11:42:50 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=507#comment-239</guid>
		<description>@alohaeverafter

You may read my other posts about efficient generic programming in C. For generic C libraries, GDSL/Glib uses void*, which may have efficiency issue. &lt;a href=&quot;http://sglib.sourceforge.net/&quot; rel=&quot;nofollow&quot;&gt;Sglib&lt;/a&gt; and &lt;a href=&quot;http://nothings.org/&quot; rel=&quot;nofollow&quot;&gt;Sean&#039;s Tool Box&lt;/a&gt; use macros, although sglib does not use the best algorithm at least for rb-tree. For generic RB-tree, &lt;a href=&quot;http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/tree.h&quot; rel=&quot;nofollow&quot;&gt;Niels Provos&#039; tree library&lt;/a&gt; is recommended due to its performance and stability. For generic hash table libraries in C, I recommend my own implementation.

STL is the work of several phenomenal programmers who have considerable influence over the C++ programming. It is difficult for a common/unknown programmer to write something widely accepted by the C community. In addition, good C programmers, like me, love to reinvent the wheel. They do not rely too much on existing libraries as much as C++ programmers do.</description>
		<content:encoded><![CDATA[<p>@alohaeverafter</p>
<p>You may read my other posts about efficient generic programming in C. For generic C libraries, GDSL/Glib uses void*, which may have efficiency issue. <a href="http://sglib.sourceforge.net/" rel="nofollow">Sglib</a> and <a href="http://nothings.org/" rel="nofollow">Sean&#8217;s Tool Box</a> use macros, although sglib does not use the best algorithm at least for rb-tree. For generic RB-tree, <a href="http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/tree.h" rel="nofollow">Niels Provos&#8217; tree library</a> is recommended due to its performance and stability. For generic hash table libraries in C, I recommend my own implementation.</p>
<p>STL is the work of several phenomenal programmers who have considerable influence over the C++ programming. It is difficult for a common/unknown programmer to write something widely accepted by the C community. In addition, good C programmers, like me, love to reinvent the wheel. They do not rely too much on existing libraries as much as C++ programmers do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on B-tree vs. Binary Search Tree by alohaeverafter</title>
		<link>http://attractivechaos.wordpress.com/2008/09/24/b-tree-vs-binary-search-tree/#comment-238</link>
		<dc:creator>alohaeverafter</dc:creator>
		<pubDate>Tue, 29 Sep 2009 10:55:21 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=507#comment-238</guid>
		<description>What’s more important, C++ programmers have STL. but most C programmers have to achieve generic programming at the cost of efficiency. I want to change this. Although the .h source code is hard to read, the API does not look so bad. What do you think? Do you have better ideas? I am still exploring the methods.
&lt;a href=&quot;http://www.thebootcd.com&quot; rel=&quot;nofollow&quot;&gt;www.thebootcd.com&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>What’s more important, C++ programmers have STL. but most C programmers have to achieve generic programming at the cost of efficiency. I want to change this. Although the .h source code is hard to read, the API does not look so bad. What do you think? Do you have better ideas? I am still exploring the methods.<br />
<a href="http://www.thebootcd.com" rel="nofollow">http://www.thebootcd.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on OOP in C? Don&#8217;t go too far. by attractivechaos</title>
		<link>http://attractivechaos.wordpress.com/2009/09/20/oop-in-c-dont-go-too-far/#comment-237</link>
		<dc:creator>attractivechaos</dc:creator>
		<pubDate>Mon, 28 Sep 2009 09:30:59 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=674#comment-237</guid>
		<description>@Antiguru

I agree with you in general. C++ is unnecessarily overcomplicated. I only use C these days, although I used to systematically study STL source code back to a few years ago.

I am thinking why C++ is so popular. There must be a reason. In my view, the magic of C is to write a variety of programs from a few simple rules. But to combine these rules effectively and efficiently, you must have a programmer&#039;s mind which is not possessed by everyone. Many people after C classes cannot work on real projects at all. They do not know where to start from simple rules. In contrast, C++ gives you many complex rules. After C++ classes, you feel you have really learned something. You can write reasonably good programs without really grasping the essence of programming. For many people, remembering knowledges is much easier than using knowledges. Simplicity attracts someone but also pushes someone away. To this end, C++ lowers the threshold of a qualified programmer.

However, even so I think the adoption of C++ is a historical mistake. To be compatible with C libraries (not C source code), D does much better. It is just too late.</description>
		<content:encoded><![CDATA[<p>@Antiguru</p>
<p>I agree with you in general. C++ is unnecessarily overcomplicated. I only use C these days, although I used to systematically study STL source code back to a few years ago.</p>
<p>I am thinking why C++ is so popular. There must be a reason. In my view, the magic of C is to write a variety of programs from a few simple rules. But to combine these rules effectively and efficiently, you must have a programmer&#8217;s mind which is not possessed by everyone. Many people after C classes cannot work on real projects at all. They do not know where to start from simple rules. In contrast, C++ gives you many complex rules. After C++ classes, you feel you have really learned something. You can write reasonably good programs without really grasping the essence of programming. For many people, remembering knowledges is much easier than using knowledges. Simplicity attracts someone but also pushes someone away. To this end, C++ lowers the threshold of a qualified programmer.</p>
<p>However, even so I think the adoption of C++ is a historical mistake. To be compatible with C libraries (not C source code), D does much better. It is just too late.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on OOP in C? Don&#8217;t go too far. by Antiguru</title>
		<link>http://attractivechaos.wordpress.com/2009/09/20/oop-in-c-dont-go-too-far/#comment-236</link>
		<dc:creator>Antiguru</dc:creator>
		<pubDate>Mon, 28 Sep 2009 00:42:58 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=674#comment-236</guid>
		<description>You can do OOP in assembly but you can be sure you know what you are doing if you build it yourself.

The problem with C++ seems to me they are adding too many overcomplex features but not simplifying anything.

Take autopointers. The idea is yet another thing to obscure memory management but you should either go for managed memory or keep at a lower level, not a horrid in between state. With autopointers you make many small allocations, and you are doing extra allocations for the pointer itself. AND you can easily accidentally assign it to the wrong thing anyway...so what&#039;s the benefit? It&#039;s not only worthless but a very harmful and misguided practice.

A pointer should be a pointer, not some vague idea that you have no idea what it&#039;s really doing on a particular platform. Types with pointers is very likely a mistake, and not the only possible mechanism to avoid assignment to invalid object types. 

Memory and pointers are easy concepts but C++ completely obscures them instead of forcing programmers to just use them from the start.

Inheritance is really not something to worry about, though. It&#039;s not the performance issue many make out or it&#039;s not if you are using it in places that make sense. 

The biggest performance problem with OOP is that C++ has awful memory allocation that just can&#039;t handle lots of small allocations (such as autopointers) which causes huge waste in space and time. 

The real problem, though, is overcomplexity. If you use anything in STL at all, it&#039;s not long before you have to start coding every single thing around the STL in their (very very silly) paradigm. The new casts are a good illustration of what&#039;s wrong with C++&#039;s direction - if you are consciously throwing out constness ever, and I mean EVER, you are doing something very wrong or using a very poorly made library (usually latter).

Templates themselves are nice and would also be a good addition to C, but the way they are used by most people is just awful, including STL. 


What really needs to happen is to ditch C and C++ completely. Many of the C++ OOP features are just halfassed and barely functional. IE try and catch, namespaces, having to tell the compiler to use virtual destructors when overloaded. There&#039;s so many old features lingering that it makes it so that most people are also basically redefining C++ as they go, making their code useless to anyone who doesn&#039;t use their exact same paradigm.</description>
		<content:encoded><![CDATA[<p>You can do OOP in assembly but you can be sure you know what you are doing if you build it yourself.</p>
<p>The problem with C++ seems to me they are adding too many overcomplex features but not simplifying anything.</p>
<p>Take autopointers. The idea is yet another thing to obscure memory management but you should either go for managed memory or keep at a lower level, not a horrid in between state. With autopointers you make many small allocations, and you are doing extra allocations for the pointer itself. AND you can easily accidentally assign it to the wrong thing anyway&#8230;so what&#8217;s the benefit? It&#8217;s not only worthless but a very harmful and misguided practice.</p>
<p>A pointer should be a pointer, not some vague idea that you have no idea what it&#8217;s really doing on a particular platform. Types with pointers is very likely a mistake, and not the only possible mechanism to avoid assignment to invalid object types. </p>
<p>Memory and pointers are easy concepts but C++ completely obscures them instead of forcing programmers to just use them from the start.</p>
<p>Inheritance is really not something to worry about, though. It&#8217;s not the performance issue many make out or it&#8217;s not if you are using it in places that make sense. </p>
<p>The biggest performance problem with OOP is that C++ has awful memory allocation that just can&#8217;t handle lots of small allocations (such as autopointers) which causes huge waste in space and time. </p>
<p>The real problem, though, is overcomplexity. If you use anything in STL at all, it&#8217;s not long before you have to start coding every single thing around the STL in their (very very silly) paradigm. The new casts are a good illustration of what&#8217;s wrong with C++&#8217;s direction &#8211; if you are consciously throwing out constness ever, and I mean EVER, you are doing something very wrong or using a very poorly made library (usually latter).</p>
<p>Templates themselves are nice and would also be a good addition to C, but the way they are used by most people is just awful, including STL. </p>
<p>What really needs to happen is to ditch C and C++ completely. Many of the C++ OOP features are just halfassed and barely functional. IE try and catch, namespaces, having to tell the compiler to use virtual destructors when overloaded. There&#8217;s so many old features lingering that it makes it so that most people are also basically redefining C++ as they go, making their code useless to anyone who doesn&#8217;t use their exact same paradigm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on OOP in C? Don&#8217;t go too far. by attractivechaos</title>
		<link>http://attractivechaos.wordpress.com/2009/09/20/oop-in-c-dont-go-too-far/#comment-234</link>
		<dc:creator>attractivechaos</dc:creator>
		<pubDate>Sat, 26 Sep 2009 19:12:11 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=674#comment-234</guid>
		<description>Well, I miss C++ template, but I do not feel OOP ideas help much in my mid-scaled projects. With procedural programming, developers also break a big system down to small bits. In addition, as I said, most well-formed C projects have encapsulation and (de)construction, but I do not know if these few features alone can be said as OO coding style. In my view, OOP in C++ and procedural programming in C have similar efficiency and flexibility. I was just saying that implementing too many OOP features in C hurts performance.</description>
		<content:encoded><![CDATA[<p>Well, I miss C++ template, but I do not feel OOP ideas help much in my mid-scaled projects. With procedural programming, developers also break a big system down to small bits. In addition, as I said, most well-formed C projects have encapsulation and (de)construction, but I do not know if these few features alone can be said as OO coding style. In my view, OOP in C++ and procedural programming in C have similar efficiency and flexibility. I was just saying that implementing too many OOP features in C hurts performance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on OOP in C? Don&#8217;t go too far. by shelling</title>
		<link>http://attractivechaos.wordpress.com/2009/09/20/oop-in-c-dont-go-too-far/#comment-233</link>
		<dc:creator>shelling</dc:creator>
		<pubDate>Sat, 26 Sep 2009 16:43:18 +0000</pubDate>
		<guid isPermaLink="false">http://attractivechaos.wordpress.com/?p=674#comment-233</guid>
		<description>interesting comment. 

I heard there is also OO coding style in Linux Kernel. When programs go further complicated, do something in OO may reduce the load to designed a big system. 

It is also the original significance: breaking code into segments with proper authorizing and simplifying the process to design a system.

It is true whether or not choose OOP is a trade-off between efficiency and flexibility.</description>
		<content:encoded><![CDATA[<p>interesting comment. </p>
<p>I heard there is also OO coding style in Linux Kernel. When programs go further complicated, do something in OO may reduce the load to designed a big system. </p>
<p>It is also the original significance: breaking code into segments with proper authorizing and simplifying the process to design a system.</p>
<p>It is true whether or not choose OOP is a trade-off between efficiency and flexibility.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
