2
头图

Recently, Rob Pike, one of the founders of the Go language, posted a comment on Github that attracted attention. It is reported that he has submitted an issue (#48918) in the Go code repository, opposing the introduction of generic support in the Go 1.18 standard library, and it is recommended not to change the standard library in Go 1.18.

Rob made the above recommendations are mainly two basis :

First, because the scope of the changes is too large, errors may occur. Rob said that version 1.18 of the Go language is likely to include the biggest change to the language since its creation-parameter polymorphism, commonly known as generics.

Although the language changes have been carried out in some form for more than ten years, the library changes are very new, and there is no experience and basis for designing and using new types for the time being. Of course, the Go language team has done a lot of work on this over the years.

There has been a lot of discussion about how the core library will adapt to other topics (for example, see #45955 and #48594, there are others, and they will definitely appear soon.)

The second is the lack of actual combat experience. Rob pointed out that how to use these generics in the standard library requires careful planning. If you put them in the library now, it will add a lot of burden to the release.

It can be tested in production, and changes, adjustments and developments can be made in one or two cycles, so that the entire community will try it out. Only after passing the test will they be transferred to the main repurchase agreement and enter the main warehouse. In other words, after one or two versions have been used in practice, and enough experience has been accumulated, it is not too late to consider updating the standard library.

In addition, due to the compatibility promise of generics, the cost of errors in any details is quite high. The Rob team waited, observed and learned first.

Therefore, Rob recommends not to modify the standard library in Go 1.18 for now. You can continue to design, build, test, and use new libraries for slices, textures, channels, etc. First, provide generic versions of related libraries at golang.org/x or golang.org/exp.

Finally, Rob advises: “I realize that everyone wants to have fun with new language features and look forward to solving some of the problems in the core library. Once these problems arise, they will become less clumsy, but I firmly believe that now It’s best to slow down. Use, learn, learn and act with caution.”


MissD
955 声望40 粉丝