Why shouldn't I use Go?

agolangf · · 961 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I always see people asking why they should switch/use Go, but I would like to see your input on why one shouldn&#39;t use Go.</p> <p>I always see lack of generics as a hotly contested topic, but other than that what is there?</p> <p>And additionally, are there any other languages that aren&#39;t necessarily &#34;superior&#34; to Go, but don&#39;t possess it&#39;s shortcomings?</p> <hr/>**评论:**<br/><br/>mwholt: <pre><p>Don&#39;t use Go for writing GUI applications or rocket software. And yes, there are languages that have other strengths.</p></pre>Streamweaver66: <pre><p>Lots of reasons really. In no particular order:</p> <ul> <li> If you primarily do text processing, Go is fairly slow compared to other languages on this.</li> <li> If you need a simple MVC web framework. I get pushback on this every-time but I think Sanatra/Flash/Django are much better alternatives if you just need an MVC app.</li> <li> If you have to share code with team members or are a manager of a team that would have a hard time transitioning out of traditional OO design. </li> <li> If you want to create a desktop GUI based application. This is a weak spot for the language.</li> <li> If you&#39;re not prepared to adopt some of the more opinionated aspects of managing apps in the language. (Dependency management is one example, compile and store your dependencies is a pretty strongly opinionated position on Go&#39;s part, if this kind of thing puts you off, Go isn&#39;t a good choice.)</li> <li>If your use case would call for a lot of mature 3rd party libraries or maturity in the toolset, Go MAY not be for you but you&#39;d have to define your specific needs and do some research to see if this is an actual problem.</li> <li> If you need speed across the board. Go is improving but some aspects of the language are faster than others .</li> </ul> <p>Much of the complaining about Go I don&#39;t think is founded as it seems to center on expectations of patterns established by other languages that don&#39;t necessarily have inherent value. You mention Generics and that is one example of the kind of thing I mean.</p> <p>Overall you would be better served listing out what you need in terms of a language and doing some specific analysis of Go (and some other languages) to find a good fit.</p> <p>Good luck and let us know what direction you think you&#39;ll head. It would be helpful to get your thoughts on what specifically influenced you.</p></pre>FUZxxl: <pre><blockquote> <p>If you primarily do text processing, Go is fairly slow compared to other languages on this.</p> </blockquote> <p>How so?</p></pre>Streamweaver66: <pre><p>There are a couple of threads benchmarking CSV parsing and other text based parsing that shows this. There have been some threads here on it in face. Languages like Python perform much better in comparison when it comes to text. I do a good bit of NLP and over large corpus you can notice Go is a bit slower. </p> <p>In my own case I stuck with Go because I had to process large numbers of text files independently and the savings of you get through concurrency in Go made up for it being a bit slower in dealing with text. If you&#39;re use case is a single large body of text or they have to be processed serially then Go may not be the best fit.</p></pre>FUZxxl: <pre><p>Yeah, the CSV parser has problematic behaviour for broken input (e.g. input with missing closing quotes) and can use large memory in these cases. The authors are currently fixing this issue. One difference might also be that Go&#39;s CSV parser correctly deals with UTF-8 encoded text, I&#39;m not sure if Python&#39;s does.</p></pre>Streamweaver66: <pre><p>Python 2.x does not but Python 3.x does. Both run faster than Go. CSV was just one example, as another reply pointed out this problem goes deeper than just the CSV parser it extends to regex and other text processing aspects. I don&#39;t consider this a deal breaker for Go but text processing isn&#39;t it&#39;s strongest feature. </p> <p>In the real world you&#39;re only going to see this if you do very large amounts of text processing though so, as always, it depends on your use case.</p></pre>gohacker: <pre><p>Are you sure that the Python&#39;s CSV parsers aren&#39;t actually written in C/C++?</p> <blockquote> <p>Both run faster than Go.</p> </blockquote> <p>Benchmarks are welcome.</p></pre>Frenchiie: <pre><p>Not OP and I don&#39;t know if this is still true today but from what I read, Python and Ruby use C implementation for regex. Also Go uses a different algorithm that makes it so that in the worst case the regex will have a time complexity that is linear. Other implementations can have a worst case time complexity that is exponential. In the best or average case though it seems like the Python/Algorithm wins.</p></pre>Streamweaver66: <pre><p>Yes I&#39;ve found this in benchmark tests and in real world apps too. See my reply below that I still used Go since it&#39;s concurrency made up for the performance on text.</p></pre>iqandjoke: <pre><p>I have also tested the ported RE2 implementation named SRE2. The performance is worser than the Go built-in one if using substring match.</p></pre>FUZxxl: <pre><p>Go&#39;s regular expressions use DFA construction which guarantees linear runtime. There is some extra time needed to construct the DFA, but this time is consumed once at the time the regex is compiled. For most regular expressions, this is faster than the stuff Python uses (NFA simulation with backtracking).</p></pre>theGeekPirate: <pre><p>Python (and C#, as well as most other languages now I&#39;m sure) use the same algorithm as well these days.</p></pre>FUZxxl: <pre><p>I don&#39;t think Python&#39;s regices use DFA-construction for regular expressions.</p></pre>theGeekPirate: <pre><p>You&#39;re correct in that it doesn&#39;t use DFA, but it uses something very similar to DFA (more closely between both NFA and DFA) to achieve similar speed to DFA, while mitigating the downsides.</p></pre>FUZxxl: <pre><p>How can that be between a DFA and an NFA?</p></pre>theGeekPirate: <pre><p>I don&#39;t know enough about it, but feel free to read the code!</p></pre>ecmdome: <pre><blockquote> <ul> <li> If you have to share code with team members or are a manager of a team that would have a hard time transitioning out of traditional OO design. </li> </ul> </blockquote> <p>Huh? I&#39;m confused, are you saying don&#39;t use Go in this case? This is almost exactly what Go was designed for.</p></pre>IntellectualReserve: <pre><p>You&#39;re right that this isn&#39;t a language weakness as much as it is a human weakness. </p></pre>Streamweaver66: <pre><p>Yep definitely. I think trying to force Go on a coworker who can&#39;t or wont get it is the 8th circle of hell.</p></pre>Frenchiie: <pre><p>Yeah right? Pretty sure it even says so on the golang website.</p></pre>Streamweaver66: <pre><p>Sorry if I wasn&#39;t clear. I was saying you shouldn&#39;t use Go if you have to work on a team that has a hard time thinking outside the traditional OO patterns. Go can be confusing for people coming from traditional inherited OO languages. So if your team can&#39;t (or wont) put the time or effort into learning the Go way of doing things I wouldn&#39;t use it.</p></pre>Velovix: <pre><p>You probably shouldn&#39;t use Go for very small, embedded programs where the amount of memory or storage space you have is heavily restricted. Go produces comparatively large binaries and has a comparatively large runtime.</p></pre>FUZxxl: <pre><p>Go binaries are statically linked by the reference implementation. <code>gccgo</code> produces dynamically linked binaries with much smaller size.</p></pre>ecmdome: <pre><p>This is a good academic question to ask but it&#39;s a bit too broad. </p> <p>Should be why u should or shouldn&#39;t use go for specific use case scenario. Citing type of project, intended architecture, the type of team working on it (or single person project?), who will support it, is it open source or proprietary.... As well as many other variables can come into play when it comes to your choice in language IMO</p> <p>Edit: word</p></pre>Agent_HK-47: <pre><ul> <li><p>Web development project.</p></li> <li><p>Made just by me.</p></li> <li><p>Probably won&#39;t be open source</p></li> </ul> <p>If that helps.</p></pre>ecmdome: <pre><p>Are you looking for something that will handle templating for the frontend or a restful API to use with something like angular/backbone/&lt;insert js framework&gt;</p> <p>What&#39;s your previous experience? What is your goal, to learn as much as possible or to build something quickly and release it? </p></pre>Agent_HK-47: <pre><p>I would like to learn as much as possible, and it would be a REST API type application. </p></pre>ecmdome: <pre><p>Go does have templating but it doesn&#39;t seem too popular.</p> <p>I think with Go you will learn a hell of a lot more because it&#39;s not recommended to use a full ready framework ... Rather to use the standard library and piece together a framework from other components .... Also the ORMs available for Go aren&#39;t as solid as ones for python and ruby... You will have to do a lot of research on your own and look at other code, and this is why I think you will actually learn more.</p> <p>On the flipside you could use something like pyramid/django or rails/sinatra that will come with most of the components you need bundled in a nice framework... And if you aren&#39;t lazy you can read through the code and figure out what&#39;s happening (a lot of people don&#39;t).</p> <p>If you don&#39;t decide to go with go I would choose python over ruby just as a personal preference... My experience is limited to ruby on rails and it was too opinionated for me. </p></pre>Streamweaver66: <pre><p>That does help. There&#39;s still a lot to break down. I comes down to what experience you&#39;re looking for out of it and what features you need. </p> <p>As I said above consider frameworks like flask/sanatra. If you&#39;re looking for MEAN stack type work I actually think I prefer Go as a stand in for where ExpressJS and Node. </p> <p>We could philosophize about this for quiet some time so time for real advice.</p> <p>My advice is to start creating your site in a Go framework you find attractive (Gorilla, BeeGo, Revel, Martini, whatever). It&#39;s easy to get started so your investment is low, you&#39;ll know early on if this isn&#39;t the way you should be going and you&#39;ll get more knowledge of Go one way or another so you can&#39;t lose.</p></pre>albatr0s: <pre><p>You shouldn&#39;t not use Go.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

961 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传