← Back to context

Comment by pregnenolone

7 hours ago

Language design isn't just about adding every possible feature. For example, someone mentioned operator overloading. As someone who has written a lot of Scala, I think operator overloading would be a very bad feature for an enterprise language like Java which needs to be consistent above all else. I never understood the obsession some people have with the C# vs Java debate anyway. Generally, both languages are very good at what they do, each having its own set of advantages and disadvantages. Regardless, a developer can pick up the other language with basically no effort.

> I think operator overloading would be a very bad feature for an enterprise language like Java which needs to be consistent above all else.

Operator overloading increases consistency. Instead of having

  int a = b + c;
  CustomNumberType x = y.add(z);

you have

  int a = b + c;
  CustomNumberType x = y + z;

  • The problem with operator overloading is it makes things confusing when mixing types and let's programmers write confusing code.

        Person x;
        Job y;
        CustomType z = x + y;
    

    WTF is Z?

    Is the argument, anyway, I support operator overloading.

    • > WTF is Z?

      Hopefully a type error, because no sane programmer would implement addition like this. Obviously an insane programmer could, but that’s not the fault of operator overloading. The following code is exactly as confusing:

          Person x;
          Job y;
          CustomType z = add(x, y);

      2 replies →