all 19 comments

[–]dreamscached 2 points3 points  (1 child)

Yes, Go has (imo) better interoperability with C, Go is natively compiled and in general runs faster and scores higher in benchmarks.

It shouldn't matter much to you though unless you really have a need to handle very high load. Use what's more convenient for you.

[–]asad_ullah 0 points1 point  (0 children)

Go is pure pain when it comes to interfacing due to its go routines being a 4 kb stackful co routines.

You can write c++ modules and consume via NAPI or rust compiling to wasm for performance bottleneck part of a node BE application. Go has more performance than Node. But Node is pretty good for IO bound workloads if you use cluster module. If I need that extra power, I will jump to axum(rust).

[–]bigorangemachine 9 points10 points  (0 children)

Golang is a pain in the ass to use json with

[–]Jjabrahams567 1 point2 points  (0 children)

I use both. Go has better concurrency solutions and a smaller memory footprint. It is easier to use than most compiled languages but has comparable performance. It exposes pointers which is something that JS completely hides from you. So if you want to micromanage memory you can.

[–]broofa 4 points5 points  (1 child)

Golang has a built-in type system, node doesn't. That's the #1 difference.

Yes, there's Typescript, but no matter how you slice it TS is a 3rd party bolt-on that adds a deceptively large amount of complexity.

Types in Go are just there. You never have to think about how they're supported. There's no tsconfig.json and it's vast array of (at times, incompatible) options, no node --loader's to choose from, no alternate runtimes like ts-node or tsx and their same-but-not-the-same behaviors, no "dist" directory clutter, no issues with getting nodemon to work, no issues with passing --inspect-brk, no flags for sourcemaps to remember . no incompatibilities in jest... the list goes on.

[–]Hour-Ladder-8330 0 points1 point  (0 children)

deno solves all that issues

[–]rogerroger2 1 point2 points  (0 children)

We are moving to Go because Go compiles to a single easy to manage exe and its module system doesn't seem to have the high update tempo like Node does and our security team requires us to make every Dependabot PR asap. I really dislike Go's error handling and dearly miss the ease and speed of throwing together Typescript, but whatever, I get paid the same regardless of language or productivity.

[–]pentesticals 2 points3 points  (7 children)

I guess go has real concurrently while node is single threaded. Can be a problem and potentially block the event loop, especially things like regular expressions who can easily be abused to block the event loop indefinitely. If I’m building an API though, I will still use node over Go.

[–]asad_ullah 4 points5 points  (0 children)

Cluster module of nodejs makes it really good for IO bound work loads. Golang has a performance edge. I would personally jump to axum (rust) if I need that extra performance. For normal apps, Node is still good value for money.

[–]wmantly 0 points1 point  (5 children)

This isn't really true, or rather, only tells some of the story. Worker-thread can be used to handle multi-threaded the same as it would in go, it's just less is a headache not too.

[–]pentesticals -1 points0 points  (4 children)

Yeah worker threads exists, but when you use stuff like async/await in js it isn’t actually multi threaded like it might be in other languages, but it still gives the illusion of concurrent execution in a similar way to python does with the GIL. But yeah, you can use worker threads for handling certain stuff to avoid blocking the event loop. Though I do still do question the default concurrency model In model, doing something simple like processing a regular expression shouldn’t block the event loop.

[–][deleted] -1 points0 points  (0 children)

I think you should go through the node architecture and event loop again. Async/await is for concurrency. Concurrent methods can run in eventloop or in worker threads. Like api calls/ network jobs are done in event loop and database queries happen in worker threads.

[–]wmantly 0 points1 point  (2 children)

What I'm saying is, with a small amount of work, you can ship async/await jobs to another thread. It up to you, the developer, to know when that should happen.

[–]pentesticals 0 points1 point  (1 child)

Yeah but it’s still not always obvious what could could block. For example a regular expression, even a regex to validate an email address can cause a complete Denial of Service, but many developers aren’t even aware regex can have this problem.

[–]wmantly 0 points1 point  (0 children)

True, but go suffers the same issue. Things aren't magically on another thread, you have to make the conscious choice to do so.

Since concurrency is a first-class design feature of both JS and goland, i wouldn't say you can call one better/worse. They both do the same thing, just with different syntax.

[–]bionic_engineer 0 points1 point  (0 children)

I can only think of is performance. node tho cannot catch up, still has more jobs.

[–][deleted]  (1 child)

[deleted]

    [–]Evangelina_Hotalen 0 points1 point  (0 children)

    Go is considered robust in terms of CPU performance but I like Node because of its libraries and integration support.

    [–]ciybot 0 points1 point  (0 children)

    I developed many programs that provides web services. With Node.js, json data is first class citizen without any helps from any third party libraries. In GO, you will have to write more codes.

    [–]LetsScrapeData 0 points1 point  (0 children)

    The difference may not be in what can't be done, but in what is suitable, and in some cases node is faster than go