Live data from Hacker News

Lies we tell ourselves to keep using Golang (2022)

fasterthanli.me

461–470 of 526 posts

Re: Lies we tell ourselves to keep using Golang (2022)

#461
post #419

Earlier quoted context omitted.

You are right there is no reason mobiles can't run Rust/Go/Python. But actually they don't, because there is no infrastructure and no tooling to build mobile apps using these languages. And this is the big oversight of the creators of these languages. All these languages we love so much as developers will die. Not because they are missing generics or error handling or coroutines or a static type system or other nifty…

I think you're vastly overstating the case saying these languages will die.. The majority of code we write runs on servers, even if its ultimately in service of a mobile/web client. Even if mobiles didn't support them, that doesn't mean these languages will die. The servers still have to run. Creating the tools to run them on mobile is a solvable problem. Rust is already supported in the Android platform [1]. It take…

> I think you're vastly overstating the case saying these languages will die..

Sometimes you need to wake up people. Because I don't want to live in a world where we have Javascript in the frontend and in the backend. But this is going to happen if the creators of other programming languages are continuing to ignore development for mobile apps.

Re: Lies we tell ourselves to keep using Golang (2022)

#462
post #434

Earlier quoted context omitted.

It doesn't matter with `error` because it's returned everywhere, both functions and from packages by proxy. I'm not arguing that the tenet should be held true, to be clear. I'm saying that this tenet is misleading. If you can, return a concrete type. If several packages consume the same interface, then you it's not reasonable to define the interface at the consumer because you'd just have to copypaste it.

> I'm saying that this tenet is misleading. Doesn't that go without saying? There is no tenet that isn't misleading when presented to a general audience. Fair that if you come from a position where you understand the full context and nuance under which the tenet was built then you should be able to free yourself from being mislead, but, of course, this time is no exception. > If several packages consume the same inte…

I don't quite see when a package is "understood to be the consumer" of... itself? We're talking about other packages importing an interface.

I can give you a concrete example.

I have a "storage" package, that exports multiple storage implementations/backends. Files, in-memory, S3, zip...

Some other packages pick one of the implementations to instantiate, depending on the use case (this is NOT a case of mocking for testing or anything like that).

Most other packages work with a "storage" interface, as they're only concerned with reading/writing to "storage".

So the storage package, or in any case some package, has to export the interface. Otherwise, every consuming package would have to copypaste that interface, which is NOT warranted.

Re: Lies we tell ourselves to keep using Golang (2022)

#463
post #377

Earlier quoted context omitted.

Technically, Go v2 signified the transition away from Google control to the project being directed by the community. That happened several years ago. Go v2 is already here and has been for a long time. The stdlib is also at v2 now (e.g. math/rand/v2). You must mean the language? They said that a language v2 (go2) is probably unnecessary – that any future additions could be added without breaking the existing language…

This was what I was referring to. The stdlib is what would need to see backwards-compatibility-breaking changes, not the language itself.

I am not sure how would that work? F.ex. how would you introduce tagged unions and make the language 100% backwards-compatible... but not the stdlib?

I admit I have no idea.

Re: Lies we tell ourselves to keep using Golang (2022)

#464
post #437

Earlier quoted context omitted.

How? Stringly matching? That's not typesafe at all.

No it wraps the underlying error

But the underlying error stays unmatchable. Doesn't sound like a solution if you have to duplicate every error type, and worse, they don't even map 1:1 but now you have the same underlying error wrapped to god knows how many different errors.

For example, the lib produces some an error "bad file descriptor". You'll be wrapping it when you call fileOpen, fileDelete, etc etc 20 times. So you will be wrapping it in "open error", "delete error", etc, 20 times. You cannot try to match it to "bad file descriptor", that information is lost, you now have 20 relatively useless errors.

Except if you stringly match.

Re: Lies we tell ourselves to keep using Golang (2022)

#465
post #460

Earlier quoted context omitted.

why would it have to respect GNU getopt? When did that become the golden standard? I never respect getopt because I really don't care about it and it has no bearing on anything I build. As long as they are documented under `--help`. Almost everyone uses Cobra from command-line options. And it is capable of doing getopt if you want, but I don't see why it would be a requirement. Signals and Backgrounding seem to be ju…

> When did that become the golden standard? 30 years ago? > Signals and Backgrounding seem to be just developers that have little experience with that stuff. Yes, go developers have little experience. I see we agree. > What more are you expecting? Them to tell systemd they started. > I don't even know what you are referring to by the `old fork way` As I said, most go developers have little experience. I see you agree…

> 30 years ago?

I have yet to find a developer, go or otherwise, that cares strongly enough about getopt outside the hardcore FOSS groups that pays attention to this. I know of getopt, and I don't follow it, because no one ever told me to was the golden standard, I was under the impression it was one of many ways, not the only way, especially if you work with systems like Windows at any point, that doesn't follow it either. I also personally don't like the getopt style

> Yes, go developers have little experience. I see we agree.

Or you know, they have no need for it, and don't implement it. You are conflating inexperience, with not caring about the thing you care about.

> Them to tell systemd they started.

Why? Very few services care about your init system these days. Like I said, containers have made it so you don't need to worry about it. I have dealt with many supervisors and init systems, and I have 0 interest in specifically adding code to notify them. At best I will add a network endpoint, and it is up to the unit file to poll for it, if it can.

> As I said, most go developers have little experience. I see you agree once again.

