[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Extra juicy! | Home]

Why are python programmers less retarded than C++ programmers?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 15
Thread images: 1

File: 1413808482810.png (832KB, 1024x768px) Image search: [iqdb] [SauceNao] [Google]
1413808482810.png
832KB, 1024x768px
Why does C++ allow enforcing encapsulation with protected/private keywords? It's not really necessary unless the people who use your library are fucking retards.

Python doesn't enforce encapsulation, you're supposed to know that it's fucking retarded to bypass setters/getters and access member variables directly. inb4 "muh underscores" because that just doesn't count as enforced encapsulation.

It's ironic, really, because in most other cases C++ is fine with letting retards wreck their own shit, leak memory, write outside of array bounds, etc. What gives?
>>
>>51414417
>Why does C++ allow enforcing encapsulation with protected/private keywords? It's not really necessary unless the people who use your library are fucking retards.

its to ensure the users of your library know which functions are "safe" to use without having to read all the source code. cos you're right, they could work it out but why bother if you dont need to.

also, it helps you when you release version2,3,4... of your lib, as long as you dont change the public interface you can change your code with impunity (protected stuff is slightly different but the same sort of thing applies).
>>
install C
>>
>>51416092
"install" C ftw
>>
>>51414417
>Why does C++ allow enforcing encapsulation with protected/private keywords?
Because C++ is the amalgamation of every feature Stroustrup found passingly interesting. Unlike Java you find a reasonable number of C++ programmers who make everything public because they don't feel the need for language enforcement.

DESU I think your typical C++ programmer is going to be smarter than a typical python programmer, which isn't to say I think the former is a better language but it's just more complicated/"rich" and generally takes more thinking to use well.
>>
>>51414417
>inb4 "muh underscores" because that just doesn't count as enforced encapsulation.
It doesn't count but it seems quite a few find encapsulation necessary. Which is why they have to work around not having private members by using underscore prefix. So, why wasn't this oversight fixed? Why doesn't python allow enforcing private members?
>>
>>51414417
It's what you get from design by committee, some retarded OO fag thought it would be 'nice' to be able to semantically mark up 'private' data and functions.
The sad things is it's doubly retarded in C++ because of the compilation model, if you change class private data you still have to recompile every user of the class anyway, so all the private and protected keywords accomplish is useless busy work for bureaucratic code monkeys.
>>
>>51417083
You can use closure semantics if you really want "private" members but I don't think it's an oversight even if you couldn't. Convention works perfectly fine. A far greater number of people use style conventions for the class/instance distinction in Java, does that mean the lack of enforcement of capitalization style in Java was an oversight as well? Surely it couldn't be that every instance of convention is an example of language oversight.
>>
>>51414417
>in most other cases C++ is fine with letting retards wreck their own shit, leak memory, write outside of array bounds
>what are smart pointers and STL containers

You can write safe programs in C++ you know. Encapsulation is a good thing. Python enforces more petty things, like forced formatting. In the end they both can't stop awful programmers being awful.

I like both languages though.
>>
>>51417119
>what is pimpl
>>
The worst part is the visibility system is completely non-functional. You can literally remove the private keyword from a codebase and the only thing you lose is an advisory error.

class A { };
class B { public: int x; };

class C : private A, public B { private: int x; };

void foo(A*);
void foo(B*);

int main() {
C c;
foo(&c); // ERROR: CALL TO 'foo' IS AMBIGIOUS
c.x = 123; // ERROR: 'x' IS A PRIVATE MEMBER OF 'C'
}
>>
>>51419045
>only thing you lose is an advisory error
I don't see how this makes it non functional?
>>
>>51418668
this desu
>>
I miss RAII in Python. Memory usage blows up when you load sizeable datasets with numpy. it always returns new arrays instead of inplace modify.
>>
>>51418685
gross
Thread posts: 15
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.