GoLang is an open source language developed and backed by internet giant Google. GoLang is famously known as Go and that is how we are going to refer to in future. In 2007, Robert Griesemer, Rob Pike and Ken Thompson at Google started with experiment to develop a language that will have minimal of features, but will cater most of the use cases. Beside this their idea was to overcome some of the hurdles in development, build and deployment of code written in C (and also of any other languages). Go was officially released in 2009, with latest version Go 1.5 releasing in August 2015. Go’s popularity is growing rapidly and is used by many companies like MongoDB, CloudFlare, BBC etc. Click here to know more on who are using Go and for what purposes.
But Go’s, rapidly growing popularity is not the only reason, why one should learn Go, but it is the features and the design of the Go language.
- Is Statically type language, this means that compiler will try to check the type of assignment and complain in case of mismatch. Go though support dynamic type with help of interface, but not in truly an polymorphism way.
- Fast compilation of code
- Go is designed in a way were their are not too many options, restricting the number of ways in doing the same thing. This also brings in the ease of reading code written by someone else.
- Go, also builds in the runtime code required for execution along with the Go final execution file, though this makes the final binary large in size, but avoid the hurdle of installing and configuring Go on machine where code is going to be executed.
- Go, as a language have best support for Concurrency built-in.
- Go also have various other tools for formatting, generating docs, testing and benchmarking of the code written
- Supports deployment on various OS.
Along with the key features stated above there are many more that should excite a developer to learn this new language.
Hello Playground !!!
Go, was developed with the idea to promote simplicity and so far stands to it. We don’t need to install Go on local machine to try and get started with. Visit http://play.golang.org/ online tool for Go. As soon as you launch this URL, but default you will see code for Hello Playground our first program. Let us try to understand our first program and thereby get introduce to the Go language.
First Go Program-Hello Playground
- First line of the code is “package main”, just like any other language package is used to group together various code files.
- Import “fmt”, statement to import fmt package required for formatted I/O operation like printing and scanning.
- func main () entry point for the execution. You can have multiple files in the package main, but only one file can have func main defined in it.
- fmt.Println(“Hello, playground”), call to Println method in fmt package to print “Hello Playground”
Please note, there are some limitation to the use of playground:
- Can run only one file at a time.
- Cannot try file I/O operations.
- Limitation on execution time, CPU and memory usage So in case if you want to install Go on your local machine click here.
Today we got introduce to the Go, one of the most rapidly growing language. We saw our first Go program and got familiar with it. Also we looked at the online tool Go Playground to get quickly started with Go. Though Go follows C like syntax, but just like any new language Go too has its own way of doing things like variable declaration, func calling and so on. In next few blogs to follow we are going to learn the basics of Go and understand how things are done in Go.