Go for web development

blov · · 850 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hey everyone.</p> <p>I&#39;m pretty experienced with using Python and Django to build websites but I keep seeing this hype around Go and how much faster it is.</p> <p>I guess what I&#39;m wondering is, is it worth writing a website in Go over something like Django? Is speed like that really noticable in a web application?</p> <p>Thanks!</p> <hr/>**评论:**<br/><br/>carsncode: <pre><p>If speed weren&#39;t noticeable in a web application, the New York Times website could be hosted on a Raspberry Pi. When it comes to servers, a lot of the time, performance is more in terms of efficiency than speed - i.e. how many requests per second can be handled by the same amount of hardware.</p> <p>As to whether it&#39;s &#34;worth it&#34;, that&#39;s up to each developer to decide for each specific situation. Maybe the performance alone makes it worth it, maybe it doesn&#39;t. Maybe the scalability makes it worth it, maybe it doesn&#39;t. Maybe the ease of deploying a Go app makes it worth it, maybe it doesn&#39;t. Maybe one developer prefers a strongly-typed compiled language while another prefers a dynamic-typed interpreted language. It&#39;s largely a matter of personal preference and project requirements.</p></pre>tmornini: <pre><p>I recommend that you use Go to build an API and use HTML/CSS/JS to write a UI to interact with the API.</p> <p>This is the way web apps are written in the modern era.</p></pre>mcouturier: <pre><p>Except that its fine for control panel and portals where you have to be logged in but hurts SEO for general websites. </p></pre>shovelpost: <pre><blockquote> <p>hurts SEO for general websites.</p> </blockquote> <p><a href="https://developers.google.com/search/docs/guides/intro-structured-data" rel="nofollow">Structured data</a> can help.</p></pre>goenning: <pre><p>I have an API in Go and UI in React/SCSS/TS, I don&#39;t have any issues with SEO. The problem with SEO is not the stack, but how you use it.</p></pre>tmornini: <pre><p>Prove it?</p></pre>goenning: <pre><p>You can see it live here <a href="http://demo.fider.io/" rel="nofollow">http://demo.fider.io/</a> And this is how Google sees my page <a href="http://i.imgur.com/9kT9qu8.png" rel="nofollow">http://i.imgur.com/9kT9qu8.png</a></p> <p>Source code is here <a href="https://github.com/getfider/fider" rel="nofollow">https://github.com/getfider/fider</a></p></pre>tmornini: <pre><p>Looks the same to me.</p> <p>Am I missing something?</p></pre>goenning: <pre><p>Same what? The google rendered image?</p> <p>It should be the same. Which means google crawler has the same view as a human and can index it properly.</p></pre>tmornini: <pre><p>Sorry, thought I was responding to <a href="/u/mcouturier" rel="nofollow">/u/mcouturier</a> who I responded to.</p> <p>You and I see eye-to-eye on this.</p> <p>There was probably a time when Google couldn&#39;t handle this, but today it&#39;s an old wives&#39; tale.</p></pre>mcouturier: <pre><p>I don&#39;t even know if the google bot will execute your scripts to try to parse your HTML.</p> <p>There&#39;s a difference between &#34;how Google sees my page&#34; to render a screenshot and how it does analysis for SEO.</p> <p>If your HTML isn&#39;t there using a good old cURL, I won&#39;t bet your page will be properly indexed.</p> <p>For once, ppl have javascript disabled.</p> <p>EDIT: prove me otherwise, without a screenshot ;) EDIT2: google ranks SEO on usability. Intuitively, I&#39;m sure it hurts your rank going full SPA.</p></pre>tmornini: <pre><p>The whole point of that screenshot Google presents is to dispel the myth that you&#39;re propagating.</p></pre>rbsns: <pre><p>I&#39;m working with python/django for +7 years, but now i&#39;m using Go whenever it&#39;s viable.</p> <p>There&#39;s a lot of web frameworks in Go, but you really don&#39;t need them. The standard library is awesome.</p> <p>I would recommend Go if you: </p> <ul> <li>have performance problems with django/python or performance is a <strong>big</strong> concern;</li> <li>are working with a huge project and/or have a large number of developers working with it;</li> <li>need a really good first-class concurency. </li> </ul> <p>But there&#39;s no magic inside. If you use a lot of meta-programming, generics and DRY concept, you&#39;ll miss some &#34;features&#34; in Go. </p> <p>And you&#39;ll need to forget a lot of the <em>django way of do things</em>, it&#39;s another language, with another concepts, and you&#39;ll need another mindset too.</p> <p>I think that if django is OK for your projects, use the right tool for the job and don&#39;t blindly follow the hype. Except for fun or learning purposes, of course.</p></pre>akxdev: <pre><p>It&#39;s absolutely noticeable and it&#39;s one of the reasons I&#39;m switching to Go from Ruby on Rails. Now Ruby on Rails is known to be quite slow (as mostly anything written in Ruby is) and I&#39;m not sure about Django&#39;s performance, so you may want to do some research and check out some benchmarks before making the leap.</p> <p>In my experience so far, Go has been a harder language to learn than Ruby was. I tried my hand at Python awhile back and it wasn&#39;t much harder than Ruby, so keep in mind that you might have to spend more time learning the actual language before you can make sense of a web framework written in it.</p></pre>carsncode: <pre><p>Depending on the framework, that might be the problem. I found Go&#39;s stdlib web components very easy to learn.</p></pre>Killing_Spark: <pre><p>No offense to you, but go is generally assumed to be a fast learned language. That of course is the opinion of people who probably learned things like c, and java, so they are familiar with a lot go has to offer. </p></pre>joncalhoun: <pre><p>I would guess OP means learning how to build a web app is harder. In rails it is like 4 commands and your web app skeleton is generated and runnable. In Go there is more left to the developer to set up. This makes it feel harder to learn despite the language itself being easy to understand.</p></pre>Killing_Spark: <pre><p>Ah i see. Thats a valid point of course </p></pre>found_dead: <pre><p>I did rails stuff for a company for about 6 months. Absolutely does rails have a steeper learning curve. Everything is metaprogrammed so you can&#39;t search for anything. </p></pre>aboukirev: <pre><p>PHP or Python are fast enough for Web sites that I am building. The reason I am using Go is its deployment story. Copy build artifacts to server and you are done, no need to check runtime versions or dependencies. Easy maintenance. And with Web sites, maintenance after going live is a huge chunk of work you are going to do. </p></pre>crueber: <pre><p>Optimizations because of static typing, not having an extra interpretation layer, and a concurrency model that is first class all contribute to the hype that you&#39;re hearing around Go.</p> <p>In my experience, learning Go has been a little more difficult than any of the dynamic languages out there. Ruby, Python, Node, et al. I came from a Java background, so learning types and interfaces, etc, weren&#39;t quite as hard, but depending on where you&#39;re coming from, it can be a bit tough. The speed increase due to concurrency is very noticeable though, once you get used to Go&#39;s idioms. </p> <p>For example, I used a node/go benchmark set of code that someone else wrote, and updated it to make full use of all the processing power on the box I&#39;m on, and node still performed at only about about 60% of the speed that Go does, in the best case scenarios. With fully idiomatic node, and go, and node is about as fast as you get for the dynamic languages out there. Python is significantly slower, and doesn&#39;t have a first class concurrency model.</p> <p>That all said, hardware is cheap these days. Software development isn&#39;t. So it isn&#39;t just about the speed of the app, that&#39;s just one of the many variables that has to be decided when deciding which language/frameworks to go with.</p></pre>

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

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