DEV Community

Discussion on: Learn a New Language: Ruby or Go?

developius profile image
Finnian Anderson

I would say it depends on what you may like to do in the future.

I’ve been using Rails for 3 years now and imo, nothing compares to it for web dev. I won’t be changing backend stacks for a while. It’s just lovely.
These are points about Rails though, not Ruby. I have no numbers on this, but I expect a vast majority of Ruby code currently running is because of Rails. So, unless you’re wanting to do web dev, maybe something with broader horizons is a better bet.

I tried learning Go a year or so ago and I did enjoy it. However, I intensely dislike the verbose-ness of error handling - leaving this code all over the place just annoys me:

if err != nil {
    return err

I prefer catching exceptions to returning errors.

Go would also be a good bet if you’re wanting to get involved in any OSS projects as a lot of the larger ones (Docker, k8s etc etc) are written in Golang. Go is definitely something I’d like to spend more time learning as I think it’s a good investment for the future.

Let us know what you pick and how you get on!

m_nevin profile image
Marc Nevin Author

Fair points! Nice to hear someone who's tried both!

I've heard nothing but wonders about Rails but I'm not sure its something I'll end up fitting into my stack any time soon - Ruby itself still has a great promise though

I'm coming round to thinking it's probably best if I try both and see how my personal preference plays but I think I'm mostly set on starting with Go, the promise of big OSS projects are tipping me a little,

Then after a while with Go, moving to try Ruby on a similar problem and some Rails then next time I'm doing some WebDev!

citizen428 profile image
Michael Kohl

I prefer catching exceptions to returning errors.

Exceptions don't travel well across boundaries in distributed systems, which is one of the main use cases for Go. Making errors values allows for defining strategies appropriate for the context. Alas most people don't, so code is littered with examples like the one you show.

Rob Pike's post on this topc is definitely worth a read:

developius profile image
Finnian Anderson

Yeah, I suppose I don't have much experience with distributed systems and hadn't considered exception handling.

For ActiveRecord (think model validation), I've used the pattern of appending to a list of errors and then doing @errors.any? to determine whether a call was successful or not - quite liked that. It kind of overkill if you want to bail at the first error though, since errors.count will always be 1.

That's a great post, thanks!