Articles

A Short Introduction To Google's Go Language Or Golang

by Kevin L. Strategist

Golang, a short typed of Google Language is the new programming language initially developed by Google in 2007. According to Ken Thompson, one of its initial developers (along with Robert Griesemer and Rob Pike), “When the three of us [Thompson, Rob Pike, and Robert Griesemer] got started, it was pure research. The three of us got together and decided that we hated C++. [laughter]... [Returning to Go,] we started off with the idea that all three of us had to be talked into every feature in the language, so there was no extraneous garbage put into the language for any reason." Google claims, "Go is an expressive, concurrent, garbage collected programming Language". This language have evolve since its inception. Its “gc” compiler, targets Linux, Mac OS X, FreeBSD, Open BSD, and the Windows OS.

Golang is designed to be a general purpose program. The syntax of this language is easy to understand and analyzed by automated tools such as integrated development environments. Its pattern is made short and orderly. Writing programs in this language is not tough once the basics are understood.

The syntax is quite similar to that of C, made simpler by omissions of certain aspects. According to many developers, it has the pattern of C and the simplicity of Python. It includes garbage collection, type safety, additional dynamic-typing capabilities, build-in types such as variable length arrays and key-value maps accompanied by a large standard library.

As the syntax of this language is simplified, there is no need of separate specification of expression types. One could simply write, just i:=”some number” or s:=”some character” replacing the int(integer type declaration) or char(character type declaration) as needed in C. Semicolons are not required to end a statement. To initialize maps, slices and other struck parameters literal syntax are used. Slices are an extra type that is used in Go, points to an array of objects in memory. The objects may be passed by reference. The Map key type is used to include hash tables.

The Go program constitutes of packages. Each package has a path (e.g.,"compress/bzip2 "or"

code.google.com/p/go.net/html") and a name (e.g., bzip2 or html). Therefore, writing the first Go program starts with a package. The program starts by running the package “main”. A typical program is as below:

package main

import (

“fmt”

“math/rand”

)

func main () {

fmt.Println(“My nunber is “, rand.Intn(10))

}

In this program, the package with import path “fmt” and “math/rand” is used.

Here is a simple math program,

package main

import "fmt"

func main() {

sum := 0

for i := 0; i < 10; i++ {

sum += i

}

fmt.Println(sum)

}

While executing the program, the result will be 3 4 5.

Here the package used in with the path “fmt'. Comparing this program with C, one can make out its simplicity.

The language complies quickly and it supports concurrency at language level. Although, this language is high level as Python, it supports lower low level features. This makes it compatible for OS level programming. Golang is a new programming language, it is still in its developmental stage and its is already finding its use in most recent systems and processors. Being new, it lacks support and help communities like other languages do. Software service providers companies are opting this language nowadays and its increasing popularity will definitely lead one of the best languages soon


Sponsor Ads


About Kevin L. Advanced   Strategist

45 connections, 0 recommendations, 115 honor points.
Joined APSense since, March 12th, 2013, From Noida, India.

Created on Dec 31st 1969 18:00. Viewed 0 times.

Comments

No comment, be the first to comment.
Please sign in before you comment.