<p>I know this is a general question, but maybe someone can help. I've been using primarily Ruby for the past few years, but I worked on a few Node projects and wrote some scripts in Go. I'll soon start working on a greenfield project and the only two language options (imposed by the company) are Node and Go. I'm not sure which one to pick. coming from the Ruby on Rails landscape, I find it very hard to switch to either of them as I'm not impressed with the quality of libraries and frameworks. I am tempted to pick <a href="https://beego.me/">Beego</a>, but I'm scared at some point I will not find the libraries I need and get stuck. They don't even mention testing on their website. The project I have to work on is a dashboard that will be using React for the frontend.</p>
<hr/>**评论:**<br/><br/>hancengiz: <pre><p>We have actually used go and react together while we were transitioning a dotnet shop to linux stack. Dotnet devs were so easily adapted to go and they quickly become productive. But there were some challenges around connecting to some legacy systems like oracle :) (where is this not a problem? :)) Other than that I highly recommend it. It is a very fast growing ecosystem and a beautiful language. </p></pre>losinggeneration: <pre><p>I've been using Go for the back end services for a few years so I'll give a few observations.</p>
<ol>
<li>The web page still needs JavaScript. However, it's been nice having one team able to focus on the presentation layer, and one on the data layer. For a smaller project this may be more of a burden.</li>
<li>Excel is a PITA and avoid it. Both companies I've used Go at had requirements to support Excel. In one company PHPExcel was used as an endpoint and openpyxl was used at the other. Most recently, we tried two Go Excel libraries and found them lacking.</li>
<li>I did a bit of Rails at my last job, but didn't feel hindered by a lack of ORM with Go. Even now, gorp is used mainly to fill in structs from queries. There are other options in development that generate ORM like structs and methods that might be interesting for a new project.</li>
<li>There are web frameworks, but like ORMs, aren't totally needed. Something like Beego or Buffalo may help ease people into it.It really depends on what you're after. It sounds like something like this may be more what you're comfortable with. My last job I went from Rails to Martini (which is Sinatra-like.) Now it's basically httptreemux, standard context, and a small function composition middleware.</li>
</ol>
<p>I don't know what type of timeline you have, but being able to do a prototype in each may make it easier to pick. I would most likely pick Go for most of my back end services, but a few times it has made sense to use other languages. </p></pre>the-kontra: <pre><p>By the way, you can also write frontend React code in Go by using <a href="https://github.com/gopherjs/gopherjs" rel="nofollow">GopherJS</a></p></pre>shark1337: <pre><p>I don't think that anyone has ever traded js react for gopherjs react in production..</p>
<p>Edit: Why? Simple, the devtools, the starter kits, bundlers etc..</p></pre>shark1337: <pre><p>I've been using both Golang and Node.JS and I'm gonna make a short comparation:</p>
<pre><code> - in terms of packages, node.js beats go by far with npm, but now it depends what kind of packages you're looking for. I needed a good image processing package ( something like sharp in node) and I successfully found it in go.
- in terms of productivity, node.js feels faster too me and now with es6 even faster. Go assertion is kinda boring sometimes
- in terms of performance for web development I've heard that they do the same, but I doubt it since it's native code vs interpreted code. (Note: there's also fasthttp package which I also use it in production..)
- in terms of ruby guy..well, it depends by a lot here, neither node.js nor go looks like ruby, but if you're doing the switch because ruby feels slow, there's also crystal language which was intented to be native ruby, but turned out in the compiler. Kemal ( like sinatra) and Amber( like rails) are very well mantained crystal web frameworks. Also note that the crystal itself hasn't reached v 1.0, but the http lib is pretty solid.
</code></pre>
<p>Other than that, if performance si not a matter for you, go with Node.JS. We used node.js at our company to consume an API written in c#. If you're looking to design APIs, go with go, working with databases will be a pain so I sugest using some helper libs like xo (NOT an ORM). Good luck ;)</p></pre>vassyz: <pre><p>The frontend can be separated. It doesn't need to be served by the backend. The only two options are Go and Node.</p></pre>luckyleprechaun98: <pre><p>Ive done quite a few sites with React and Go over the last few years. The best combo in my opinion is <a href="https://github.com/go-chi/chi" rel="nofollow">chi</a> for a router and <a href="https://github.com/jmoiron/sqlx" rel="nofollow">sqlx</a> for database access. You don't need much more than that.</p></pre>mishudark: <pre><p>if you are looking for some like RoR <a href="https://gobuffalo.io" rel="nofollow">https://gobuffalo.io</a> could fit your needs, other case looks at gokit</p></pre>metamatic: <pre><blockquote>
<p>I'll soon start working on a greenfield project and the only two language options (imposed by the company) are Node and Go.</p>
</blockquote>
<p>If those are your two options, definitely Go. With Node you'll constantly be dealing with library churn and the other issues of the Node ecosystem. (How's that fork going?)</p></pre>H1Supreme: <pre><p>Go is awesome for web backends, and most people find they don't need a framework. Get a router, maybe an auth library, and get moving. What kind of libraries are you looking for? Have you looked at Go's built in packages? They might seem limited, but they're quite robust.</p>
<p>I came to Go from PHP framework world myself. But, after a few years of using Go almost exclusively for web backends, I've realized I don't need all that bloat. </p></pre>vassyz: <pre><p>I really like the structure a framework provides. Maybe because I'm seeing this through the eyes of a Rails developer.</p></pre>mrwnmonm: <pre><p>Yes. You will like it and you will hate using RoR again.</p></pre>shovelpost: <pre><p>If you are going to develop a server-side application which produces HTML, unless it is simple and small in scale, then Go might not be the best tool for the job. Really no language is. This architecture simply doesn't scale. RoR can help up to a certain point. But as soon as the rendered pages start becoming complex and increase in number you are going to start pulling your hair.</p>
<p>On the other hand if you are going to develop an API which will be consumed by some Javascript frontend then I highly recommend Go.</p></pre>HugoWeb: <pre><blockquote>
<p>Really no language is. </p>
</blockquote>
<p>I'm confused - what are you suggesting here if even RoR can only help to a certain point?</p></pre>shovelpost: <pre><blockquote>
<p>I'm confused - what are you suggesting here if even RoR can only help to a certain point?</p>
</blockquote>
<p>Separation of backend and frontend.</p></pre>i-dontevenseethecode: <pre><p>I can't believe people still write front end code in the back end. Just gross.</p></pre>shovelpost: <pre><p>Sometimes producing HTML server-side can be better. It really depends on the project requirements.</p>
<p>But I tend to agree. With this architecture, when the project grows bigger and more complex, things start getting pretty gross.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传