Gopher

Why You Should Consider Learning the Go Coding Language

As a programmer in the olden days of QBasic in MS-DOS, I learned the benefits that compiled languages such as C++ had over interpreted languages that are processed at runtime. The same is true to this day. While computers have amassed insane amounts of processing power, the demand on servers has also grown exponentially.

At the time of writing this article, PHP is still the primary choice for web developers and web frameworks. In my opinion, this is simply for the lack of a better option. Most new languages and frameworks have simply expanded on existing technologies, and Object Oriented PHP was an afterthought. Drupal, Magento, WordPress, PhpFox, Zend, and many others use PHP as their base coding language. I won’t deny that PHP has a lot of kick behind it when used properly and is easy enough to learn, however, it is by design an interpreted language, meaning that every time a request hits your server, the script runs from start to finish. What happens if you need to make changes and make a typo? First, your visitors will be greeted by a nice little 500 error, then your boss is calling you in the middle of the night. Sound familiar? It gets better. PHP only runs on one CPU core at a time. So if you have a massive 32 core CPU server, your website doesn’t even come close to utilizing the full power of your dedicated server. And if you’re like a lot of people on a shared hosting plan, there’s 500+ other websites hogging resources from you, causing your visitors poor load times between pages and requests.

There are many issues and I can go on all day about performance, but we came here to learn about Go, so let’s get to the good stuff!

Why go Go?

Go is fairly young compared to other languages, but it’s fully production ready. It’s been around since 2007, and became open source in 2009. Since then, it has grown by leaps and bounds, and reached version 1.0 by around 2012. It was developed at Google by some of the pioneers that made Linux possible, Rob Pike, Ken Thompson, and Java engineer Robert Griesemer. Go was created to solve many issues programmers face every day, such as security, compatibility, and scalability, which take time and extensive knowledge of computers. Go takes things out of the development process that make code very messy over time, and keeps the ideas that work, causing developers to learn the “correct way” to code and leaving little to no room for error. Words can’t even begin to describe what that can do for the open source community which we all hold dear. “Hacks” in code aren’t necessary with Go as it was designed to unify and streamline the process.

It gets better

Go has multi-threading capability, and scores very high according to benchmark tests
You can set up a web server in just a few lines of code, and serve dynamic web content (when you add database support) in fractions of the time it would take to serve PHP pages. Of course, with caching PHP output you can cut that time down, but the fact is that it has to be processed, then the issue still remains of your output being up to date with your code changes. That said, with Go, your changes are recompiled the next time you run it and you can set up asynchronous listeners and events – you read that right, asynchronous – to serve responses to requests for a running Go web server, as opposed to PHP which has to start up from the beginning each time (excluding FastCGI, which keeps PHP running for faster response times), and requires a bit of overhead just to determine what the actual request was and how to handle it in the context of your application.

Who uses Go?

Actually, quite a few major websites have implemented Go, either partially or fully.
Some notable organizations using Go:
CloudFlare
SoundCloud
Heroku
Bitly
And more..

You can learn more about Go on the official website: http://golang.org
An interactive tour of the go coding language: http://tour.golang.org
A Highly recommended eBook is also available here: http://www.golang-book.com/

Happy Coding!

The following two tabs change content below.

Dave Wilson

Senior Engineer at BuyerQuest
Dave Wilson is a web developer focused on the newest technologies, Social Networking, SEO, and Marketing. I have been working with computers since the days of Apple ][ and MS-DOS.

Latest posts by Dave Wilson (see all)

Posted in Go.