Comments on HN/Quora/Blogs keep saying Haskell run circles around golang. Why?

agolangf · · 596 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<ul> <li><a href="https://github.com/ksimka/go-is-not-good" rel="nofollow">https://github.com/ksimka/go-is-not-good</a></li> <li><a href="http://jozefg.bitbucket.org/posts/2013-08-23-leaving-go.html" rel="nofollow">http://jozefg.bitbucket.org/posts/2013-08-23-leaving-go.html</a></li> <li><a href="http://yager.io/programming/go.html" rel="nofollow">http://yager.io/programming/go.html</a></li> </ul> <p>Consistently over the years, here and various other places, I&#39;ve seen golang spoken as having an inefficient type system, and that FP languages like Haskell and Scala are wholly superior since they preserve safety. So it appears from heresay they are actually better for big codebases, but I&#39;m struggling to find examples that are readable and a lot of them break when I build them...</p> <p>I do admit, its difficult for me coming from C#, but our whole team is wickedly confused by how types scale over the long term.</p> <p>I am leading 4 other engineers and looking for some feedback for people on golang projects older than a year. Is it inherently flawed like all the FUD thats out there? Why are people leaving go for haskell?</p> <hr/>**评论:**<br/><br/>TheMerovius: <pre><blockquote> <p>Consistently over the years, here and various other places, I&#39;ve seen golang spoken as having an inefficient type system</p> </blockquote> <p>&#34;inefficient&#34; is completely the wrong term. I would wholeheartedly agree with &#34;weaker&#34; and possible also with &#34;effective&#34;, but if anything I would claim that a weaker type system is more efficient (as in, it allows you to program quicker).</p> <blockquote> <p>and that FP languages like Haskell and Scala are wholly superior since they preserve safety</p> </blockquote> <p>This is a logical fallacy: You assume that type safety is the only relevant axis on which to evaluate a programming language. I strongly disagree with that premise. If that was the case, there would be actually existing agda programs, as it has an even stronger type system.</p> <blockquote> <p>So it appears from heresay they are actually better for big codebases</p> </blockquote> <p>This has an even stronger (false) assumption: That a strong type system is the only thing that determines how suitable a language is for <em>large codebases</em>. I very much disagree. It might be around third on my list of criteria (if I had such a list).</p> <blockquote> <p>but I&#39;m struggling to find examples that are readable</p> </blockquote> <p>And that is exactly one of the other axes that determines how suitable a language is for large codebases, or how &#34;good&#34; it is. Readability. Another is productivity -- to be suitable for large codebases, codebases first need to be able to get large. And for that, programmers need to be able to get things done. Stronger type-systems usually stand in the way.</p> <blockquote> <p>Why are people leaving go for haskell?</p> </blockquote> <p>Because they overemphasize one criterion when choosing a language. go is very much a balancing language: It has a strong typesystem, but not <em>so</em> strong that it gets in the way. It tries to be productive, but doesn&#39;t sacrifice readability in the process. It tries to be fast and efficient, but not at the cost of memory safety; which, on the other hand, it partly sacrifices for productivity and readability by not preventing races.</p> <p>go is an engineering language. It doesn&#39;t try to be pure or optimize for one usecase. It tries to find a good tradeoff between all axes to get to a good language for large systems.</p></pre>drvd: <pre><p>That is a fine and well-balanced comparison! Thanks!</p></pre>dankcode: <pre><p>To quote the zen of python &#34;practicality beats purity&#34;. A lot of people tout the virtues of Haskell and Scala because they&#39;re &#34;Purely Functional&#34;. I think most of the go hate from these other systems language users is due to the fact that go is much easier to learn and use. It has eaten up quite a bit of the market share from these other languages &amp; people who already invested time in learning them are pissed.</p> <p>It is also true that go isn&#39;t nearly as optimized as these other languages. I think some of the criticism around channel, interface and typing performance are valid, but these issues will no-doubt be improved upon in newer versions of the language. Haskell has been available to the public for 5 times longer than go so it definitely has had time to iron out most of it&#39;s kinks. Scala is still largely dependent on the JVM to work so they&#39;ve shoehorned 25 years of research and dev time into their language so of course it&#39;s more robust. What&#39;s probably most interesting is that Go is the only popular language implemented in some time that doesn&#39;t rely on c, c++ or the jvm for it&#39;s implementation. </p> <p>This sort of debate isn&#39;t new. Every time a new disruptive language emerges there is no end of people willing to start a holy war over it. We&#39;ve seen this with c, c#, c++ and Java it&#39;s also happened with PHP, Ruby, Perl, Python and Node. Engineers constantly have pressure to learn new stuff and we&#39;re dumb and territorial just like anyone else. In the end all of these languages are valid choices to use in production and will likely continue to be so (well except Perl. Fuck Perl.).</p> <p>My advice: Try Go, it&#39;s easy to learn and really simple &amp; then if it&#39;s not working for you switch to something else.</p></pre>quiI: <pre><p>FWIW I have written quite a lot of Go (~18 months part-time) but a lot more Scala (~5 years) and I can honestly say I enjoy both and as many have said it&#39;s all about trade-offs. </p> <p>In languages like Scala you can push a lot more errors to the compiler and can model domains far more expressively than you can in Go. If you get the modelling right you get very easy to understand code that almost writes itself. </p> <p>But it&#39;s not a free lunch. Scala has a lot of accidental complexity because it&#39;s a <em>really</em> big language so two developers can solve a problem in completely different ways. If you dont have a disciplined engineering team that communicates really well you can quickly run into a mess. </p> <p>Go on the other hand is pretty opinionated, easy to pick up and the standard library can get you really far. It has plenty of tooling to ensure consistency in a code-base. That&#39;s not to say its not possible to make a mess. But the stability and simplicity of the language mitigates that risk hugely. You will run into situations however where the type system will let you down and you end up either duplicating code or having functions with <code>interface</code> which can be pretty bad.</p></pre>rco8786: <pre><p>Golang vs Haskell/Scala is apples to oranges. The latter are highly functional languages with incredibly powerful type systems. The former is an imperative language with a simple/easy to use type system.</p> <p>I&#39;m quite certain that for every blog post you find about someone leaving Go, you can find another for someone leaving Scala/Haskell.</p> <p>I wouldn&#39;t worry about it too much.</p> <blockquote> <p>its difficult for me coming from C#, but our whole team is wickedly confused by how types scale over the long term.</p> </blockquote> <p>This I don&#39;t understand. C# is strongly typed, and is much closer to Scala&#39;s type system than Go&#39;s. If you understand how C# scales into large projects, then you almost inherently understand how Scala does as well.</p></pre>xiaq: <pre><p>Type system is still an unsolved problem in programming language design. It is like the state of structured programming in the 1950s. Today we all agree that a decent programming language should have functions and control structures like &#34;if&#34; and &#34;while&#34;, but there wasn&#39;t a consent back then.</p> <p>More elaborate type systems catch more bugs at compile time, but they also tend to be harder to reason about. They can also be too restricted at times and you have to work around it. (I omitted verbosity, because that is mostly solved by type inference.) The very reason we have dynamically typed languages is that people got fed up wrestling with static type systems and would rather throw it away along with all its benefits.</p> <p>It is good that there seems to be a renaissance of static typing systems in the recent years, but you don&#39;t have to feel bad because go&#39;s static type system is not expressive enough. Type systems are as good as how programmers can use them. The experience of ordinary programmers is the ultimate judge of which type systems are better.</p></pre>haskell_oxford: <pre><p>Haskell is useful for writing <strong>robust, high quality and reliable software</strong>. You can write the same stuff in any other language. But Haskell is designed based on <strong>solid mathematical principles</strong>. It is statically typed which allows the compiler to detect certain classes of <strong>bugs</strong> which are impossible for compilers for C++, Java, Python etc. to detect. Haskell compiler can also perform <strong>optimizations</strong> which cannot be performed for other mainstream languages. Haskell focuses on <strong>modularity and composability</strong> by virtue of pure functions with no state changes. Code with state changes is neatly separated from code without state changes, allowing you to zero in easily, onto the bugs. </p> <p>Its a truism in the Haskell community that <strong>if your code compiles, then it will do what you want it to do.</strong></p> <p>Golang is great for <strong>beginners</strong>, but if you have <strong>smarter people</strong> on your team, you may as well just take the plunge and go pure FP. Facebook is using Haskell now and its <a href="https://wiki.haskell.org/Haskell_in_industry" rel="nofollow">ready for industry</a>.</p></pre>kjk: <pre><p>Now that we know the theory, how about you tell us how many robust, high quality and reliable software products did YOU write in Haskell.</p> <p>I ask, because as a beginner, my Go accomplishments are embarrassingly modest:</p> <ul> <li>a note-taking application (<a href="https://quicknotes.io/" rel="nofollow">https://quicknotes.io/</a>)</li> <li>database management GUI (<a href="https://dbheroapp.com/gui-database-client-for-mysql-postgresql-mac-osx" rel="nofollow">https://dbheroapp.com/gui-database-client-for-mysql-postgresql-mac-osx</a>)</li> <li>a software translation editor (<a href="http://www.apptranslator.org/" rel="nofollow">http://www.apptranslator.org/</a>)</li> <li>a blog engine (<a href="http://blog.kowalczyk.info/" rel="nofollow">http://blog.kowalczyk.info/</a>)</li> <li>a forum software (<a href="http://forums.fofou.org/sumatrapdf" rel="nofollow">http://forums.fofou.org/sumatrapdf</a>)</li> </ul> <p>I&#39;m sure by using Haskell you&#39;ve accomplished twice as much in half the time. I just want to bask in the glory of your (and Haskell&#39;s) awesomeness so I humbly request that you show me the great Haskell software you wrote.</p></pre>haskell_oxford: <pre><p>You have to be kidding me. What is <em>that</em>?</p> <p>A bunch of little websites. Facebook already uses Haskell.</p> <p>Golang is great for beginners and kids who want to build cute games, but for <strong>industry</strong> you want something that has <strong>compostability and modularity</strong> that is <strong>highly readable</strong>.</p> <p>Its not just that, it may take a little longer to write Haskell, but the compiler can do thing in that golang&#39;s definitely can&#39;t! All those types add safety, as well as strategies the compiler can use to build a <strong>more efficient</strong> program for <strong>highly reliable, mission critical environments</strong>.</p> <p>So sure, for you little hobby projects, go have fun. But if we&#39;re going to Mars - we&#39;ll be writing that flight computer in Haskell 2014, we don&#39;t want to risk it on a toy language with a gopher.</p></pre>kjk: <pre><p>So, still can&#39;t show a single program in Haskell that YOU wrote?</p> <p>Not even a tiny, teeny, hobby one?</p> <p>One program, however insignificant, it&#39;s really all I&#39;m asking for.</p> <p>Should I aim lower? Can you show me a single line of Haskell that you wrote?</p></pre>ar1819: <pre><p>You know that you talking with troll, right? When they use both</p> <blockquote> <p>highly readable Haskell</p> </blockquote> <p>you already know that person has no idea about what he\she is talking about. Or they throw too much sarcasm at it.</p> <p>Haskell mostly proves that your program is race free \ leak free \ bound&#39;s checked. From logical and architecture view it still pretty much the same cycle of writing and testing. </p></pre>stackmutt: <pre><p>I was just waiting on an explanation of <em>compostability</em>... I&#39;m sure this year&#39;s veggie garden would love it some functional goodness, nom nom nom+</p></pre>bonekeeper: <pre><p>So, let&#39;s see:</p> <blockquote> <p>Facebook already uses Haskell</p> </blockquote> <p>Good - it also uses <a href="http://www.drdobbs.com/mobile/facebook-adopts-d-language/240162694" rel="nofollow">D</a>, <a href="https://code.facebook.com/posts/264544830379293/hack-a-new-programming-language-for-hhvm/" rel="nofollow">PHP/Hack</a> and I&#39;m sure many others like Perl, C, C++. Oh, and they also use <a href="https://github.com/facebookgo" rel="nofollow">Go</a>.</p> <blockquote> <p>but for industry you want something that has compostability and modularity that is highly readable</p> </blockquote> <p>Google is larger than Facebook and they not only use Go but they created it in the first place to deal with those issues.</p> <blockquote> <p>But if we&#39;re going to Mars - we&#39;ll be writing that flight computer in Haskell 2014, we don&#39;t want to risk it on a toy language with a gopher.</p> </blockquote> <p>No, it will be written in <a href="http://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf" rel="nofollow">plain ANSI C</a>, not even C++, let alone Haskell. Also, as others mentioned, SpaceX is <a href="https://www.reddit.com/r/golang/comments/3pu3nl/spacex_is_using_go_for_its_telemetry_system/" rel="nofollow">using Go for their telemetry system</a>. Even one of their <a href="http://www.spacex.com/careers/position/8711" rel="nofollow">open positions</a> lists Go as a preferred skill. Apparently they haven&#39;t migrated things to Haskell yet... but anytime soon, cross your fingers!</p></pre>j_heg: <pre><blockquote> <p>No, it will be written in plain ANSI C, not even C++, let alone Haskell.</p> </blockquote> <p>Even worse for him...if I recall correctly, the Orion people said they were using lots of code autogenerated from Simulink. ;)</p></pre>dlsniper: <pre><p>You should tell SpaceX to stop using Go. And I&#39;d be really happy to hear more about these mission critical systems built in Haskell. Oh and btw, Facebook uses PHP (or Hack) and probably there&#39;s a bit of every language out there. Does that mean that every language out there is production ready then?</p></pre>mixedCase_: <pre><blockquote> <p>Golang is great for beginners and kids who want to build cute games, but for industry you want something that has compostability and modularity that is highly readable.</p> </blockquote> <p>I&#39;ll let the YouTube division, Dropbox, Baidu, Uber and many others know about your hot engineering experience, Mr. Academic.</p></pre>abcded1234234: <pre><p>Out of curiosity what are these &#34;certain classes of bugs which are impossible for compilers for C++, Java, Python etc. to detect&#34; and &#34;optimizations which cannot be performed for other mainstream languages&#34;?</p></pre>

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

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