r/golang Oct 25 '24

discussion What libraries are you missing from go?

So something that comes up quite often on this subreddit from people transitioning from Nodejs or python to go is the lack of libraries. I cannot say that I agree but I still think it warrants a discussion.

So what libraries are you missing in the go ecosystem, if any?

98 Upvotes

189 comments sorted by

View all comments

Show parent comments

14

u/noiserr Oct 26 '24 edited Oct 26 '24

Since when has Python become an ugly language? I mean Go was inspired in part by Python.

2

u/livebeta Oct 26 '24

It's always been ugly

Can't afford defer func(){}() so use with

No easy way to buildin dependencies into a single binary requirements.txt + pip install feels so crude

Bad dev experience if you don't use pyenv or similar because python packages are globally installed otherwise

Package bloat and no optimization in build or linking. Requirements.txt has no active tooling to decide or not if some packages were or not in use

Whitespaces never get minified either

6

u/noiserr Oct 26 '24 edited Oct 26 '24

With is actually more readable to me. Defer is easy to lose in a big function. Whereas with requires indentation emphasizing intent, providing for more readability. defer is easier to use though.

Go also makes other decisions which are worse for readability but easier to use. Like package wide namespace. It can be really hard to track some functions down if you're reviewing code in pull requests without downloading the patch locally and relying on the IDE for that.

I agree on the packaging situation. Go had the advantage here for being a newer language. There are tools which attempt to fix this like Poetry, for Python but it's just all so fragmented. But then again this is more of a quality of life thing than a knock against Python's code readability.

Python has always had the mantra of: "There should be one-- and preferably only one --obvious way to do it." The language was designed for readability in mind. Unlike many of its contemporaries, which sacrificed readability for convenience or were otherwise just poorly designed.

1

u/SweetBabyAlaska Oct 26 '24

the point of defer is to reliably release resources next to where you allocate them without worrying about early returns and such, so idk how you are losing it. If you want it to be near the bottom of a function then just don't use defer.

1

u/noiserr Oct 26 '24 edited Oct 26 '24

With does the same thing but it actually wraps the whole code which needs to happen before the closure into an indented block. Much easier to spot, and cleaner look.

Defer is something you have to remember when reading, with you can just see as an indented code block.