<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>simias</author><text>I see where you&amp;#x27;re coming from but IMO this &amp;quot;Cheshire cat&amp;quot; idiom to hide the implementation details is not exactly like private, it fact it can do things that private can&amp;#x27;t do, and doesn&amp;#x27;t do things private does.&lt;p&gt;The advantage of hiding your state behind an opaque struct with builders and accessors is that you can change the size and layout of said struct without it being a breaking API change. The code remains binary compatible even, no need for a recompile if you&amp;#x27;re shipping a shared lib. This is something just using private members doesn&amp;#x27;t achieve since with private members the compiler still knows and uses the layout of the struct, it just forbids access to it.&lt;p&gt;That&amp;#x27;s why you can even find C++ libraries use this idiom even though C++ obviously has `private`. It&amp;#x27;s about having a stable, opaque API.&lt;p&gt;On the other hand because of this added indirection, there&amp;#x27;s usually a greater performance hit to accessing these opaque structs since code can&amp;#x27;t be inlined. With private since the compiler can still see inside the struct, it&amp;#x27;s able to more aggressively optimize the code. You can also store the objects directly on the stack without requiring malloc.&lt;p&gt;IMO the right way to have private members in C structs is... to document that members shouldn&amp;#x27;t be touched directly, perhaps using a special naming convention or embedding the publicly-accessible members in a dedicated sub-struct to prevent confusion.</text><parent_chain></parent_chain></comment><story><title>The C Programming Language: Myths and Reality</title><url>https://www.lelanthran.com/chap9/content.html</url></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>jasode</author><text>To the author :  your explanation can be interpreted as &amp;quot;correct&amp;quot; but also be aware that -- for some readers -- your argument is a variation of the Turing Tarpit:  &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;Turing_tarpit&quot; rel=&quot;nofollow noreferrer&quot;&gt;https:&amp;#x2F;&amp;#x2F;en.wikipedia.org&amp;#x2F;wiki&amp;#x2F;Turing_tarpit&lt;/a&gt;&lt;p&gt;In other words, the 2 different possible receptions to your post:&lt;p&gt;- YES, file-level modularity with opaque structs is _equivalent_ to class private members --&amp;gt;  for those mindsets already sympathetic to C Language&lt;p&gt;- NO, using file-scoping rules and structs is &lt;i&gt;not equivalent&lt;/i&gt; to class private members because it&amp;#x27;s a bunch of extra ceremonial syntax to implement a workaround. (The &amp;quot;Turing Tarpit&amp;quot;).  It&amp;#x27;s using the opaque struct as a &amp;quot;design pattern&amp;quot; and as Peter Norvig famously said, &lt;i&gt;&amp;quot;Design patterns are bug reports against your programming language.&amp;quot;&lt;/i&gt;</text><parent_chain></parent_chain></comment><story><title>The C Programming Language: Myths and Reality</title><url>https://www.lelanthran.com/chap9/content.html</url></story>