Live data from Hacker News

From Python to Go to Rust: an opinionated journey (2018)

tech.allo-media.net

21–30 of 78 posts

Re: From Python to Go to Rust: an opinionated journey (2018)

#21
I've yet to try Rust. But Go is the best and worst thing to happen in my career. Best because it's amazing, worst because now I don't like working in other languages.

I'm trying elixir currently, and it makes me want to rip my hair out. No for loops, no typed parameters, implied returns. Who in the world though any of this was a good idea? IO.puts() refuses to print certain objects (list of ints) and just prints a newline, making it useless for debugging.

I'm very very excited to try Rust, and I'm glad I've been able to choose the languages I work with up to this point in my career.

Re: From Python to Go to Rust: an opinionated journey (2018)

#22

> but at some point, it didn’t feel right anymore. That's not how engineering works. > I realized that I couldn’t rely on the compiler to get my back when I was doing mistakes That's not how engineers work. > a compiler that should not rely on the fact that I know how to code I don't even know what to say anymore.

Maybe you should try the dev experience of Elm or ReasonML before shooting down the author’s comments.

I get what you are saying and I also get what the author is saying it might be that you are missing something truly great in our engineering field.

Re: From Python to Go to Rust: an opinionated journey (2018)

#23
post #6

> I compiled the code and … no error message. Everything went fine. But?! I just added a field to a struct, the compiler should say that my code is not good anymore because I’m not initializing the value where it should be! This is your big hangup with Go? You added a new field, didn’t use that field anywhere, and the compiler didn’t complain? I’ve heard a lot of valid criticisms of the language but this is a new one…

> I’ve heard a lot of valid criticisms of the language but this is a new one for me.

We've had bugs in prod because of this "feature". It's another bad design decision in golang.

Re: From Python to Go to Rust: an opinionated journey (2018)

#24
post #6

> I compiled the code and … no error message. Everything went fine. But?! I just added a field to a struct, the compiler should say that my code is not good anymore because I’m not initializing the value where it should be! This is your big hangup with Go? You added a new field, didn’t use that field anywhere, and the compiler didn’t complain? I’ve heard a lot of valid criticisms of the language but this is a new one…

I wouldn't have left Go just because of these but before you write this off as minor thing, I would suggest you look this as one of the core language design decision. It reveals two important language philosophies:

1. Go doesn't follow "you pay for what you use" model.

2. Go isn't too deeply invested in compilation as means for catching errors.

Above are not binary language decisions. If you go in one direction strongly then there are consequences in other. Therefore all languages chose some balance point (aka compromises). Go has chosen a balance point that is weaker than Rust (and may be even C++) but stronger than Python.

Re: From Python to Go to Rust: an opinionated journey (2018)

#25

> but at some point, it didn’t feel right anymore. That's not how engineering works. > I realized that I couldn’t rely on the compiler to get my back when I was doing mistakes That's not how engineers work. > a compiler that should not rely on the fact that I know how to code I don't even know what to say anymore.

> > I realized that I couldn’t rely on the compiler to get my back when I was doing mistakes

> That's not how engineers work.

Engineers don't leverage automated error checking whenever possible? I think you're confusing engineers with cowboys.

Yes you should have a good idea of what's going on, and strive to make minimal mistakes, and take responsibility for continual improvement. That does not take away from the fact that you should use tools that guide you to the right answer, that catch your mistakes early, and that fail safely.

Safety is not a set of training wheels that a good engineer drops when they're no longer needed.

Re: From Python to Go to Rust: an opinionated journey (2018)

#26
I was working on a simple Rust CLI program to parse JSON from the Github API, but I got turned off by some of the unfriendliness of the available http libs. One http library pulled in dozens of other crates and turned my 10 line program into a 50MB binary [0], while another had an unpleasant api [1].

[0] https://docs.rs/reqwest/0.9.18/reqwest/

[1] https://docs.rs/hyper/0.12.29/hyper/client/index.html

Maybe I have too much desire for instant gratification, but it sucked the fun out of the project.

Re: From Python to Go to Rust: an opinionated journey (2018)

#27

