I don't know why you are being downmodded. You are precisely on point - in Python (a slow language, similar to ruby), I'd often spend 50-500ms in the db (or 10-100ms in memcached) and 1-10ms in code.
Optimize your sql, then optimize your memcached.
That said, I've recently been working on a project building a webapp in Scala. The type safety Scala gives is amazing.
Want to write to master then read from a slave in the same http request [1]? Won't compile. Want to build a page without a tracking beacon? Won't compile. Want to prevent invalid input to enum fields (e.g., a string for which the only valid choices are "moderator", "subscriber" and "contributor")? Compiler has you covered.
[1] If you write to master then read from a slave, there is a nontrivial chance that the result of your write won't be mirrored to the slave.