

{"id":1177,"date":"2013-06-02T19:39:54","date_gmt":"2013-06-02T18:39:54","guid":{"rendered":"http:\/\/fabsk.eu\/blog\/?p=1177"},"modified":"2013-06-22T12:37:08","modified_gmt":"2013-06-22T11:37:08","slug":"golang-lack-of-generics-bothers-me","status":"publish","type":"post","link":"https:\/\/fabsk.eu\/blog\/2013\/06\/02\/golang-lack-of-generics-bothers-me\/","title":{"rendered":"Golang: lack of generics bothers me"},"content":{"rendered":"<p>I think I will give up Go, mainly because of the lack of generics. What bothers me is that I can&rsquo;t see how to write all-purpose algorithm functions like the ones C++ have (I love them), like for example \u00abstd::remove_if\u00bb. Without them, you will have to write the same little pieces of code again, and again, and again. Or use cast everywhere (not great for a language with strong static types).<br \/>\nThe built-in functions (like \u00abcopy\u00bb) can do such a magic, but you, developer, can&rsquo;t.<br \/>\nOh, it&rsquo;s possible to do like the package <a href=\"http:\/\/golang.org\/pkg\/sort\/\">sort<\/a>: provide to the function an interface that will perform the operations on the data (like \u00abSwap\u00bb, \u00abLen\u00bb, \u00abLess\u00bb). If I want to implement my \u00abremove_if\u00bb, implementing such an interface will be a drag.<br \/>\nSame problem if you want to create a generic data structure, like a \u00abset\u00bb or a b-tree of anything (interface or native type), and keep the type-safety.<\/p>\n<p>That&rsquo;s a pity, Go has some great features. Maybe I will try Rust.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I think I will give up Go, mainly because of the lack of generics. What bothers me is that I can&rsquo;t see how to write all-purpose algorithm functions like the ones C++ have (I love them), like for example \u00abstd::remove_if\u00bb. Without them, you will have to write the same little pieces of code again, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,25,6],"tags":[],"class_list":["post-1177","post","type-post","status-publish","format-standard","hentry","category-dev","category-golang","category-informatique"],"_links":{"self":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/1177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/comments?post=1177"}],"version-history":[{"count":10,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/1177\/revisions"}],"predecessor-version":[{"id":1192,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/1177\/revisions\/1192"}],"wp:attachment":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/media?parent=1177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/categories?post=1177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/tags?post=1177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}