A couple of weeks ago, I was going through the Medium app on my phone, and stumbled upon an interesting article about the Go language titled “Why should you learn Go?”. It was interesting because it wasn’t a Hello World tutorial, but rather started with a bold statement: “Moore’s law is failing”.
What stuck to me was the concurrency features of the language, which allows smart usage of CPU and OS resources, and the fact that it was created by Google, facts that I did not know before. Oh, and that some very cutting-edge software was written in Go, such as InfluxDB. But, break was over and I went on with my day…
Fast forwards a few days, I got back to working on Monitive’s new worker component, which is basically a small service written in Lumen PHP, that pulls “check jobs” from an Amazon SQS queue and checks up to a few hundred URLs in under one minute, by using a minicrawler library, written by Testomato. Of course, it uses multiplexed sockets to fetch multiple URLs at once.
The next step was adding Ping checking capabilities. But, since a “worker” will check various types of internet services, I couldn’t check hosts with Ping as efficient as I could check URLs, because I somehow had to either fork the code to check URLs and Ping simultaneously, or use curl_multi to loopback check requests for each type. Remember, all checks have to be performed and results persisted in under one minute.
Long story short, after an agonizing for an hour of trying to figure out how will PHP help me perform hundreds or thousands of various checks, of various types, it suddenly hit me: it cant! PHP can’t help me process hundreds of simultaneous routines. So I remembered the article on Go.
Google’s Go had exactly this in mind: efficiently running hundreds or thousands of tasks, all in parallel, without hardcore process multiplexing and all the horrors that come with that. I’m going to blindly assume they had a similar conundrum to sort out in their efforts to efficiently index and analyze the whole world wide web.
So I started going through their introductory tutorial, the Go language specifications (which, for a programming language, it is really short), another interesting article on Medium, some simple instructions on how to setup go on my Mac, an eagle-eye overview and the more I played with it, the more I realized:
I want to learn Go!
The challenge here is that 17 years of PHP will probably not amount to much when it comes to writing production-ready code with Go, in a few weeks. I have thought about externalizing this to a Go developer, and it might still be the way to go. But I definitely want to learn Go. Multi-platform, C-level software performance via compiled software without having to deal with pointers and everything the C brings, sounds like not only a good idea, but an actual opportunity!
There are plenty of resources and even books out there about getting started with Go, and I just can’t wait to see where this takes me. As I am only writing this piece on the very day I embarked this quest, I have no idea what’s waiting for me. But I do have a few sources for inspiration. And a Sublime Text plugin to get me going. I actually even sent out a tweet about it to let the world know it can add another Go enthusiast on its list…
I believe it can never hurt to learn a new programming language, just as it can’t hurt to learn a new language such as Spanish or French. I’m really eager to share my new experiences, challenges and solutions I encounter along the road. But I sure will keep you posted.
Later edit: As I managed to learn Go to the point which I could create a tool that I’m using on production servers, I wasn’t truly confident that I can build production-ready, high-performance software in Go, so I found a kick-ass Go developer that created the worker I was looking for in a matter of days. Thank you, Radu!