News for hackers. Stuff that matters.
Re:The C Programming Language: Myths and Reality (1) by lelanthran on Monday July 17, 2023 @11:56AM (#36759783)
> I wouldn't call this equivalent to the private keyword:

I didn't mean to imply it is, I lead with:

>> All too often someone, somewhere, on some forum … will lament the lack of encapsulation and isolation in the C programming language. This happens with such regularity that I now feel compelled to address the myth once and forever.

It's only about the myth that C doesn't have any level of encapsulation or isolation.

Re:The C Programming Language: Myths and Reality (1) by brabel on Monday July 17, 2023 @12:22PM (#36760118)
Nearly every rebuttal on the internet starts with misinterpretation of what's being said. Good reading skills are extremely rare, it seems.

To be clear: you tried to say "C offers encapsulation/isolation". People read "This solution is equivalent to 'private'", an almost completely unrelated statement, and then respond to that.

That could typically be classified as a "Straw man fallacy"[0], but I believe people who do this in many cases simply do not have the necessary reading skills to understand what proposition has been made, and therefore honestly believe themselves to be reasoning correctly (i.e. without fallacy).

Reading comprehension used to be a topic at school when I was a child. I suppose that's no longer the case??

[0] https://en.wikipedia.org/wiki/Straw_man

Re:The C Programming Language: Myths and Reality (1) by jasode on Monday July 17, 2023 @12:32PM (#36760280)
>To be clear: you tried to say "C offers encapsulation/isolation". People read "This solution is equivalent to 'private'", an almost completely unrelated statement, and then respond to that.

>That could typically be classified as a "Straw man fallacy"[0], but I believe people who do this in many cases simply do not have the necessary reading skills

Fyi... the author's article that this thread is about has in bold heading: "Myth: C has no equivalent to “private”"

So, a reasonable interpretation of the text following that headline is how to use C Language constructs to dispel that myth.

Doesn't seem like "straw man" applies here.

Re:The C Programming Language: Myths and Reality (1) by gjulianm on Monday July 17, 2023 @03:17PM (#36762689)
As the other commenter said, and I want to reiterate, what led me to start with the talk about the private keyword is the big bold header that says "Myth: C has no equivalent to “private”" and the first code snippet that shows how you can have "private" fields in C++ and the following ones that show an "equivalent" implementation in C. So I think it's reasonable to infer that the author is talking about encapsulation and "the private keyword" as somewhat interchangeable (and I don't disagree, for this discussion they're practically the same). Not only that, but the points I made are about the implementation shown in the article, which is independent of whether the talk is about "private equivalency" or "lack of encapsulation": the gist of it is "yes, you 'encapsulate' things but not in the same way and it comes with disadvantages that aren't really there in other languages".

With all that said, I don't think all that condescending talk about the lack of reading comprehension or skills, without actually going into the arguments themselves, is really necessary or positive.

Re:The C Programming Language: Myths and Reality (1) by gjulianm on Monday July 17, 2023 @03:05PM (#36762563)
I mean, there's a big header that says "Myth: C has no equivalent to “private”" and a code example about the private keyword, so that's why I started saying that. Even then, my points still apply: this isn't really equivalent to how encapsulation works in other languages due to the lack of granularity and the "extras" of all the usual language behavior that stops being supported.
Re:The C Programming Language: Myths and Reality (1) by lelanthran on Tuesday July 18, 2023 @02:27AM (#36768616)
> I mean, there's a big header that says "Myth: C has no equivalent to “private”" and a code example about the private keyword, so that's why I started saying that.

You are correct; I should change the heading to "Myth: C provides no encapsulation". I don't want to do it now, as the discussion is still ongoing and making this change now while people are commenting on the 'private equivalence" aspect would be gaslighting those people.

> Even then, my points still apply: this isn't really equivalent to how encapsulation works in other languages due to the lack of granularity and the "extras" of all the usual language behavior that stops being supported.

So? The myth the article addresses is "C has no encapsulation", not "C has great encapsulation".

That C provides stronger encapsulation and stronger guarantees for upgrade migration is the specific myth that I am trying to address.

Re:The C Programming Language: Myths and Reality (1) by gjulianm on Tuesday July 18, 2023 @03:38AM (#36769104)
I think that at this point this is a discussion about semantics, just as this other commenter pointed out: https://news.ycombinator.com/item?id=36758407

Yes, you can do something in C that somewhat resembles encapsulation. You could also do it in Python with a decorator that inspects the caller. You can also do inheritance and virtual functions in C. You could do anything in a Turing complete language. But usually when talking about "X language has Y" refers to whether the language has Y as part of the specification. In this case it isn't encapsulation as part of the specification (that's why it comes with all those downsides/extras) but as an artifact of other aspects of the language, that's why I say it's not really equivalent.