Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I enjoyed this article; I learned several things (I didn't even know that "struct Employee : Person {" was valid syntax) and I can't argue with any of the factual content.

But this is a losing battle. "class" conveys intent to C++ programmers. There are lots of things that are needlessly complex in spoken languages (like do inanimate objects really need to be masculine or feminine?), but you can't just start speaking differently when the existing meaning is burned into people's brains.

As an example of existing convention, take the Google C++ Style Guide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.x...

    Use a struct only for passive objects that carry data;
    everything else is a class.

    The struct and class keywords behave almost identically
    in C++. We add our own semantic meanings to each
    keyword, so you should use the appropriate keyword for
    the data-type you're defining.


Agreed. In the literal sense they are very much two keywords for the same concept, but culturally, a struct is POD and a class is not.

Personally I think the mistake was in making them the same. In Ides, a friend's LLVM-based PL (no contributions here, just some discussion and ideas), an instantiated 'struct' is a non-polymorphic object rather like in C#; this allows for more expressive code by logically attaching methods to the struct but without creating a vtable and breaking C compatibility.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: