On Mon, Apr 11, 2022 at 11:19 PM 'Jack Li' via golang-nuts <golang-nuts@googlegroups.com> wrote: > > Why Go provides only 2 built-in data structures, slice and map. It has just > more than C, but less than all other programming languages I've heard of, > C++, Python, Swift, Rust. > > I think this simplicity attracts me very much. Sometimes I can use only one > data structures for a task. Because there is no more similar data structures > for choice. It's really "one way to do one thing". This also makes code like > familiar and consistent. > > I want to know more about the mind behind this design of built-in data > structures.
The short answer is that in the early days of Go language features were added if several programs required them. Many programs needed slices and maps, so they were added to the language. Both types went through many permutations in the early days before settling into the versions we have today. Even very basic operations like "append" were added after the first release of Go. No other data structures came up nearly as often as slices and maps, so no others were added to the language. Now that generics are in the language, it will be easier for people to write their own general purpose data structures. We'll see what people come up with. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVcgKKoapCNuebfyk%2BkaXc3X2sn3h6K5eGGppi7TCdPPA%40mail.gmail.com.