Hacker News new | ask | show | jobs
by 430gj9j 4944 days ago
All languages have pitfalls. Including the author's beloved Java. For example:

   String x = "foo";
   String y = "foo";
   // Appears to work but compares references
   System.out.println(x[0] == x[1]);
There's no substitute for knowing your tools well.
2 comments

The difference is that languages can have more pitfalls, more severe pitfalls, pitfalls which are more difficult to detect, and so on.

I don't love Java, not by any stretch, but it's difficult to argue that Java and C++ are anywhere near equivalent in this dimension. Effective C++ is littered with examples of gotchas which are highly peculiar to C++ and the C++ compiler. It's an incredibly complex language.

Whether C++ worth these trade-offs for a particular team, project, or company is orthogonal.

I assume you meant to say:

    System.out.println(x == y);
Yes. In a previous version I was trying to bypass string caching to make x==y return false.