Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

While not Go, in C# you can avoid a ton of heap allocations by using StringBuilder instead of concatenation, and the crossover point for one being more efficient than the other is at something like 4 concatenations. But people will always say nonsense about "premature optimization" the moment you care about performance.


In regards to Go, in most cases its a pointless optimization. Unless the string is quite large, its the same result. Go is nothing like C# in this case.


In python since 2.5 (and im sure other languages implemntations) the compiler/implementation recognize this += use case and implement it as a fast one.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: