Computation ----------- For some number N, first build a string of the form 1,2,...,N, (yes, there's a trailing comma!) Then print N, the total length of the string, the number of zeroes in the string and then the contents of the string, in single quotes. If N is 10, here's the expected output: N=10: 21 total chars, 1 zeroes, s: '1,2,3,4,5,6,7,8,9,10,' Benchmark Runs -------------- Case 1, N=1,000,000: % a2/run-bench 1 3 | python3 a2/bench-avg.py Java: 0m0.394s Python: 0m1.688s Java: 0m0.333s Python: 0m1.854s Java: 0m0.382s Python: 0m1.783s Java was 4.80x faster than Python (0.370s vs. 1.775s for 3 runs) Case 2, N=3,000,000: % a2/run-bench 2 3 | python3 a2/bench-avg.py Java: 0m0.471s Python: 0m5.256s Java: 0m0.497s Python: 0m5.317s Java: 0m0.553s Python: 0m5.247s Java was 10.40x faster than Python (0.507s vs. 5.273s for 3 runs) Case 3, N=7,000,000: % a2/run-bench 3 3 | python3 a2/bench-avg.py Java: 0m0.803s Python: 0m12.950s Java: 0m0.764s Python: 0m12.716s Java: 0m0.853s Python: 0m12.775s Java was 15.88x faster than Python (0.807s vs. 12.814s for 3 runs) Observations ------------ In my code there's a commented out line: `//s += i + ",";`. If that line is reinstated and the StringBuilder set aside, I found that with an N of only 100,000 the Java version is about 70, repeat 70 TIMES SLOWER than Python. If N is 200,000, the Java version is 150 times slower than the Python version. I was once on a consulting project with Howard Lewis Ship (howardlewisship.com). He's the creator of Apache Tapestry, among other things. With design in mind, he often said, "Make the easy thing right." I'd say that `s += ...` is surely the easy thing, but it is not "right", a violation of Howard's excellent maxim!