Advice to Gophers from Francesc Campoy

Introduction

Francesc Campoy runs a Golang-oriented YouTube channel - JustForFunc, works on developer relations at source{d} and used to work as Developer Advocate for the Go team at Google. He has a passion for developer relations, specifically when it comes to Go and anything that can help developers be more productive and happier.

Top discussions

Here are a few things we learned from his β€œAsk me anything” session on Hashnode.

Q: If you were to learn the golang today, how would you start the learning process and where would you look on the internet.

Francesc: If I was to learn Go today I'd probably try to learn it the same way ... by joining the Go team! Hahaha

I'm not kidding, that learning experience was amazing and I recommend it to anyone that has the chance to try.

But more realistically I'd say a good idea is to simply start writing Go, as much as possible, even when it doesn't really makes sense! My first program in Go was something that I would have normally written in bash, a bunch of calling other commands and pipes, etc.

The next step is to share that code and seek feedback wherever you can (the gophers slack is a great place for this)! I do code reviews on justforfunc.com from time to time, so make sure you send your code for consideration at form.justforfunc.com.

Code reviews are actually my favorite way to learn, because you're getting feedback on what you're doing wrong! So you already have the context and the knowledge is absorbed much more efficiently.

That said that's not always possible for everyone so if you want to know websites and books to read:

  1. execerism.io: great place to exercise your coding skills in Go and receive feedback from the rest of the community
  2. adventofcode.com: a great way to find problems to solve in Go! also you'll be able to see many other solutions, which kinda counts as getting feedback I guess.
  3. Dave Cheney's blog posts are a jewel! dave.cheney.net/category/golang
  4. justforfunc.com ... I've heard it's pretty decent 😎

Regarding books, I'm not much of a book reader when it comes to programming languages ... other than "Learn you a Haskell for a greater good" which is amaaaaaazing!

I'd say the cannonical book is "The Go Programming Language" by by Alan A. Donovan and Brian Kernighan, but I'll admit I haven't read it completely ...

studying

Q: Can you describe how your average day at work looks like? Do you even have those days πŸ˜„

Francesc: Oh my god you just made me laugh because today has been so crazy hahaha

I'm currently VP of Product and Developer Relations at source{d} so my day is a bit all around the place.

I do still code a lot and use our products, for instance yesterday spent my day coding Python and SQL to analyze the Kubernetes codebase with source{d} Engine (sourced.tech/engine).

I also meet with potential customers regularly to better understand their needs and how to meet them with our products. This is somehow right in between Product Management and Developer Relations if you think about it! Since our users are often developers, the empathy required for Product Management is actually basically the same skill needed for DevRel!

Other than that I travel a lot ... too much even. I'll be in Seattle next week to attend KubeCon (say hi if you're around!) and on Friday I'll be running a workshop at Disney in Burbank. I am platinum with Air France, premier 1k with United, and pretty hight status too with American. This is not bragging, but rather a call for help πŸ˜…

On top of that I try to have my own hobbies so I still play piano often (you might see some tweets on that from time to time), plus hit the gym at least 3 times a week πŸ‹οΈβ€β™€οΈ

piano

Q: I would love to know your take on dep vs go modules and maybe go a little deeper into the differences between the two approaches. And please feel free to do a dedicated justforfunc episode for it, if it's difficult to do it here.

Francesc: It is indeed kind of hard to do it here! hehe

First the things I like about both is the fact that at the end of the day, no matter which one you're using you can always end up exposing the vendor directory therefore letting your users simply use your code without having to care about your choice for dependency management.

On the other side dep is not integrated into the go tooling as much as modules (for reasons that belong more to political rather than technical conversations). This means that eventually everyone will be able to use modules natively without having to have an extra tool ... and we know programmers are lazy!

So yeah, I'd say modules and dep are both solutions to the same problem, but given the fact that modules is already integrated with the official Go tooling I do not think dep will be popular for much longer.

And that makes me a bit sad, because the team of gophers behind dep is amazing! Great people and great coders. The show must go on, as they say.

Q: What (existent or absent) libraries do you think the community should work on to improve the things we can do with Golang?

Francesc: I'd say my favorite thing is the effort on bringing generics. I've wanted them for quite a while, since they will empower gophers to write more concise code.

Imagine a library containing common concurrency patterns, or maybe even some functional programming concepts like reduce or filter ... the dream!

I don't care that much about the error handling, because I think that once we have good generics we should be able to improve error handling thanks to other concepts like error monads etc.

Q: I'm used to working with streams and sockets in other programming languages. I've been trying to wrap my head around channels for IO. Could you help break down the differences between channels and streams. Maybe also any recommended examples, posts or code that really highlight their usage

confused

Francesc: Hah, great question!

Channels are more about communication and synchronization than streaming data, tbh. Everything you can do with streams you can also do with channels, but take into account that the result will very probably be much less efficient.

This is due to the inherent complexity on making things work correctly across multiple goroutines and threads.

If you want to write with streams in Go, io.Reader and io.Writer are your friends!

For instance you could do something like:

  1. http.Get on a url that serves a zipped json file, that returns an http.Response
  2. Create a zip.Reader reading from http.Response.Body
  3. Create a json.Decoder reading from zip.Reader
  4. io.Copy from the json.Decoder to os.Stdout

This will start printing the first decoded objects from JSON before you're actually done downloading the file if the network is slow enough!

So if you wanna do data streaming use io.Reader and io.Writer, if you wanna do synchronization of workers sharing tasks channels.

For the synchronization of tasks, check out this talk by John-Graham Cumming!

youtube.com/watch?v=woCg2zaIVzQ

Q: What is your opinion on the future of Go? What do you think Go 2 will bring to us?

Francesc: I sincerely hope Go 2 never happens.

This might seem a bit excessive, I know, but the reason is that having Go 2 would imply that somehow there's a non backward compatible change in the language.

This could cause the same kind of drama Python had when the migration from Python 2 to Python 3 was proposed. The amount of Python 2 code that is still running out there and that can't be used from Python3 is just painful. The community is finally getting back together, but it's been some rough years.

I really enjoyed this talk by Ian Lance Taylor (youtube.com/watch?v=LqKOY_pH8u0) since it talks about different ways we could have breaking changes that do not imply breaking the community in two. Basically how a single project could use some files in Go 1 and some in Go 2.

If that's the case ... let's go for it! But let's be very careful, please.

I think Go has a very bright future, but I'm also not fully attached to the language and I recommend doing the same. Attaching your career to any specific technology is always a losing bet.

mic drop

More interesting questions

If you'd like to read more interesting answers, go to the full AMA page.

Let us know who would you like us to invite next!

I'm a marketer, technophile, gamer, coffee lover, geek and a bunch of other things. Feel free to send me a message on Hashnode or follow me on other social media. πŸ‘©β€πŸ’»

Write your comment…

Be the first one to comment