Golang vs Node.js: The Showdown

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

出處:http://www.polydaic.com/blog/go-vs-node-js


Golang vs Node.js: The Showdown

By David Baldwin Jan26 6:23:59 PM

 VS 

Before Node.js popped on the scene, async was something (primarily) used by OS developers - backend web devs had few (easy) options to implement async functionality into their code. But then  Node.js came on the scene in 2009 and took the web development community (as well as networking devs) by storm. Since then Node.js has been the go to technology for web apps needing high throughput and multiple sockets (e.g. web messaging). 

However in 2012 all changed with the first stable release of Golang ; a open-sourced google backed language built with async and speed. Golang, invented at Google by Robert Griesemer, Rob Pike, and Ken Thompson is a statically typed language that closely resembles C; but with useful features like type-safety, non-blocking io, dynamic typing and with fast compilation times.

Let's look the disadvantages and advantages of each stack and see how they addup in the 'real world':

THE DETAILS

Since this site primarily deals web technologies, we'll narrow our focus to just backend web development ( and leave out the limitless other types of applications we could build).

First off Golang and NodeJS share similar features and technologies that power them. Both feature non-blocking io and are have dynamically cast types (no more type casting problems like C!)
Both also havefully featured standard libraries that support a multitude of functionalities, including HTTP and TCP (which can be access through interfaces in Go and modules in NodeJS).

OK. Thats great but your here to see which one is better right? Well then take a look below for the advantages and disadvantages:



TECHNICAL COMPARISON


 

NODEJS - ADVANTAGES

  • Same language on front and backend
  • Maturity in market
  • Much more advanced and powerful language features (if used correctly)
  • Built-in JSON parsing support
  • Faster than Golang for handling multiple io streams
  • More wb development frameworks than Go (27 vs. 2)

 

GOLANG - ADVANTAGES

  • Easy to learn - very simple syntax
  • Supported by Google - no risk of project dying
  • Easy to fully understand 
  • Designed from scratch - don't have to deal with artifacts from older releases
  • Simple design allows for high productivity and fast (initial) deployment
  • Increases code clarity (at the expense of # of LOC)

 

 

REAL WORLD TESTS

As seen below in the test results by Jonathan Warner done here , Golang can now be considered a viable alternative to NodeJS. In his bubble sort and http tests, Golang came out on top. However it is to be noted that Go does randomly spike when handling plain HTTP requests compared to NodeJS, maknig me doubtfull on the scalability of these results.

Results

  Node.js Go 1.1
Avg of 5 trials 430ms 326.26ms
Best 420ms 290.272ms
 

 

RESULTS - Plain HTTP Requests

 

However when the two techologies were subjected to a Redis bottleneck simulation, their performance gap siginficantly narrowed, making the difference between the two almost negligiable, as seen in the graph below (again done by Jonathan):

RESULTS

CONCLUSION

In summary I think its fair to say that at this point, what framework you use won't adversely affect your web app's performance. It really just comes down to whether you are willing to jump on a new technology before it is proven, or stay on the NodeJS train until you are comfortable. If you do want to code in Golang, take a look atthis for more info.

Jan26

    Filed under 
  • Jan26 6:23:59 PM 
  • Comments 
  • Permalink

Comments

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.