DEV Community

Cover image for I don't get the point of Golang - That's why I need help
Lucas Chitolina
Lucas Chitolina

Posted on

I don't get the point of Golang - That's why I need help

Hello everyone, I'm back. The past few days were crazy at my work, so many complicated tasks needed to get shipped and I couldn't write here.

Today I'm coming up with a different topic: I don't get the point of Golang - and I need help with it.

Contextualizing things up

Since the beginning of my career, I've always used node in most of my projects, from discord bots to complex backends. I feel a little comfortable with it, but I realized that my way of thinking is becoming tied to this technology.

So, I need fresh air and new things. That's why I want to give Go a chance.

Okay, I get it – when compared to other languages, Go is known for its simplicity and the plethora of benefits it offers. But I don't want to fall into a trap that will solve Go-specific use cases tasks but with a Node mind.

I also don't get the point of it (as the title says). What different or specific things *need * to be done in Go that I can't do with Node?

I want to invite more experienced people, people who have been on the two sides, people who are learning one of these two amazing techs, to join start a discussion here with a main question:

What can I do with Go that I can't do with Node?

Feel free to join in the comments:

Top comments (14)

Collapse
 
dsaga profile image
Dusan Petkovic

I would also like to hear a perspective from other experts there, even though I understand the obvious benefit to using GO, that its a compiled language rather than interpreted at runtime, which makes it faster

Collapse
 
xwero profile image
david duymelinck

I think you are asking the wrong question.

You said you need fresh air, then maybe the question is why do you need fresh air?

I always try new languages, listen to talks that go over my head. But i consider that a part of my developer life. Always wanting to learn how to do better, and failing a lot along the way.

I would suggest you focus on something you see in another language you want to understand. And once you understand it, try to do it in your language of choice. All languages are evolving and a thing that wasn't possible a year ago, can be possible now.

Collapse
 
kaamkiya profile image
Kaamkiya • Edited

I use now Go for most of my projects. When I started, I was wondering why I shouldn't just use Python. After a while, something just clicked, and now I love it.

Nothing needs to be done in Go, so if you'd rather, you can something else.

What can you do with Go but not Node?

  1. Build executables. Go is a compiled language, so it's very fast.
  2. Statically typed (although I think Node supports TS now?).
  3. VERY useful error messages. It basically only lets you run your code if it has no errors.
  4. Simplicity. Although this can also be a downside, because you have to do a ton yourself.
  5. The packaging system. go.mod is complex, but once you get the hang of it, it's an absolute pleasure.
  6. Go saves your dependencies. Instead of having 40 node_modules directories, you have one ~/go directory that holds all of your dependencies, and you can use them across different projects.
  7. Concurrency.

Side note: The creator of Node switched to Go. Then Rust. Then made Deno.

Hope it helps :)

Collapse
 
wsgac profile image
Wojciech S. Gac

I haven't used Node.js for much more than playing around. But I do now have some more serious Golang projects behind me and so I can give you my reasons for liking it. I'm a Lisper at heart so Go is not my dream language, but it sufficiently embodies the Unix philosophy of simplicity and readability that I can't not like it. Here are some points I find noteworthy:

  • The type system is robust and expressive. It's not as watertight as Haskell's but gives one the feeling of well-defined data structures at the center of one's programming effort (see Alan Perlis' epigram no. 9: cs.yale.edu/homes/perlis-alan/quot...)
  • It's a bit C-like in terms of syntactic simplicity, yet feels much more high-level (probably due to a rich set of libraries and standard means of their distribution).
  • Channels! Go has typed channels and goroutines at its core, which is a clever programming paradigm for concurrency. It's more or less equivalent to Tony Hoare's CSP (cs.cmu.edu/~crary/819-f09/Hoare78.pdf)
  • It's fast. Both execution and compilation. Combined with goroutines' lightweight implementation, you can easily have thousands (maybe millions) of goroutines in parallel.
  • It feels like a no-nonsense systems programming language for the present. It's not trying to be too clever, rather deliver a pragmatic mixture of theory and practice. If I were to recommend a single resource to get a little excited, Id' suggest you check out this presentation by Rob Pike, one of Go's designer: go.dev/talks/2012/concurrency.slide#1
Collapse
 
jamesvanderpump profile image
James Vanderpump • Edited

After having used TypeScript for like forever, writing Go feels like a huge step back in language ergonomics. Some of it because I'm more experienced in TS, some because TS really does have a lot more going for it with things like map().filter().reduce() etc. Let's not talk about error handling. That being said, it's good to be curious and Go does have it's place, which is why I still use it for certain tasks like where I want a single static cross-platform binary.

Collapse
 
forestdev profile image
Dominykas Bartkus

I always find the error handling argument weird. What do you guys do with your errors? I'm all for optimistic programming, but I've worked on so many projects where you have no luxury of just bubbling your errors up top, as in the end you'll end up having to still write a nasty block of code to actually handle those errors. I feel being explicit with every error just makes it easier to debug.

Collapse
 
forestdev profile image
Dominykas Bartkus

I find go a breeze to write and the added performance and goroutines is great. The code structure is much more easy to reason about. Pass by value or pointer, your choice. Especially when seeking performance, one or the other could better as per stack vs. heap allocation. Gives you control to some degree of how you manage the life cycle of your variables.

I also love how they've implemented interfaces: you can only define methods, everything else is up to you how you need to implement it, no need for further strictness. Testing comes out of the box and it works great, no need for 3rd party tools.

