An interesting thread by Kristian Köhntopp last year:
[Archive.is] Kristian Köhntopp on Twitter: “Python: >>> print(1+2+” = “+2+1) Traceback (most recent call last): File “”, line 1, in TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’ Java: System.out.println(1+2+” = “+1+2); 3=12”
The examples from him and others in the thread:
Python: >>> print(1+2+" = "+2+1) Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'int' and 'str' Java: System.out.println(1+2+" = "+1+2); 3=12 php8.1 -r 'print 1+2+" = "+2+1;' PHP Fatal error: Uncaught TypeError: Unsupported operand types: int + string in Command line code:1 Stack trace: #0 {main} thrown in Command line code on line 1 php7.3 -r 'print 1+2+" = "+2+1;' PHP Warning: A non-numeric value encountered in Command line code on line 1 Node? Chrome & FF dev console: window.alert(1+2+" = "+1+2) 3 = 12 Sind ja immerhin verschiedene Sprachen. SELECT Wert1 FROM table1 WHERE Wert1 < AVG(Wert1); DB2 vs. Oracle vs. MSSQL vs. ....
The joke is that Python actually does better than Java.
But in practice, this is a problem on many platforms, so it deserves constant attention, that’s why Kristian pointed to [Archive] Anna “Legacy Archaeologist” Filina on Twitter: “My annotated slides “Fantastic Bugs and How to Avoid Them” from @LonghornPHP: #LonghornPHP”
[Wayback/Archive] Fantastic Bugs and How to Avoid Them – Speaker Deck
I’ve expanded the examples from the thread below. The results are interesting and consistent over versions of the various languages.
–jeroen