Comment by callc
10 hours ago
You shouldn’t need a library to do this simple operation.
I’m guessing the go language design went too far into “simplicity” at the expense of reasonableness.
For example, we can make a “simpler” language by not supporting multiplication, just use addition and write your own!
The operation is simple in concept, but can be costly from a compute standpoint when n is large. Multiplication has predicable performance. Insert does not. It being a function indicates that it is doing a lot of things and thus offers pause to make sure that the operation is acceptably within your operational bounds.
It could have been a builtin function, I suppose, but why not place it in the standard library? It's not a foundational operation. If you look at the implementation, you'll notice it simply rolls up several foundation operations into one function. That is exactly the kind of thing you'd expect to find in a standard library.