This issue touches Go and C# so the comparison would deal with current implementations -- I am rather looking for theoretical evidence, something like quick sort in worst case performance is...
In many places dedicated to Go I saw a function that returns a tuple, with last element being an error code. In C# it is rather
TryXXX pattern with last
Now I wonder which one is better performer (once again, from theoretical standpoint -- meaning if you could implement it at best, what would be the outcome).
Maybe naive thinking, but with tuple approach I see memory allocation problem, you have to do it each time the function is called, no matter what. With
out parameter you allocate memory outside the function, so then even if you call a function millions times, the cost is zero (well, except for copying some data).
out then should be a better performer, correct? Or is there some way to implement tuple passing to match
out? Or am I completely wrong?