Skip to content

Comment on G# – A modern .NET language with Go, Kotlin, and Swift ergonomicsparent

Comments

I don't find Go especially verbose - in fact, due to the economy of syntax, Go code without the usual syntax sugar features ends up similar in length to other curly brace languages. I tested this with C# and Typescript, where I migrated projects from these languages to Go - the overall volume of code stayed roughly the same.

  err := do_something()
  if (err != nil) {
    return nil, err
  }

  err = do_something_else()
  if (err != nil) {
    return nil, err
  }

  err = do_something_more()
  if (err != nil) {
    return nil, err
  }
...

So very concise. And this is not even including the error wrapping that is recommended.

First, this is legal:

       if err := do_something() ;err != nil {
         return nil, err
       }
Not horrible imo. But I've found that verbose error handling and explicit errors made me consider which parts of the code can return err, and reorganize code around that - with that I've been able to eliminate most 'err' from my codebase.

Like, if you go by function: ReadData(has err)-> ParseData(has err) -> ProcessData(no err)

Instead of having functions that can fail dynamically all over your codebase.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.