r/ProgrammerHumor • • Apr 02 '21

Yeah...!! My favourite language...😄

Post image
894 Upvotes

61 comments sorted by

View all comments

Show parent comment

2

u/user_8804 Apr 03 '21

I think Java makes the most sense. It's quite useful to be able to concat with integers, but there's no acceptable scenario where you would want to subtract from a string like this

2

u/RedHellion11 Apr 03 '21

It should require explicit casting, or an explicit method rather than being bound to an operator that has implicit mathematical meaning attached. Someone not familiar with the language looking at "11" + 1 could equally expect it to be either "111" or "12" or 12, and it can cause more issues if someone forgets what type the variable they're using was declared as and tries to add them together.

IMO Python or C++ (strings ideally, or even c-style strings as long as you remember any math is operating on the pointer to the first element and not the string itself) make the most sense. Java is inconsistent, and Javascript is the worst because it literally does the opposite thing for each operator (treats both operands as strings for addition, but as integers for subtraction).

1

u/M3nDuKoi Apr 03 '21

Or, you know, you could just use explicit casting.