<?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/"
		>
<channel>
	<title>Comments on: C and C++ are not the same language.</title>
	<atom:link href="http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/</link>
	<description></description>
	<lastBuildDate>Sun, 31 Jan 2010 19:10:39 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: COdE fr3@K</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4848</link>
		<dc:creator>COdE fr3@K</dc:creator>
		<pubDate>Sun, 24 May 2009 12:44:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4848</guid>
		<description>&lt;strong&gt;Observer Done Differently...&lt;/strong&gt;

In a recent post of Scott Wheeler&#039;s (C and C++ are not the same language), he talked about differences between C and C++, and applications of different programming languages (C, C++, Java, Ruby) in his company.
In the post, Wheeler implemented observe...</description>
		<content:encoded><![CDATA[<p><strong>Observer Done Differently&#8230;</strong></p>
<p>In a recent post of Scott Wheeler&#8217;s (C and C++ are not the same language), he talked about differences between C and C++, and applications of different programming languages (C, C++, Java, Ruby) in his company.<br />
In the post, Wheeler implemented observe&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bojan</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4857</link>
		<dc:creator>Bojan</dc:creator>
		<pubDate>Fri, 22 May 2009 10:23:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4857</guid>
		<description>&gt; @Scott referring to @Bojan, And memory management, ie garbage collection.

The big bad wolf.

You have to have a bit of perspective on this subject. E.g. more often than not in my line of work manual memory management (optimized for particular usage pattern) has given me tremendous performance boost and predictable heap growth figures.
Yes, writing everyday enterprisy frontends and whatnot benefits greatly from automated memory management, no argument there. Fire-and-forget is usefull.
But I like to have a choice. Using a subset of boost libraries with a bit of RAII can significantly ease the pain of fiddling with memory management in C++, although it still requires a lot of discipline (but then again, it&#039;s not like Java or any other VM out there will let you get away with reckless coding).</description>
		<content:encoded><![CDATA[<p>&gt; @Scott referring to @Bojan, And memory management, ie garbage collection.</p>
<p>The big bad wolf.</p>
<p>You have to have a bit of perspective on this subject. E.g. more often than not in my line of work manual memory management (optimized for particular usage pattern) has given me tremendous performance boost and predictable heap growth figures.<br />
Yes, writing everyday enterprisy frontends and whatnot benefits greatly from automated memory management, no argument there. Fire-and-forget is usefull.<br />
But I like to have a choice. Using a subset of boost libraries with a bit of RAII can significantly ease the pain of fiddling with memory management in C++, although it still requires a lot of discipline (but then again, it&#8217;s not like Java or any other VM out there will let you get away with reckless coding).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Garvin</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4853</link>
		<dc:creator>Joseph Garvin</dc:creator>
		<pubDate>Fri, 22 May 2009 04:19:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4853</guid>
		<description>In addition to John Haugeland&#039;s comments, I would add that anywhere a C programmer uses a function pointer, instead of doing something wildly different a C++ programmer may simply use a boost::function object. What you are calling &quot;modern&quot; C++ is not actually modern C++. I suggest reading the book ironically titled, &quot;Modern C++&quot;. Amazon link: http://www.amazon.com/Modern-Design-Programming-Patterns-Depth/dp/0201704315</description>
		<content:encoded><![CDATA[<p>In addition to John Haugeland&#8217;s comments, I would add that anywhere a C programmer uses a function pointer, instead of doing something wildly different a C++ programmer may simply use a boost::function object. What you are calling &#8220;modern&#8221; C++ is not actually modern C++. I suggest reading the book ironically titled, &#8220;Modern C++&#8221;. Amazon link: <a href="http://www.amazon.com/Modern-Design-Programming-Patterns-Depth/dp/0201704315" rel="nofollow">http://www.amazon.com/Modern-Design-Programming-Patterns-Depth/dp/0201704315</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Walter</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4876</link>
		<dc:creator>Walter</dc:creator>
		<pubDate>Thu, 21 May 2009 19:46:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4876</guid>
		<description>Nobody would write the Java iterator like that. This is more idiomatic:

  for(Listener listener : listeners)
  {
    listener.activate();
  }

There&#039;s no need to have a concrete FooListener class, nor a separate class to run it.  Just put this in Foomatic.java and get rid of Callback.java altogether:


  /* ... */
  public static void main(String[] args)
  {
  Listener listener = new Listener()
  {
     public void activate()
     {            System.out.println(&quot;Whoopee.&quot;);
     }
  }

  Foomatic foomatic = new Foomatic();
  foomatic.addListener(listener);
  foomatic.addListener(listener);
  foomatic.activate();
}</description>
		<content:encoded><![CDATA[<p>Nobody would write the Java iterator like that. This is more idiomatic:</p>
<p>  for(Listener listener : listeners)<br />
  {<br />
    listener.activate();<br />
  }</p>
<p>There&#8217;s no need to have a concrete FooListener class, nor a separate class to run it.  Just put this in Foomatic.java and get rid of Callback.java altogether:</p>
<p>  /* &#8230; */<br />
  public static void main(String[] args)<br />
  {<br />
  Listener listener = new Listener()<br />
  {<br />
     public void activate()<br />
     {            System.out.println(&#8220;Whoopee.&#8221;);<br />
     }<br />
  }</p>
<p>  Foomatic foomatic = new Foomatic();<br />
  foomatic.addListener(listener);<br />
  foomatic.addListener(listener);<br />
  foomatic.activate();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Wheeler</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4875</link>
		<dc:creator>Scott Wheeler</dc:creator>
		<pubDate>Thu, 21 May 2009 17:29:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4875</guid>
		<description>@Ben -- the listeners in the C example aren&#039;t created by malloc -- they&#039;re just pointers to functions, so they don&#039;t need to be freed.  The thing being freed there is the array of pointers to those functions, which is created with the realloc call, and there, in fact, one free suffices.</description>
		<content:encoded><![CDATA[<p>@Ben &#8212; the listeners in the C example aren&#8217;t created by malloc &#8212; they&#8217;re just pointers to functions, so they don&#8217;t need to be freed.  The thing being freed there is the array of pointers to those functions, which is created with the realloc call, and there, in fact, one free suffices.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4869</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Thu, 21 May 2009 16:07:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4869</guid>
		<description>Very nice article. I have to agree with your choice of C++. I came to the same decision a few years ago. I&#039;m in the boost camp BTW :) At the same time, I can understand why folks dislike C++. It&#039;s powerful and complex and intimidating and thus easy to screw-up at times. I encourage folks to try it and only use the parts they need (it&#039;s a big language) to build and ship a product. It&#039;s been my experience that once they do that, they love it too.</description>
		<content:encoded><![CDATA[<p>Very nice article. I have to agree with your choice of C++. I came to the same decision a few years ago. I&#8217;m in the boost camp BTW <img src='http://blog.directededge.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  At the same time, I can understand why folks dislike C++. It&#8217;s powerful and complex and intimidating and thus easy to screw-up at times. I encourage folks to try it and only use the parts they need (it&#8217;s a big language) to build and ship a product. It&#8217;s been my experience that once they do that, they love it too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4868</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Thu, 21 May 2009 15:55:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4868</guid>
		<description>I mentioned this on HN, but I just wanted to support what you said about memory management being more of a hassle in C. Case in point, either you only freed one of your listeners in your C code (memory leak) or I&#039;m still a dufus with C memory management.

Interesting post though. I&#039;m reading C, Interfaces and Implementation and I find it fascinating to see C as C programmers C it, instead of someone more from C++ land.</description>
		<content:encoded><![CDATA[<p>I mentioned this on HN, but I just wanted to support what you said about memory management being more of a hassle in C. Case in point, either you only freed one of your listeners in your C code (memory leak) or I&#8217;m still a dufus with C memory management.</p>
<p>Interesting post though. I&#8217;m reading C, Interfaces and Implementation and I find it fascinating to see C as C programmers C it, instead of someone more from C++ land.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kman</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4873</link>
		<dc:creator>Kman</dc:creator>
		<pubDate>Thu, 21 May 2009 14:26:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4873</guid>
		<description>given that a c++ compiler supports the c99 keyword &quot;restrict&quot; and that a program was written with it in mind, 100% of the time c++ will be faster than anything running on a VM. c++ compilers have a hard time optimizing pointer related logic, namely aliasing (stores affecting loads), but with &quot;restrict&quot; this is no longer an issue. of course if one is really after performance, i&#039;m sure most compilers support their own extension to c++, such as __declspec() in msvc++. with these expensions, the generated assembly will be very close to what one might hand-write.</description>
		<content:encoded><![CDATA[<p>given that a c++ compiler supports the c99 keyword &#8220;restrict&#8221; and that a program was written with it in mind, 100% of the time c++ will be faster than anything running on a VM. c++ compilers have a hard time optimizing pointer related logic, namely aliasing (stores affecting loads), but with &#8220;restrict&#8221; this is no longer an issue. of course if one is really after performance, i&#8217;m sure most compilers support their own extension to c++, such as __declspec() in msvc++. with these expensions, the generated assembly will be very close to what one might hand-write.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zwieback</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4872</link>
		<dc:creator>Zwieback</dc:creator>
		<pubDate>Thu, 21 May 2009 13:50:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4872</guid>
		<description>One thing is undeniable: of the popular languages C++ covers the most ground. I can write anything from device drivers to Enterprise apps to CAD programs in C++. Is it the best choice for any one of these? Maybe not but it comes close enough that it&#039;s still a good choice for a first language.</description>
		<content:encoded><![CDATA[<p>One thing is undeniable: of the popular languages C++ covers the most ground. I can write anything from device drivers to Enterprise apps to CAD programs in C++. Is it the best choice for any one of these? Maybe not but it comes close enough that it&#8217;s still a good choice for a first language.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Wheeler</title>
		<link>http://blog.directededge.com/2009/05/21/c-and-c-are-not-the-same-language/comment-page-1/#comment-4874</link>
		<dc:creator>Scott Wheeler</dc:creator>
		<pubDate>Thu, 21 May 2009 12:53:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.directededge.com/?p=241#comment-4874</guid>
		<description>@Peter

&quot;C++ is slower&quot; -- not inherently, and this is naturally compiler dependent.  But when writing high-performance C++, it does help to know how the features are implemented (e.g. what they&#039;d look like in C) when using them.  Note the &lt;a href=&quot;http://shootout.alioth.debian.org/u32/benchmark.php?test=all&amp;lang=gcc&amp;lang2=gpp&amp;box=1&quot; rel=&quot;nofollow&quot;&gt;benchmark here&lt;/a&gt; where C++ does the same or better than C in almost every category.

&quot;RTTI overhead&quot; -- hasn&#039;t really been a problem since GCC 2.95.  Post 2.95 it&#039;s been placed in a separate section of the binary and of course you can disable RTTI with compilation flags if you really care.

&quot;C really isn’t either anymore. VM...&quot; -- that&#039;s rarely the case. Occasionally JIT compilers will oust compiled languages, but not often.  In benchmarks that we did internally comparing the numerics core of our recommendations engine in Java vs. C++, C++ was 2.5x faster.</description>
		<content:encoded><![CDATA[<p>@Peter</p>
<p>&#8220;C++ is slower&#8221; &#8212; not inherently, and this is naturally compiler dependent.  But when writing high-performance C++, it does help to know how the features are implemented (e.g. what they&#8217;d look like in C) when using them.  Note the <a href="http://shootout.alioth.debian.org/u32/benchmark.php?test=all&#038;lang=gcc&#038;lang2=gpp&#038;box=1" rel="nofollow">benchmark here</a> where C++ does the same or better than C in almost every category.</p>
<p>&#8220;RTTI overhead&#8221; &#8212; hasn&#8217;t really been a problem since GCC 2.95.  Post 2.95 it&#8217;s been placed in a separate section of the binary and of course you can disable RTTI with compilation flags if you really care.</p>
<p>&#8220;C really isn’t either anymore. VM&#8230;&#8221; &#8212; that&#8217;s rarely the case. Occasionally JIT compilers will oust compiled languages, but not often.  In benchmarks that we did internally comparing the numerics core of our recommendations engine in Java vs. C++, C++ was 2.5x faster.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
