Live data from Hacker News

Go as an alternative to Node.js for very fast servers

bbs.studygolang.com

71–80 of 168 posts

Re: Go as an alternative to Node.js for very fast servers

#71
post #49

Earlier quoted context omitted.

For me, Go has the least "What the hell does this code do?" and "Why isn't this code working?" of any language I've ever used. I'd say Go isn't an impressive programming language, but a very impressive software engineering language.

> Go isn't an impressive programming language, but a very impressive software engineering language. Curious, what is the distinction?

He means that Go will not impress programming language geeks and academic PL researchers with cool evolved syntax or cutting edge features, but is a fine language for actually building software.

In the same sense that a language that "in theory" has tons of cool stuff might be unusuable in practice (due to complexity, opaqueness, lack of libs, strange syntax etc).

Re: Go as an alternative to Node.js for very fast servers

#72

I know this post is about speed, but you should always remember that with node.js you only need JS developers while with Go you are probably going to need both Go and JS (for front-end stuff) developers. Just my two cents.

Nay. You're going to need both backend (routing, security, caching, HTTP, more caching, SQL/ORM/whatever, MVC, search/document stores, etc) developers and frontend (HTML, CSS, HTML5 (Re: "the hard stuff"), AJAX/JSONP/CORS/whatever). Off the cuff, knowing another language is going to be very little of the overhead, especially when you consider one side is dealing with local services and the other is dealing with mostly DOM (or using some library / "another language" to view the DOM in another light).

Re: Go as an alternative to Node.js for very fast servers

#73

I did the benchmarks outlined at the end of the article. Summary of results: 1. Node.js v0.10.15, single worker: 46.2 seconds 2. Node.js v0.10.15, cluster 8 workers using naught: 17.2 seconds 3. Go 1.0.2, GOMAXPROCS left default: 3.5 seconds 4. Go 1.0.2, GOMAXPROCS=8: 3.7 seconds Detailed results below: 1. Node.js v0.10.15, single worker Concurrency Level: 100 Time taken for tests: 46.217 seconds Complete requests: 1…

Try with GOMAXPROCS set to the number of real cores on your test machine (e.g. ignore hyperthread cores).

What do you think the difference is between a "real core" and a "hyperthread core"?

Re: Go as an alternative to Node.js for very fast servers

#74
post #44

Earlier quoted context omitted.

>I dunno what you're complaining about. I'm complaining because you and other people will go on to: 1. Use a version of Go in your development that is slower (as has much worse memory characteristics) and lacks new features. 2. End up running all your programs on single core until you understand GOMAXPROCS 3. Use ab to bench real things which is bad So "my complaining" is trying to help you.

I agree with Voidlogic here. Perhaps his tone was a little confrontational, but his intentions were good. :) Go 1.1 > Go 1.0.2 wrk > ab In particular, ab should be avoided whenever possible. Apache Bench (ab) remains a single-threaded tool, meaning that for high-performance servers in particular, your exercise will run into the limits of Apache Bench before the limits of the server(s) being tested. The LigHTTP team h…

Is this the wrk you're referring to:

https://github.com/wg/wrk

Re: Go as an alternative to Node.js for very fast servers

#75
post #34
post #24

Earlier quoted context omitted.

How much of an advantage, if any, does Node provide because it's more "mature", or at least has been used for far longer. For example, when I go to StackOverFlow I see that Node has far more questions asked: http://stackoverflow.com/questions/tagged/go http://stackoverflow.com/questions/tagged/node.js

I'm really uncertain about node being judged more "mature". Being developed by Thompson and Pike makes you gain something like 30 years of "maturity". Plus, running in production in the Google infrastructure is far more of a proof of maturity than running the chat service of every hackathon project for 2 years.

So do I just email all my questions directly to Thompson and Pike, then?

In this case, language maturity means the quantity of reference material available to help troubleshoot problems as the arise.

Re: Go as an alternative to Node.js for very fast servers

#76

Is it possible to write Go in a functional way? Are there first class functions? Anonymous functions? If so it seems it would be possible to write highly functional code given the flexibility of interface{}

It seems to me that Go is incredibly crappy for writing in a functional style. Have a look at Rust if that's what you're after.

I wrote a library for Go that makes functional programming with channels-as-streams very comfortable, for me[1]. There is a problem with needing to box and unbox variables from the 'empty interface{}' type all the time but it's a minor wart IMO.

It's a really small library that was made in response to my own intuition (similar to yours) that the Go standard library wasn't really embracing a functional style. I haven't used it in any major projects but for small one-off things it's proved pretty useful. It basically works like pipes on the command line.

1: https://github.com/eblume/proto

Re: Go as an alternative to Node.js for very fast servers

#77