Tooling is great, fmt, and everything comes with a strict set of rules that makes it easier to avoid some pitfals. Also, go finally has go.mod, without which go was a bit messy for me module wise, but not the case anymore.

Also, true type safety! Not just a fancy "linter" that does not actually provide safety.

Any project I start now I go with go out of the box. Only might use echo as a basic framework for web servers, as I feel it saves you a bit of time.

I feel I write code faster, with less hassle, and have everything out of the box right there. Compiles fast too.

Collapse
 
mrwormhole profile image
Talha Altınel • Edited

multi threaded server that runs requests in parallel with minimal resources without an interpreter. You can't have it on python due to GIL, you can't have it on node due to C++ single event loop

if all you do is CRUD, it doesn't matter for you but when it comes to deployment you will be dealing with process managers/spawners or web server gateway interfaces/workers to be able to glue-jail your interpreter. In some cases, you can get away with [ python main.py] or [node index.js] entrypoint docker container but it is not ideal for prod

In go/rust/zig, you just ship native binary in a scratch container and it just works because it is native static single bin kinda like C but with less cumbersome tooling

lastly, I think working without type hinting doesn't scale in team projects, it is easily the Achilles heel of duck typed languages

Collapse
 
alexmario74 profile image
Mario Santini

From the point of view of an application developer you can do pretty much the same things with Node as you can with Go.

So, the change is not worth if Node fit perfectly your application scope.

Even if you use Node successful, you might face some issues while hitting certain limits.

For example, if you write an application that is doing a lot of I/O processing, or you use a huge amount of RAM memory, just to highlight some cases that pop up in my mind.

With Go, you will have a much efficient language, that can help you work on multiple threads, using all the power of modern multi-core CPUs.
Your code in Node can't do that, you need a library in C++ or Rust, that handle the computation for you, or write your code to have different Workers, but this is not as efficient as the Go solution.

With Go you can build executable for many architecture, you just need to provide the target and it will cross-compile.

With Node, you may don't have the issue, if you don't have binary dependencies, but if you end with one of those, you have to set up a build chain that include this target architecture, I mean, you need a VM or a Container Image of this platform to build your application and deploy it.

The list can be longher, but you may get it, there are reason you may choose Go for your task, because with Node you can't be so effective.
In any case, I suggest you to learn Go a bit, even you don't end up using it with your production apps.
Why, because it will help you to refresh your mind with an outside the box approach.
It's good to pich a different language, just for learning purpose, time by time.

Collapse
 
masterkind profile image
GO

I think there is no "point" for Go. Several languages are used for building complex backend applications. For me node.js is like a bridge to the other side. If someone is used to frameworks, JS and TS its a small hopp to node.js without struggling with new languages like Go, Rust, Kotlin, ...
Go's concurrency and the channels to communicate and synchronize them are similar to the event driven non-blocking model from node.js. Go concurrency might be on heavy cpu-intensive operations slightly better...
So my answer to Your question is : Nothing

Collapse
 
liampulles profile image
Liam Pulles

Go is not an exciting language in terms of syntactic sugars. Its very (deliberately) boring in that respect.

Go is like the ultimate grug-brain language. It appeals to me at least because the language makes it harder for someone to make a clever and incomprehensible solution to an algorithm. In Go one is strongly inclined (both in terms of the language and the community around it) to do it in a plain way.

The hopeful upshot is that I will actually be able to understand what the hell I and my coworkers were thinking 6 months down the line.

Listen to Rob himself on the subject: https://www.youtube.com/watch?v=PAAkCSZUG1c&t=14m35s

Collapse
 
kwnaidoo profile image
Kevin Naidoo • Edited

Golang is minimalism, as a developer you can just focus on the engineering aspects and not worry about clunky build tools, importing 3rd party packages and so forth.

Most of what you need is built into the standard library so you don't need to reach for third-party code that often.

Golang compiles and runs incredibly fast, so very easy to scale without much effort. Furthermore, goroutines and channels are just so seamless to work with. To deploy, you literally just build and replace the binary, you don't need a process manager or other service to manage your application. It's fully self-contained.

One of the most annoying things in Node is that most things are async by default, In Golang it's the opposite. You only use concurrency when needed.

Typing in Golang is a breeze, it's not as weird as TypeScript and feels natural.

Lastly, this is debatable but I think the error handling is pretty cool too. Instead of having hundreds of try-catch blocks everywhere, you simply return an "error". The caller can then check for errors and handle those accordingly.

Ultimately it comes down to you as an individual, while there are better tools for certain tasks, generally, most modern stacks are good enough to handle most workloads. So I would just stick with what I know unless there's a clear reason to switch.

Collapse
 
ken617 profile image
Ken

As you embark on your journey to explore the intricacies of GoLang, remember that learning a new language is not just about mastering syntax but also about embracing new paradigms and problem-solving approaches. Don't hesitate to seek help from online communities, forums, or educational platforms if you encounter challenges along the way. Resources like programminghomeworkhelp.com can offer valuable help with Golang assignment, providing insights and support to help you navigate through the learning process smoothly. Keep pushing your boundaries, stay curious, and enjoy the adventure of discovering the unique capabilities of GoLang!

Collapse
 
blinkinglight profile image
M

What can I do with Go that I can't do with Node?

what you can do in node what you cant do in python, ruby, lua, bash or any other languagE?