Thread: Programming!
View Single Post
Old March 2nd, 2013 (4:41 PM). Edited March 2nd, 2013 by Archenoth.
Archenoth's Avatar
Archenoth Archenoth is offline
The arch foe
    Join Date: Jan 2012
    Gender: Male
    Nature: Lonely
    Posts: 467
    Cool... Visual Basic is fantastic for hammering out really fast graphical programs... And Intellisense can really help you out with it's completions since the language is really simple.

    Originally Posted by twocows View Post
    One of my biggest personal pet peeves is this. Operator overloading is far too easy to abuse and the benefits are negligible. That's not to downplay any of the other major problems with C++, but this one takes the cake for me.

    Operator overloading's one of those things that sounds useful but really isn't
    The thing about that style of operator overloading is that C++ isn't the only language that has it, it's in other C-like languages as well. Java has "string" + "string" concatenation overloading for example, and the other overloads I saw mentioned are in C to begin with. (Like var++, or *pointer)

    DISCLAIMER: The following is merely my opinion... One we obviously don't share.

    The way I see it, provided you have good type handling or management, you can use overloaded operators in ways that are quite understandable and not horrible. It's all in how you present your code. For example, I can write C code that is non-obvious in it's operator usage too, consider the following:
    int i = 10;
    while(i --> 0) // While i goes to zero
      printf("%d\n", i);
    Know why this works? (Try to figure it out before clicking the spoiler.)
    This may make more sense:

    while(i-- > 0) // While i goes to zero
      printf("%d\n", i);

    Another example:
    result = value**count;
    That is multiplying "value" to the value that a pointer called "count" is pointing to. And not dereferencing a pointer to a pointer. Sure you probably knew that, but it is more readable to do the following:
    result = value * *count;
    The same applies for overloaded operators. For example, in JavaScript, if you saw the following code:
    string = "That " + name + " person is a cool guy";
    You could very easily determine that that was string concatenation in the same way where if you saw this:
    total = numGuests + numStaff;
    You could reasonably assume that it is arithmetic.

    Anything can be horrible if used horribly, but if you use the features you have available to your advantage, you can write good code in mostly anything with structure. You just need to write your code in a way that is intuitive.

    In the end, the things that are horrible to you end up coming down to your own preferences. I can respect that though.
    Reply With Quote