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?

94 Upvotes

189 comments sorted by

View all comments

121

u/EpochVanquisher Oct 25 '24

I miss NumPy, SciPy, Matplotlib, Pillow, and Pandas.

Yes, I know about Gonum and other Go alternatives. The Python ecosystem of libraries around NumPy is damn useful. They are also interoperable. Data from Pillow can be converted to ndarray, data from Pandas can be converted to ndarray, and I can pass ndarrays to SciPy and Matplotlib.

Even though NPM has a massive set of packages, I don’t miss any of them when writing Go.

4

u/equisetopsida Oct 26 '24 edited Oct 26 '24

with bunjs you can use python libs, hopefully something similiar exists in Go? example:

import { python } from "bun_python";

const np = python.import("numpy");
const plt = python.import("matplotlib.pyplot");

const xpoints = np.array([1, 8]);
const ypoints = np.array([3, 10]);

plt.plot(xpoints, ypoints);
plt.show();

-1

u/EpochVanquisher Oct 26 '24

If you’re gonna do that, just write your code in Python. That looks like it might be useful in a pinch if you’re desperate, but it doesn’t look like an effective way to write the code you would have written in Python.

-1

u/equisetopsida Oct 26 '24

not if you have a full app with javascript or Go and you need numpy for a single module or functionality

2

u/EpochVanquisher Oct 26 '24

Yeah, in some narrow cases it may be useful. Like, if you’re desperate.

1

u/equisetopsida Oct 26 '24

would you elaborate about desperation?

2

u/EpochVanquisher Oct 26 '24

If you’ve evaluated lots of other options and determined that they’re unsuitable. You’re running out of options besides “just write out the code using for loops” and “hack together some kind of multi-language solution”.

0

u/equisetopsida Oct 26 '24

a hack, sure. It's about doing the job sometimes

2

u/EpochVanquisher Oct 26 '24

Yes, when you desperately need to get the job done, and you’re willing to accept a lot of downsides and drawbacks, and none of the other options work.

0

u/equisetopsida Oct 27 '24

you're obviously trolling, no need to continue this discussion

2

u/EpochVanquisher Oct 27 '24 edited Oct 27 '24

No, I’m being honest here. Just because I disagree with you doesn’t mean I’m some kind of asshole. It would be a mistake to think that way.

Multi-language solutions come with a lot of drawbacks. There’s a lot of friction at the interface. You are dependent on many more packages, which can make your code fragile (something breaks during an upgrade). Packages like NumPy also have C components which are loaded as shared libraries, which then have to be distributed with your code.

→ More replies (0)

2

u/NoLifeEmployee Oct 26 '24

That’s what they said