All languages are like this. foreach() in PHP can be an order of magnitude slower than a standard for loop. C/C++ do all kinds of wacky things. The problem is that there is no money in language design. Most languages are either built by unpaid volunteers or companies that just see it as a cost center.
You want to here something really depressing? It's almost always quicker and more cost effective to throw hardware at performance problems than spend valuable dev time fixing them.
This is why open source software can be significantly better than commercial software. It is generally built by people who don't mind spending the extra time to do things right. The down side is that it takes longer to do things right. Software is always about tradeoffs. The more you understand the systems you have to work with, the better you will be at making the right choices.