Hacker News new | ask | show | jobs
by kjksf 1764 days ago
You can find things to complain in any language, including the languages that YOU use.

For every complain like that in Go I'll find a hundred in C++, ten in Java / JavaScript / Python.

As to your question, as a full-time Go programmer: this doesn't come up often.

When it does, I google "slice tricks" and copy & paste the formula.

It'll be fixed by next release because generics will enable writing a function that does that and that function will be in standard library.

Why wasn't this fixed before generics? Because the only way to do it would be via a compiler built-in function and Go team is rightfully reluctant to bloat the language / compiler for minor functionality like that.

1 comments

Oof, I have no desire to spark a language war. Every language has its warts for sure.

It seems strange to not provide slice.erase as a primitive operation, and instead to recommend implementing it in terms of append. Usually removing from a vector does not require allocation. Still it may be for the best with upcoming generics, fewer builtins is good.