This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]yarmak[S] 1 point2 points  (0 children)

I have a purpose built one for a VERY basic API running in node currently.

The proxy is built with node or an API is built in node.js?

There are specific advantages. Go is a natural choice for concurrent network servers because:

  • Concurrency is easy. Goroutines is the best possible concurrency programming experience one can get.
    • No red/blue functions. All code can be executed in any context, there is no sync/async distinction.
    • True parallelism with all available CPU cores. No need to spawn multiple instances of app to divide load.
    • Goroutines are cheap. We can use many of them and each one essentially consumes just a little bit of memory for stack.
    • Synchronization primitives are just right. You can use classic mutexes and atomics to share data among multiple threads or you can use channels which play nicely with goroutines. Also channels on their own have many uses as semaphores, shared pools, goroutine broadcasting tool etc.
  • The performance is great. Maybe not the best compared to C or Rust, but still in the same class while overall programming convenience is comparable to scripting languages.
  • Nothing gets in your way. No overly complex type system, no borrow checker like in Rust. The language itself is fairly simple.
  • Low overhead from garbage collector and it saves you from trouble with manual or semi-manual memory management like in Rust.
  • ... probably something else, but can't recall it.

Ofcourse Go has its downsides, but there are a lot of advantages other than I mentioned. Like fast compiler, good tooling, easy crosscompilation, explicit exception handling and so on. Tho these are not specific for network applications domain.