top | item 28122025

(no title)

Ashanmaril | 4 years ago

I'm surprised mismatching parenthesis was a common mistake in 2016 given the ubiquity of IDEs and text editors that should catch a syntax error like that.

== vs .equals() is pretty understandable considering that it's Java specific, and would be valid in most(?) other languages

discuss

order

dave84|4 years ago

All of the code was written in BlueJ in 2013-2014, I have no idea if the versions of BlueJ in use at the time had the parenthesis matching feature.

PennRobotics|4 years ago

While == vs .equals() is a Java-specific issue, other languages suffer similar (and often more hidden) equality problems.

In C, you can have value equality or pointer equality. Then, you have the whole "either write your own character-by-character comparison or learn which libraries to include to compare strings". There's also the detail of remembering what strcmp() returns.

I might be wrong since Python is not my daily driver, but "a is b" and "a in b" and "a == b" and "a == b and type(a) == type(b)" are all distinct from one another.

Javascript has strict equality and equality.

marcosdumay|4 years ago

The reason people confuse "==" and ".equals" in Java is because they are confusing. In general, Java doesn't use the concept of pointers, and yet, one of its main operators does.

That language feature is simply broken, and this is really not the same situation of confusing "a == b" with "a in b" or "type(a) == type(b)". One can say that comparison with None is Python is broken too, but the situation is much better because you get an error if you make a mistake, instead of your program misbehaving.

Javascript, by the way, is way worse than Java here. In general the language does not differentiate a number from a string with a numeric value (something I imagine it copied from Perl), yet a lot of features do.

renox|4 years ago

In my experience IDE sucks for paranthensis/quote their autocompletion is awful because it only works well when you write new code not when you edit existing code..

And in VScode it isn't even possible to truly disable it!

chapium|4 years ago

There is also Objects.equals if you don’t want the ambiguity of “==“.

The main reason I find myself second guessing this one is if you get used to the convention of other languages and then switch over to java.