No, I am arguing that in modern day server dev, it is an unnecessary skill to learn, so they don't either learn it, while having plenty of other experience, or they specifically don't care enough about it for it to matter to them.

> The old fork way is the portable way to do it with whatever init system (systemd included).

This assumes you care about an init system at all. Like I mentioned previously, the majority of places Go servers run on are either in Containers, or microvms. The init system does not matter. So few go devs take the time to implement support. It is not lack of experience, it is priorities.

I work in DevOps, ever since we moved primarily to containers, I have stopped caring about adding signal handlers, init system supports, etc. I write far fewer init files, be it unit files for systemd, or old school SysV stuff. It is an unnecessary set of features to add for projects that are internal, small, or run in containers. I am sure if a Go project gets big enough, it gets support for init systems, but those kind of projects are few, and init system support is an after-thought.

If you are so big on FOSS standards, maybe open a PR and add the necessary sd_notify features. Should be only a few lines of code if you import https://github.com/coreos/go-systemd/blob/main/daemon/sdnoti... and call it.

Most Go projects won't add this by default, because the use-case is infrequent for it for most places Go is used. Just like the article said a pro and con of the Go ecosystem is we don't need to worry about the rest of the dev world to gain the benefits of Go. So GNU/linux standards are not a priority. Especially with how easy it is to build cross-platform, using a Linux standard for all platforms is not perfect.

Maybe take the time to be open minded instead of calling the entire Go dev ecosystem "inexperienced", it is simply the case of priorities and needs to the community, and when there is no need for doing the things you mention, they aren't added, even if the devs know about them.

And I disagree that everyone should follow getopt, it is not the only way, and it is not necessarily the best way.

Re: Lies we tell ourselves to keep using Golang (2022)

#466
post #434

Earlier quoted context omitted.

> I'm saying that this tenet is misleading. Doesn't that go without saying? There is no tenet that isn't misleading when presented to a general audience. Fair that if you come from a position where you understand the full context and nuance under which the tenet was built then you should be able to free yourself from being mislead, but, of course, this time is no exception. > If several packages consume the same inte…

I don't quite see when a package is "understood to be the consumer" of... itself? We're talking about other packages importing an interface. I can give you a concrete example. I have a "storage" package, that exports multiple storage implementations/backends. Files, in-memory, S3, zip... Some other packages pick one of the implementations to instantiate, depending on the use case (this is NOT a case of mocking for te…

Actual code is always better, but based on the description it seems a bit strange that there would be a single package that exports multiple implementations. Presumably each distinct implementation should be its own package. None of these packages would export the interface.

An additional package would export the interface and provide the common functionality around that interface. Those common functions would be considered the consumer. In fact, the standard library offers an example of exactly this: io/fs.

Re: Lies we tell ourselves to keep using Golang (2022)

#467
post #459

Earlier quoted context omitted.

I don’t know about the padding (certainly it never inserted any when I’ve used it) but you can definitely state the byte order upon reading or writing. That would definitely be an oversight. Take a look at the encoding/binary package: https://pkg.go.dev/encoding/binary

I want a struct, not to having to write the code manually to do a struct every single time. I know you can do that in go but as I already said: "more error prone than C".

Can you please give me an example of what you don’t like? I’m not sure I understand the “write the code manually to do a struct” bit.

You have to define the struct for sure, but beyond that you just pass it to binary.Read and it comes back with the fields populated. I don’t see how you’d avoid defining the struct.

Re: Lies we tell ourselves to keep using Golang (2022)

#468

Earlier quoted context omitted.

This was what I was referring to. The stdlib is what would need to see backwards-compatibility-breaking changes, not the language itself.

I am not sure how would that work? F.ex. how would you introduce tagged unions and make the language 100% backwards-compatible... but not the stdlib? I admit I have no idea.

The stdlib would remain 100% backwards compatible, but the implication was that he would want to see certain existing features of the stdlib amended with modified versions that leverage the new tagged unions. He imagined that modification would necessitate v2 stdlib packages to maintain sensibility.

Re: Lies we tell ourselves to keep using Golang (2022)

#469
post #45

Earlier quoted context omitted.

Without fail, every single person I’ve seen rave about go’s error handling compares it only to exceptions as if that’s the only alternative. On the flip side I have yet to find a person who’s familiar with sum types (e.g., Maybe, Option, Result) that finds the golang approach even remotely acceptable.

I dislike sum-type based error handling. It is annoying syntactically and only really doable with lots of high-level combinators, which in turn hinder debuggability.

I'm dealing with Rust based error handling now and nesting `match` statements is not exactly very happy. Or having to pull in `anyhow` and dealing with its awful awful documentation.

Re: Lies we tell ourselves to keep using Golang (2022)

#470
post #376

Rust and Go are very different and I feel people want a middle ground that just doesn't exist currently. A garbage collected relatively simple language that compiles into a statically linked binary but has a type system similar to rust, rest types etc. Syntactically, Gleam and Kotlin come somewhat close but not really. I like Rust but I do believe it is too complicated for many people who are capable of creating some…

So here is my take on this, once again: Start with JavaScript. The basic syntax is delightfully direct, it has massive adoption already, the ecosystem is large, the runtimes are getting better all the time, compilation is here with WASM, Now remove the weird parts (e.g., too much flexibility to redefine things, too much use of the global scope, too much weirdness with numbers, etc.), and add: - Types (including sum/p…

I think here you're pointing at something along the lines of Roc/Gleam?
Post reply on HN