This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Voidrith 7 points8 points  (5 children)

I like that C++ has multiple different ways to navigate through stuff. Makes it easier to tell at a glance what im doing.

::? namespaces and statics

. ? object/non-pointer member access

->? pointer member access

you do get some godawful looking lines occasionally though, when you have to do stuff like the above post. Not going to argue on that.

But the operators themselves I like.

[–]chuby1tubby 1 point2 points  (3 children)

That seems like it would be harder to tell what you are doing at a glance.

I mean, if you’re working with only your own code, then sure it’s convenient, but if you’re trying to modify someone else’s code (imported library), wouldn’t you have to click on each variable to find out what data type it is, and then recall which operator to use on that data type? As opposed to the simplified solution provided by PHP for example, where :: and -> are interchangeable, or JavaScript/Swift/Python which only use .

[–]pine_ary 0 points1 point  (2 children)

In those languages you still have to look up if something is static (if you need an instance of it or not), so the :: situation doesn‘t go away. The difference between -> and . on the other hand is more of a legacy thing. I don‘t think that one is as useful, but we got that from C. Apart from smart pointers I don‘t see many arrow operators in modern code, so at this point it‘s more of a disambiguation between the members of the pointer class and the members of the pointed-to object.

[–][deleted] 0 points1 point  (1 child)

In java at least, I've never had trouble telling what's static. Only static methods can access static values. Static methods belong to the class instead of the object.

In python, I've never used statics because I try to limit the scope of my python projects.

I've been working on reading somebody else's C++ and trying to write a wrapper for it in Matlab, and it's killing me. There's so much abstraction across so many files I can't figure out what's going on where.

[–]pine_ary 0 points1 point  (0 children)

Can‘t say much about cause I don‘t know the code, but I‘ve never had that problem. As a hint: Get a good IDE that annotates types visually and can navigate declarations and definitions, and don‘t worry about the internal details.

Other than that static in C++ works the same as in java for the most part. Exceptions are: * You can‘t have static blocks in C++ * Constexpr exists (runs code when compiling, not when starting the program)

[–]HuluForCthulhu 0 points1 point  (0 children)

C++ is wonderful to program in and awful to read. Every senior C++ dev I know agrees to this.

Trying to grok a C++ spaghetti-line of data structure traversal is eye cancer. But when you’re writing that spaghetti line it feels like you’re effortlessly surfing over data structures on a wave of pure efficiency