Re:Making a Go program 70% faster by avoiding common mistakes
by tetha on Thursday March 17, 2016 @04:51PM
(#11307503)
In my book, some people are taking the quote "Premature optimization is bad" too far. To me, there is a difference between optimization of some kind, and not writing dumb code. After some experience, bulk loading data in a batch job, avoiding high complexities if you can, trusting your frameworks is not part of smart optimizations - that's just writing proper code.
Optimization in todays world starts when you're looking at reducing communication volume, lock contention, utilizing your persistence better, replacing locks with atomic operations, ... Those things shouldn't be done on a whim without measurements, because they will make code a lot harder for non-obvious reasons.
Re:Making a Go program 70% faster by avoiding common mistakes
by Cthulhu_ on Thursday March 17, 2016 @11:30AM
(#11304935)
Yeah, I'd like to be in the 'not worry about such things' school of thought; personally I don't like the re-calling of methods all the time, because it doesn't look elegant, but in terms of performance it shouldn't matter - I'd like to think the compiler can do some optimizations there. Of course, the compiler may not realize or want to assume the result of the methods are the same for every loop. But still, it should be possible for it to infer that, and optimize this developer oversight.
Re:Making a Go program 70% faster by avoiding common mistakes
by JoeAltmaier on Thursday March 17, 2016 @11:54AM
(#11305138)
For instance if Itoa were a const method (is that a Go thing?) the compiler can make the optimization automatically.
Database requests, and really any IO, is never appropriate to use like this, I'm refering to stuff like itoa.
When you follow this principle, you end up with software that is exactly as performant as it needs to be (or whatever arbitrary standards were set).
I started following HN when I was a novice programmer, so I do appreciate seeing content appropriate for beginners.