Go or Python -- which one is my main language for the next 5 to 10 years?

xuanbao · · 452 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>It&#39;s that time of the year again to let loose the one question which is simmering in millions of people&#39;s minds. I would like to choose Go or Python to devote my free time to learning it. </p> <p>Python is appealing deservedly for all the usual reasons. I like Go because of its static typing, performance and deployment story, among many things.</p> <p>I am well-versed in Java/PHP, familiar with Python, and can work with C/Ruby/JS if allowed to cheat (google around to steal code, etc.).</p> <p>My future projects will be in the business application side, mainly your typical old-fashioned backends (ecommerce, social networks, etc.); data/file processing (large amount but probably not in petabyte range); and mobile apps (simple ones such as online store app, no games).</p> <p>For my specific needs, which one will serve me better in the next 5 to 10 years? I know developing mobile apps is tricky for both of them at the moment. No flame war please, they are both excellent languages, use the right tool for the job, and all that. Thanks in advance.</p> <hr/>**评论:**<br/><br/>earthboundkid: <pre><p>Learn more languages. Don&#39;t be lazy. No one ever got a job for knowing one fewer language. </p></pre>thomasfr: <pre><p>I will safely put both in my group of main languages for the coming years. To me choice of language(s) should be made on a per project requiremetns basis.</p></pre>__crackers__: <pre><p>I got into Go because Python 3 has been a clusterfuck.</p> <p>It didn&#39;t fix the issues it was supposed to but rather replaced them with different, harder to fix ones. It did almost nothing to &#34;modernise&#34; Python.</p> <p>Fundamentally, Python is stuck in the &#39;90s. It&#39;s hopeless at concurrency and cannot make good use of today&#39;s multicore processors. It still defaults to ASCII, instead of UTF-8 like sane modern languages.</p> <p>It&#39;s still a great language, but the core Python developers have made clear that the GIL (which prevents concurrency) isn&#39;t going away, so I can only see Python&#39;s relevance falling with time.</p></pre>victrolla: <pre><p>These posts bug me. You&#39;re comparing two completely different things. Your asking a Go sub if we recommend Python? Sounds to me like you made your decision. </p> <p>Some things to consider </p> <ul> <li>the Python community is a nightmare. Every time I&#39;ve had to interact with community support I&#39;ve regretted it immediately. The Go community has been helpful friendly and welcoming. </li> <li>Python doesn&#39;t do parallelism or concurrency. Sure you have threads and some sort of weird fork pic helpers but it&#39;s usually a rabbit hole of problems. Sure Python3 has a sync but the language can&#39;t seem to progress beyond Python2. That should tell you something. Sure you have gevent but that&#39;s also bug town. </li> <li>having mentioned concurrency. If you want to make high performance web applications, Python is an extremely bad choice. What you gain in simplicity you lose when you realize you&#39;ve bet the horse on a language that can&#39;t keep up with demand. </li> <li>the Python index is a pool of unstable code rot. </li> <li>virtual environments. Fuck them. </li> <li>it&#39;s not until you&#39;re writing statically typed code that you realize how often you&#39;re fielding Python exceptions related to &#39;None&#39; bugs. </li> <li>I used to think pythons class mechanics where amazing. Once I learned them a bit better I started abusing metaclass in a way that was fun at first but ended horribly. Go interfaces have so much power. At first I was repelled by interfaces but once I began to actually use them my outlook changed completely. </li> </ul> <p>I could go on but I don&#39;t want to just make a giant negative list. Python is a toy. I spent the last year being responsible for a high traffic rest API written in Python. Every day the answer was rewrite some crappy component. For me the eye opener was when io undo myself writing backend services in Go to take the strain off the Python app. So from this point forward, I&#39;m sticking with Go. </p></pre>cathalgarvey: <pre><p>Interesting, I&#39;ve had totally the opposite community experience, but that could be just this sub. I can see how Pythonistas would object to your attitude if you call Python a &#34;toy&#34; though. It&#39;s ome of the most important &#34;toys&#34; outbthere if you consider machine learning, text mining, data science, not to mention its incredible role in encouraging new programmers. Calling it a &#34;toy&#34; sounds like sour grapes, TBH.</p></pre>victrolla: <pre><p>I think I wrote this on mobile very late and possibly sounded a bit more harsh than I had intended. Regarding the community experience, I find that Python has reached a critical mass where bureaucracy takes hold. I think it&#39;s just different personality types between the communities. I deeply admire the Go communities ability to cut through the human component and focus on very low level problems. </p> <p>Conversely, I find the python community to be very SJW. The last time I was looking for help on freenode, I found out that they have a bot who&#39;s purpose is to harass you in msg if you type &#39;lol&#39;. Apparently, the string &#39;lol&#39; in any context is somehow in opposition to their code of conduct. I&#39;ve never been reprimanded for appending &#39;lol&#39; to an on topic sentence. </p> <p>Perhaps &#39;toy&#39; has a negative connotation. I personally didn&#39;t mean it to sound so harsh. The reality is Python has emerged as a leader for &#39;scientific&#39; computing. This doesn&#39;t make it the most suitable language for solving computationally complex problems. It makes it the most suitable for becoming involved in data science. Python has an amazing ability to lower the barrier of entry for programmers of all skill levels working in areas that are new to them. </p> <p>RE: community, what I find truly important about engineering; Go suits me very well. Perhaps I&#39;ve had great interactions in the Go community because the folks I&#39;ve interacted with are like minded. </p> <p>RE: Toy. Harsh language, probably not the best choice. Go is undeniably more performant than python for a variety of work loads. Python has very different strengths than Go. </p></pre>mundanevoice: <pre><p>I don&#39;t know how you reached these conclusions.</p> <ul> <li><p>Python community is one of the most helpful around. </p></li> <li><p>Python 3.5 is gaining good traction and a lot of important projects have expressed support for only Python3.</p></li> <li><p>Concurrency is not the only thing you do when you write a webservice and with improvements in async it&#39;s not that bad either.</p></li> <li><p>High performance applications? I guess you are unaware that many high performance apps (instagram, pinterest etc.) are written on Python. The thing is if you write shit code in any language performance will suffer. Mostly the bottleneck is the person is himself.</p></li> <li><p>Python Index has many useful libraries and mostly very high quality. </p></li> <li><p>Virtual environments are great running applications with different dependencies. Let me know how could you isolate different version of golang on same machine in a saner way that is not overly complex.</p></li> <li><p>Not sure if you know, type hints have also made it&#39;s way to Python-3.5.2 and also available to Python2 via typings modules. It does add great support for writing more type correct code. It also makes IDE integration much better and refactoring easy.</p></li> <li><p>Metaclasses are great and so are interfaces but if you abuse then you are going to bite dust.</p></li> <li><p>I have personally written high traffic API that has been running pretty nicely and scaling as we grow. It totally depends upon how your architecture is, how your DB queries are. If you are writing Pythonic code which is performant or not. Just because you didn&#39;t wrote it well enough doesn&#39;t mean it is not possible to write good performing APIs in Python.</p></li> </ul> <p>Golang is good language and has it own strengths and use cases where it shines. So when you criticize a language, give good solid reasons not some biased bullshit that has no base. </p></pre>victrolla: <pre><p>I don&#39;t want to repeat myself but I did a more direct reply a few comments up. TL/DR; I basically just mashed the keyboard late on a mobile and my reply perhaps reads more harshly than my intent. It was not my intention to upset a bunch of people. </p> <ul> <li><p>My interactions with the Python community have been largely stifled by community guidelines that I find overbearing. The keyword &#39;lol&#39; is a forbidden word in python support channels. Freenode has a bot dedicated to harassing you each time you use the word &#39;lol&#39;. I don&#39;t find censorship and control of free speach helpful in any way. </p></li> <li><p>Python 3 is not gaining good traction. I think you may be overlooking the fact that it was released 8 years ago. Go 1.7 has been out for 2 days and there are companies who have been running it in production for months already. Further, as of today, I&#39;ve upgraded my companies code base to Go 1.7. Number of lines changed in order to upgrade? 0! In my adventures as an engineer, these types of facts are critical to making sound technical decisions. </p></li> <li><p>Concurrency is the ONLY thing you do when you write a webservice. Before the request flow reaches you the developers handlers, you are going through a great deal of concurrency oriented code. In any language, especially python, the form/function/speed of your controllers is inconsequential if it is bottle necked by the upstreams ability to handle socket IO. If you bench mark a Go app against any python app fronted by gunicorn, uwsgi, tornado, or raw gevent; Go will win every time (I&#39;m guessing uwsgi is the only contender). This type of assertion holds true throughout the entire request cycle. There is a large degree of complexity in Python applications around non-blocking IO for things like DB drivers to service web requests. Simply put, the fact that the time to market is quicker with python due to it&#39;s syntax, does not make it superior to more modern languages. It just makes it different. </p></li> <li><p>Instagram, pinterest etc have become polyglot&#39;s in recent years. I find that Instagram is a particular point of pride for the Python community. Undeniably, Instagram serves a lot of traffic; but there is actually very little computation complexity in Instagram outside of image processing and database IO. You are confusing their massive horizontal scale with programatic speed. Conversely there are a litany of public companies like Iron IO, that are able to perform extremely computationally expensive operations at scale in a fraction of the infrastructure footprint of Instagram. Whats further, many of the things Instagram has pioneered are now not really considered normal or best practices. A very good example of this is Instagrams old blog posts describing their implementation of &#39;RedisHash&#39; to make their caching layers more efficient. Today, this is pretty uncommon. IMHO, Instagram contributed much more to the startup community with the way they implemented data sharding within postgresql. At the time, the only company we knew of that was operating this way at scale was Facebook and Youtube. </p></li> <li><p>Python index suffered a catastrophic outage 2 nights ago. It is a critical point of failure for the entire ecosystem. Further, the python index suffers from a high degree of code rott. Sure, theres great modules there! Thats not up for debate at all. But it suffers from a myriad of issues from naming conflicts to dependency resolution challenges. The ironic thing to me has always been that the truly excellent modules in the python ecosystem are little more than C FFI&#39;s. Please evaluate your requirements.txt file very carefully. Speaking to a cassandra DB? Blist, a C module is recommended. Want to operate on data frames easily? You guessed it, low level language under the hood. I hope this reminds many interpreted language developers that <em>we</em> are all standing on the shoulders of giants. </p></li> <li><p>Virtual environments are an absolute nightmare. Virtual environments have an extreme burden on portability and build time. They are error prone, and they rely on a lot of dirty mechanics under the hood like stripping bang lines from entry_point&#39;s and replacing them with the virtualenv&#39;s interpreter. For a code base the size of instagram or pinterest, the deploy time footprint is likely in the neighborhood of half a gig. Instead of having one artifact to deploy, you now have hundreds or thousands. Virtualenv is not a convenience it is a necessity. It was a band aid to painful dependency management, and a band aid to include path collisions for systems rendered unusable when python 2 and python3 are installed in tandem. Yum and apparmor suffer from a LOT of bugs due to these issues. Further, there are literally hundreds of attempts to solve these problems. The only mildly successful one is pex. The rest is a cludge. Check out dh-virtualenv if you ever want to regret liking virtualenvs. As a last point, think about a code base implemented as a series of microservices. What happens when their requirements deviate? You&#39;ll likely say switch between virtualenv&#39;s etc. Cool! Now multiply the development team by 20 and bugs emerge because of the logistical complexity associated with virtualenvs. To answer your clearly sarcastic question about equivalent behavior in Go, the answer is to repoint $GOPATH to the directory containing the version you&#39;d like. For comparison, virtualenv is manipulating several more env vars (including PS1... wtf), AND rewriting pieces of pythons site config to play nicely. Why does it do this? The C api behind python is complex and inconsistent. </p></li> <li><p>Type hints are not the same as static typing. This counter point is nonsense. Under the hood, the way python types are implemented are somewhat flawed IMHO. Overall I think this typing module will have a very positive impact on the python community, if anything just to make developers more aware of types. Side note, there is a very long list of python type hacks out there. Things you can do to trick the interpreter into doing what you want. I&#39;ve come to view these hacks as a waste of time. If the language allows you to express a type, you become more productive because you stop spending a bunch of time validating inputs. </p></li> <li><p>Metaclasses are interesting. Granted they are capable of strange and interesting things, their practical use is usually around implementing interfaces. Go has accomplished this in a much more straight forward way. </p></li> <li><p>Congratulations on your successful API. I&#39;m willing to bet we have VERY different ideas of what constitutes high traffic. If you feel that my responses are unfair or inaccurate, I&#39;d love for you to send me some raw stack frames from sys.signal and I&#39;ll gladly produce a flame graph we can review together. What you will find is your high traffic python API is likely spending a lot of time on CPU doing things that are seemingly innocent in python. For example, use of deep clone is rampant in python web code. What occurs is extreme waste of resources. </p></li> </ul></pre>mundanevoice: <pre><p>Some pretty good points I must agree. However:</p> <ul> <li><p>You are right about censorship but thing from their perspective, it is much bigger community and banning certain keywords does help in filtering out crap. </p></li> <li><p>I am not overlooking the fact that Python-3 has been for 8 years but you got to understand that it has a legacy of a very successful Python-2 behind and there are breaking API changes. Go has not reached that stage yet, Wait till we reach Go 2.0 if there is any coming and then it might be fair to compare.</p></li> <li><p>For me instragram or any other site is not a point of pride but validation of a pretty fine language. Even the platform you are righting this on is written on Python(web.py) and been pretty successful in handling a lot of traffic. Also, as you are a web engineer too, you must be aware that outages doesn&#39;t always happen because of a language but there are many factors like DB, caching, routing gone bad.</p></li> <li><p>Package management is really not that great in Golang either if there is any. It mostly depends on github for that packages. But what happens when Github goes down, which it does quite often. Also, how about no support of tagging of package. You use master of a repo and the the owner does a breaking change. Unless you keep all that code in your source code you are up for a shock. </p></li> <li><p>If types would make everything so awesome magically everybody should be using Haskell, but they don&#39;t.</p></li> </ul></pre>knotdjb: <pre><blockquote> <p>Check out dh-virtualenv if you ever want to regret liking virtualenvs. </p> </blockquote> <p>I would say dh-virtualenv actually makes debian packaging sane despite the hacky way it goes about things.</p></pre>knotdjb: <pre><p>Your gripes are pretty close to mine.</p> <ol> <li><p>Dogshit when it comes to concurrency or parallelism. Emphasizes higher-level constructs such as multiprocessing, but end up using os.fork() and some form of low-level IPC because it&#39;s faster and circumvents the fragile interfaces.</p></li> <li><p>Syntax appears nice but doesn&#39;t really add much value.</p></li> <li><p>C bindings can make things extremely fast, but good luck making the code multithreaded/reentrant.</p></li> <li><p>Python 3 breaks everything.</p></li> <li><p>Python stdlib is shit. I find myself replacing lots of &#34;batteries included&#34; modules with 3rd party versions that suck less.</p></li> <li><p>Python advocates a coding standard but rarely in the stdlib do you see any adherence.</p></li> </ol> <p>There&#39;s probably more gripes, but those come off the top of my head.</p></pre>OpinionatedRaptor: <pre><p>Lol this has to be a fucking troll. The exact opposite is true of almost every piece of bullshit you just spewed</p></pre>MALE_SHOEGAZE: <pre><p>Go is my current primary language but I really don&#39;t enjoy the community (sorry ya&#39;ll). People cargo cult Rob Pike way too hard and I think it&#39;s made the community closed-minded. </p> <p>I sort of get it: Go is great because of its stdlib; the stdlib is good because it&#39;s consistent, opinionated, and, well, <em>good</em>. It sets the standard for how people should write go libraries. </p> <p>The result is that the community at large adopts these standards, and eventually you end up with an ecosystem of very predictable libraries and interfaces (similar to OTP (erlang)). </p> <p>So, it&#39;s in the communities best interest to defend that philosophy. </p> <p>But at the same time, people are so goddamn hostile to anything that dares deviate away from the gospel. Oh, your error handling is just a little too clever? Bad. Tried writing map in go? Bad. Your library is actually complicated? Bad. <em>Syntax highlighting?</em> Bad!</p> <p>Seriously, the guy who got me into go no longer uses syntax highlighting. </p></pre>epiris: <pre><p>I don&#39;t think they have much intersection to be honest. Most problems I&#39;ve faced have had a clear winner with one or the other. But to be honest the more projects both personal and work related I do in Go I can&#39;t help but to feel it&#39;s better for a much larger set of problems. Anyways, if you already have experience with a lot of Java and PHP with decent python.. I think Go would be a clear win for you. Keep in mind your asking in /golang.. but I would say it&#39;s a good choice regardless. It will get you a bit closer to the metal and probably add overall more value to your development knowledge. Investing more into python will just reinforce patterns and paradigms already found in your core languages. Python will just make you more familiar with all the horrible things the language allows you to do. Push syntax and APIs into your head for better recall. But that is stuff that gets discarded if your work situation changes. I coded PHP for around 5 years professionally.. the value was the OOP .. the patterns. If you asked me for all the names of str functions I wouldn&#39;t remember right now .. or argument order for some of the str* family. </p> <p>Anyways point is I feel like you will be further from your past languages if you choose Go, learning more stuff that will be retained.</p></pre>PaluMacil: <pre><p>Both Python and Go were far easier for me to learn than what I spend my workday doing (C# and all its massive frameworks), and it isn&#39;t hard for me to find time to hobby around in both. Both have such a different feel that it&#39;s very hard to compare. If you look at only one type of application, you might be able to compare a little... For parsing through a lot of text and optionally transforming it, I find Python to be a favorite. For web apps there are great reasons to use either one. I would probably use Go for something with a higher need for accuracy and robustness. I&#39;d probably use Flask in Python for a web app that has under a thousand lines of code and isn&#39;t mission critical. For mobile, I&#39;d probably want to use Python&#39;s Kivy. For your other list of &#34;typical backends&#34; it probably doesn&#39;t really matter much. If you were to do build tools, maintenance scripts, and admin consoles in Python while making the core apps in Go, you might have a nice sweet spot, but overall the choice you make won&#39;t make or break you. :) Good luck and have fun!</p></pre>mundanevoice: <pre><p>I would suggest that you learn both of them. Python is one of the most used languages around and it is going to stick for a long time. </p> <p>Great thing about Go is that it has excellent tooling and it is not that difficult to learn the language in very less time. Go and Python advocates different philosophy. Go has excellent stdlib, so you won&#39;t find much high quality frameworks here but people make excellent application using just stdlib. But when you are under time pressure and you want to avoid boilerplates, you might want to use Python(maybe Django, Flask) under that circumstance. </p> <p>You might need to understand that with both languages there are certain tradeoffs(more boilerplating with Go, sometimes too much ORM magic with Python[Django]), and need to figure out which one you should choose.</p> <p>So if I were you, if a project is big enough I would select Python, maybe create different services in Python using flask/Django and then see if I could replace one of the service using Go(something that requires high and easy concurrency). But in order to reach that state, you really need to reach that scale and that many users and it is a good problem to solve. </p> <p>So keep an open mind, try to get to bottom of the problem and select the right tool for the job. No language in the world automagically solves all your problems.</p></pre>myringotomy: <pre><p>Try crystal.</p></pre>aakih: <pre><p>none of them.</p></pre>

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

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