I am able to use different programming languages. I know most of the well-known languages ​​without any problems: C, C++, Java, Python, JavaScript, Typescript, PHP…

However, I wanted to expand my horizon. Zig didn’t do much for me neither did Rust, but now that I’ve written some Golang. I admit, I’m intrigued by the language.

I love the fact it’s compiled to native machine language. There is still one caveat: despite Go being a GC language, you often still need to manage your memory. Sound strange right? But I needed to use io.Copy instead of io.ReadAll to avoid memory issues. But also you need to explicitly call defer res.Body.Close() to avoid Go not cleaning-up the HTTP response… Ow well, so you learn it the hard way. Overall, I’m still very optimistic with Go. And looking forward to use it more often in some of my open-source projects.

See my first project in Go: https://gitlab.melroy.org/melroy/gitlab-artifact-deployer-go. Which I wrote in 3 days.

Did you try Go? What are your thoughts?

  • chrash0@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    4 months ago

    yeah Go’s pretty good, especially for web services. i don’t have much of a space in my toolbox for it personally, though that’s not a fault of the language.

    there’s a difference between managing memory and managing resources more generally. a GC doesn’t know when you’re done dealing with a file or a database connection or some other collection of data structures that has some semantically non-deterministic lifetime.

    Rust however can close resources automatically with its lifetime mechanism ;)

    • melroy@kbin.melroy.orgOPM
      link
      fedilink
      arrow-up
      2
      ·
      3 months ago

      True true, Rust can indeed automatically close resources with its lifetime mechanisms. However, I found Rust very painful to program in. Totally skill issue! However, I didn’t like Rust yet. Maybe when you really need Rust, I can imagine you want to do that route.