I know this post is about speed, but you should always remember that with node.js you only need JS developers while with Go you are probably going to need both Go and JS (for front-end stuff) developers. Just my two cents.

There's a school of thought in software dev that a developer is a developer is a developer, and should be able to do all the things a developer should do.

That said, you hire "backend-focused" developers, "front-end" developers, etc., but to me that still means they should be able to do whatever tasks are necessary (Go, JS) to get their job done.

Re: Go as an alternative to Node.js for very fast servers

#78

I know this post is about speed, but you should always remember that with node.js you only need JS developers while with Go you are probably going to need both Go and JS (for front-end stuff) developers. Just my two cents.

Nay. You're going to need both backend (routing, security, caching, HTTP, more caching, SQL/ORM/whatever, MVC, search/document stores, etc) developers and frontend (HTML, CSS, HTML5 (Re: "the hard stuff"), AJAX/JSONP/CORS/whatever). Off the cuff, knowing another language is going to be very little of the overhead, especially when you consider one side is dealing with local services and the other is dealing with mostl…

I am a "full stack" developer. I know the ins and outs of both my front and back end stacks (Groovy in my case), and I have a pretty good sense of the patterns required in this case.

However, one of the more frustrating pieces of this is that I never dive deep into one paradigm. I'm continually having to work bilingually. When I was working with node.js, I didn't feel nearly as much bilingual stress (even though I've written backends in python, ruby, java, groovy, and scala!)

As such, my single person one-off and side projects will be in node.js. It's about cognitive overhead in the moment. I agree that it's a mediocre solution for larger teams and enterprise is not its sweet spot, but it's great for projects in the small.

Re: Go as an alternative to Node.js for very fast servers

#79
post #24

I did the benchmarks outlined at the end of the article. Summary of results: 1. Node.js v0.10.15, single worker: 46.2 seconds 2. Node.js v0.10.15, cluster 8 workers using naught: 17.2 seconds 3. Go 1.0.2, GOMAXPROCS left default: 3.5 seconds 4. Go 1.0.2, GOMAXPROCS=8: 3.7 seconds Detailed results below: 1. Node.js v0.10.15, single worker Concurrency Level: 100 Time taken for tests: 46.217 seconds Complete requests: 1…

How much of an advantage, if any, does Node provide because it's more "mature", or at least has been used for far longer. For example, when I go to StackOverFlow I see that Node has far more questions asked: http://stackoverflow.com/questions/tagged/go http://stackoverflow.com/questions/tagged/node.js

If this is your requirement, may I suggest:

http://stackoverflow.com/questions/tagged/java

Re: Go as an alternative to Node.js for very fast servers

#80
I've worked with both node and Go. There is a lot of hyperbole and fluff points about Go's strengths in the original article (sorry to the author!). Things that are touted as huge wins for Go have equally better things in node. Both platforms are great and they both have appeal for different people.

My eloquent post was eaten by an expired link on the original article but here are some counter-points:

The commutative property applies to all code that has semicolons to end lines. Use jslint/jshint/an IDE. The symbol is "optional" not marked as "leave it out because it makes scripts nicer."

Use jslint/jshint/an IDE to prevent globals. Seriously. It's the same as running go fmt on your code.

Forcing people to use "channels" as a best practice to accomplish scaling is the same as the best practice of callbacks - but yes, channels are nicer to use. Node standard modules require callbacks by default as Go standard library implements channels by default.

32-bit integers in JS don't have float problems because the precision doesn't break

Typing in Go can still be annoying for some situations. If you're dealing with external content (creating an API with mutable content that you still need to read) it can be annoying at best (e.g. reminds me of writing C). Types in Go are a nice implementation though.

npm is way better than go get and there are at least 3 projects in Go trying to replicate npm's ease-of-use

The vim/emacs syntax highlighter is nice but it's awfully frustrating if you don't use vim/emacs. This is due to Go's young age, but you shouldn't be forced into using a certain editor to get syntax highlighting.

The alternative to "go fmt" for Javascript is a good IDE or jslint/jshint.

In Go, you get a lot in the standard library, but you miss out on a lot in the community. Yet another young language problem, you wind up having to roll your own for a lot of things that should just exist. It can be frustrating looking for answers because you might be the first person working on the problem in the language.

Also, just as a general thing I've perceived, people seem to argue static types vs dynamic types more than that a particular language is "better." Go and JS/node are both great!!!! Go is typed, JS is not and you deal with the consequences in both situations. Static typed languages have big faults with external data handling that sometimes cripple features (or makes them far more difficult to accomplish). Dynamic typed languages can fall victim to variables being used incorrectly (especially when not using an IDE). That's the biggest bulk of the difference in my experience.

Post reply on HN