{"id":26367,"date":"2019-08-22T14:49:28","date_gmt":"2019-08-22T18:49:28","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=26367"},"modified":"2019-08-22T14:49:28","modified_gmt":"2019-08-22T18:49:28","slug":"why-generics-in-go","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/08\/22\/why-generics-in-go\/","title":{"rendered":"Why Generics in Go?"},"content":{"rendered":"<p><a href=\"https:\/\/blog.golang.org\/why-generics\">Ian Lance Taylor<\/a> (via <a href=\"https:\/\/news.ycombinator.com\/item?id=20576845\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/blog.golang.org\/why-generics\">\n<p>If we can write generic types, we can define new data structures, like these, that have the same type-checking advantages as [the built-in] slices and maps: the compiler can statically type-check the types of the values that they hold, and the values can be stored as themselves, not as interface types.<\/p>\n<p>It should also be possible to take algorithms like the ones mentioned earlier and apply them to generic data structures.<\/p>\n<p>[&#8230;]<\/p>\n<p>Most importantly, Go today is a simple language. Go programs are usually clear and easy to understand. A major part of our long process of exploring this space has been trying to understand how to add generics while preserving that clarity and simplicity. We need to find mechanisms that fit well into the existing language, without turning it into something quite different.<\/p>\n<p>[&#8230;]<\/p>\n<p>We are working on actual implementations to allow us to experiment with this design. It&rsquo;s important to be able to try out the design in practice, to make sure that we can write the kinds of programs we want to write.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Ian Lance Taylor (via Hacker News): If we can write generic types, we can define new data structures, like these, that have the same type-checking advantages as [the built-in] slices and maps: the compiler can statically type-check the types of the values that they hold, and the values can be stored as themselves, not as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2019-08-22T18:49:31Z","apple_news_api_id":"83dec234-130b-44e6-a0bd-d574f2a0118c","apple_news_api_modified_at":"2019-08-22T18:49:32Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/Ag97CNBMLROagvdV08qARjA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[846,46,71],"class_list":["post-26367","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-go-language","tag-languagedesign","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=26367"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26367\/revisions"}],"predecessor-version":[{"id":26368,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26367\/revisions\/26368"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=26367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=26367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=26367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}