6 ms·
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,
by pregnenolone 4mo 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.
- xigoi 4mo ago> 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;
- fragmede 4mo agoThe 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.
- xigoi 4mo ago> 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);
- bonesss 4mo ago> WTF is Z? Take a person, add a job, you get an Employee or EmployedPerson. Person.add(job). I agree overloading can create footguns, but domain concepts should make a lot of sense in context when basic arithmetic operations are performed on them. Party = Meeting + Booze. Custom operators are a big assistance for DSLs, and overloading can also aide their creation and elegance. Part of the “awesome but don’t be a jerk about it” toolbox.
- joe_mwangi 4mo agoJava’s planned approach is more like typeclass-style interfaces than unrestricted operator overloading. Types opt into core-defined operator contracts, rather than every library inventing arbitrary meanings for symbols.
- zardo 4mo agoYeah it's bad when it's abused, so don't abuse it. But not having operator overloading when dealing with vectors is maddening.