TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Go’s Type System Is An Embarrassment

109 pointsby mikeevansover 11 years ago

9 comments

colin_mccabeover 11 years ago
What&#x27;s embarrassing is that people are still evaluating programming languages like they were bags of features. The more features you stuff in the bag, the better it must be!<p>The reality is that generics aren&#x27;t free. They result in difficult-to-understand error messages and more cognitive complexity.<p>To quote Yossi Krenin, &quot;You may think it&#x27;s a StringToStringMap, but only until the tools enlighten you - it&#x27;s actually more of a... std::map&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::less&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt; &gt;&quot;<p>Of course, it would be nice to have generics, or something like them, for writing typesafe containers. But there are other goals in the language like fast compilation, easy-to-understand error messages, and overall simplicity. I hope they can come up with an implementation of generics that can keep those good properties of the language. But if they can&#x27;t, it shouldn&#x27;t be added just to get a feature bullet point. Use the right tool for the job.
评论 #7015928 未加载
评论 #7015902 未加载
评论 #7016275 未加载
评论 #7016656 未加载
nostrademonsover 11 years ago
My biggest beef with the Go typesystem is that they didn&#x27;t get rid of nil. Tony Hoare (the guy who invented null) has acknowledged they were his &quot;billion dollar mistake&quot; [1], common practice in Java and Haskell is moving away from them, and yet Go included them anyway - in a language that&#x27;s supposed to be robust because you&#x27;re supposed to handle every case. The Maybe (or @Nullable) type is a much better idea, because it flips the default from &quot;any variable may be null&quot; to &quot;only variables explicitly declared as such may be null&quot;.<p>[1] <a href="http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare" rel="nofollow">http:&#x2F;&#x2F;www.infoq.com&#x2F;presentations&#x2F;Null-References-The-Billi...</a>
评论 #7015956 未加载
评论 #7015977 未加载
评论 #7016102 未加载
frou_dhover 11 years ago
This masterclass in clickbait titling pulled in 735 comments and counting on &#x2F;r&#x2F;programming. Watch and learn, bloggers!
评论 #7015637 未加载
thinxerover 11 years ago
What&#x27;s wrong with leaking un-exported element? Your code wants it to be exported. If you care about it, please return an interface type.
评论 #7016245 未加载
vectorpushover 11 years ago
I love go, but my personal gripe with the type system is that there is no way to pass type information around without using a zero valued (or fully populated, it makes no difference) instance. For example, I have a factory struct with a New method that returns interface{MySignatures()}, but I cannot inform the factory of the concrete type I want it to produce without passing in something like new(ConcreteStructWithMySignatures). Some have suggested I pass in a string, but what is the point of a type system if I have to use strings to reason about my types?
kristianpover 11 years ago
Go is designed to be a small, simple language, it&#x27;s not hard to release that. If you want a fully featured type system, go program in Ocaml, Haskell or another &#x27;big&#x27; language.
评论 #7015979 未加载
评论 #7016634 未加载
评论 #7017646 未加载
letstryagainover 11 years ago
Are we complaining about generics again?
评论 #7015910 未加载
bsaulover 11 years ago
Type system power really is the only question i have left relative to go. I&#x27;ve always seen go being used for low level very technical stuff, where you don&#x27;t need lots of abstraction, but rather powerful primitives and libs. I&#x27;ve always wondered how it scales to business process modeling, and the lack of generics always worried me.<p>On another aspect, 2013 was the year of Go being unanimously praised, and i&#x27;ve got the feeling 2014 is going to be the year of the backlash.<p>Still, i don&#x27;t see any other languages able to take the crown back. Rust looks way too unpolished and has not only one but multiple pointer types.
评论 #7018847 未加载
评论 #7020944 未加载
评论 #7019995 未加载
puppetmaster3over 11 years ago
Are we trying to make Go into Java or JavaScript as it relates to dynamic or static?