> but at some point, it didn’t feel right anymore. That's not how engineering works. > I realized that I couldn’t rely on the compiler to get my back when I was doing mistakes That's not how engineers work. > a compiler that should not rely on the fact that I know how to code I don't even know what to say anymore.

Maybe you should try the dev experience of Elm or ReasonML before shooting down the author’s comments. I get what you are saying and I also get what the author is saying it might be that you are missing something truly great in our engineering field.

If the author had explained a real reason for abandoning Python in favor of Go, it would've made a lot more sense to write this article. "Not feeling it right" isn't how engineers choose their tools. He could've said that he wanted to try something other than Python, and I would have respected that.

On top of it, his reason to switch from Go to Rust is laughable at best.

Re: From Python to Go to Rust: an opinionated journey (2018)

#28

> but at some point, it didn’t feel right anymore. That's not how engineering works. > I realized that I couldn’t rely on the compiler to get my back when I was doing mistakes That's not how engineers work. > a compiler that should not rely on the fact that I know how to code I don't even know what to say anymore.

> > I realized that I couldn’t rely on the compiler to get my back when I was doing mistakes

> That's not how engineers work.

Maybe "hackers" work that way, but actual "engineers" seek and use the best tools available. Finding & fixing bugs after-the-fact is usually more expensive than writing things correctly the first time, so serious engineering organizations look for ways to eliminate problems as early and as automatically as possible.

Linters, unit-tests, and type systems are all valid approaches. By looking for a language that can help with this goal, the original author is demonstrating a true engineer's mindset.

Re: From Python to Go to Rust: an opinionated journey (2018)

#29
post #6

> I compiled the code and … no error message. Everything went fine. But?! I just added a field to a struct, the compiler should say that my code is not good anymore because I’m not initializing the value where it should be! This is your big hangup with Go? You added a new field, didn’t use that field anywhere, and the compiler didn’t complain? I’ve heard a lot of valid criticisms of the language but this is a new one…

Go has two mechanisms for initializing structs, name based and position based.

    type Sample struct {
        A int
        B int
    }
can be initialized as Sample{A: 1, B: 2}, or Sample{1, 2}.

The name-based method allows arbitrary elision of fields, which will be initialized to their zero value. This includes Sample{}, which will be interpreted as a name-based initialization that specified no fields.

The position-based method requires all fields to be specified, in order, with the correct type, or it's a compile-time fail.

So if the author of the article could have gotten the latter behavior with a slight syntax tweak.

This would not necessarily entirely satisfy, though, since you can't do any mix-and-match, and in particular, it can be nice to have names on the larger structs even if you want them to be fully initialized, but there is no in-between. But, nevertheless, if you are willing to pay for the behavior that the compiler will complain on any type-changes to the struct, including growing or shrinking, Go has that.

It seems to be the Go community's "best practice", above my objections, to claim that all struct initializations MUST use the name-based initialization and that positional-based inits is a mistake, on the theory that if structs change and add fields it's important for all uses of structs to continue compiling without changes. If the author's introduction to Go came from a tutorial from someone who believed that, they could easily have picked that up mistakenly as a characteristic of the language itself.

My objection is that there's a time and a place for each behavior, and there have been plenty of times I've been grateful for the compiler pointing out every place I need to change my struct to include a new member because I could tell it was a "tuple-like" struct that should always be initialized with all the fields. You can argue with the putative "best practice" or agree with it, but fortunately it doesn't really matter because you can do the one you want regardless of what the community thinks. There is no chance either method is ever going to be removed.

Re: From Python to Go to Rust: an opinionated journey (2018)

#30
post #6

> I compiled the code and … no error message. Everything went fine. But?! I just added a field to a struct, the compiler should say that my code is not good anymore because I’m not initializing the value where it should be! This is your big hangup with Go? You added a new field, didn’t use that field anywhere, and the compiler didn’t complain? I’ve heard a lot of valid criticisms of the language but this is a new one…

It's a pretty big annoyance with Go though. I hate that all struct fields are optional.

FWIW, I never had that problem, but I also tend to use constructors for my structs.
Post reply on HN