Do we really need another language?
I think the current computer language has everything that todays requirement. But i feel it is worth to learn and see the reason behind Google's motive. As we all know, DPR's 'C' has everything in it for enterprise and todays emerging embedded and smart phone and tiny OS environment's. Let's see what 'Go' really brings into table.
Before going to see the value of 'Go' on the table, let me bring some information about the FAQ, which I read to understand about 'Go'.
What is the main intention to bring 'Go'?
Go is an attempt to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language. It also aims to be modern, with support for networked and multicore computing. Finally, it is intended to be fast: it should take at most a few seconds to build a large executable on a single computer.
This means, can I build my whole Android system in few seconds? if it is in 'Go'. I dont really believe that is really possible. But how are they going to achieve? Here are some of the points which they are arguing 'Go' is faster.
It is an expressive but lightweight type system; concurrency and garbage collection; rigid dependency specification; and so on. These cannot be addressed well by libraries or tools;
By the way, 'Go' is not completely new language. It is mostly in the C family (basic syntax), with significant input from the Pascal/Modula/Oberon family (declarations, packages), plus some ideas from languages inspired by Tony Hoare's CSP, such as Newsqueak and Limbo (concurrency). So this means, still any new language completely behind DPR's 'C'.
Well, It sounds like yet another language like 'Java' or '.NET'. But let see how different from them?
Interestingly 'Go' doesnt provide exceptions or asserts. It also uses its own goroutine instead of thread. Go Language always tries to keep the stack size so small and even incase it allocates run time and free it. Basically it uses the segmented stack.
The next questions comes to my mind, Is it Object Oriented Language?, The answer 'Go' provides 'Yes' and 'No'. It is bit confusing, It uses the OO model but it defer some of the complicated OO model. Instead it uses its own method of easy way of providing interfaces and object classes.
Now Let see the initial setup and other details before we jump into more detail about 'Go' programming language.
You can use Notepad ++ or Vim as editor for 'Go'.
You can download 'Go' plugin for Notepad ++.
For Notepad++:
http://go-lang.cat-v.org/text-editors/notepad-plus-plus/
For Vim
Place $GOROOT/misc/vim/syntax/go.vim in ~/.vim/syntax/ and put the following in ~/.vim/ftdetect/go.vim:
au BufRead,BufNewFile *.go set filetype=go
Install Instruction for Ubuntu
$sudo add-apt-repository ppa:gophers/go $sudo apt-get update $sudo apt-get install golang
There are a few quick easy things we’ll need to do in order to get our environment prepared. First, Go requires a few environment variables to be set in the shell so that it knows where to find and place files. You could type all the following commands directly into the terminal, but since some of them may be needed later, we’ll put them all in our .bashrc file.
Open ~/.bashrc file, and enter the following lines at the end:
$vi ~/.bashrc
#This line will tell the Go installer where to place the source code before compilation export GOROOT=$HOME/gosource #With this line, you choose the architecture of your machine. #Those with 64 bit CPUs should enter "amd64" here. export GOARCH=386 #operating system export GOOS=linux #And now the location where the installer will place the finished files #Don't forget to create this directory before installing export GOBIN=$HOME/gobin #Include Go binaries in command path export PATH=$PATH:$GOBIN
Save and exit into terminal.
and then now
source ~/.bashrc
Type the following command in the terminal to make sure dependencies installed for build.
$sudo apt-get install bison gcc libc6-dev ed gawk make python-setuptools python-dev build-essential $sudo easy_install mercurial
Now you can install 'Go' Language.
$hg clone -r release https://go.googlecode.com/hg/ $GOROOTTest the installations.
$cd $GOROOT/src $./all.bash
Save the following into a file called test.go
package main import "fmt func main() { fmt.Printf("Hello, Go!\n") }
#These commands are for 32-bit builds #Replace the "8" with "6" in all examples to build for 64. #Compile... $8g test.go #Link $8l test.8 #And run.. $./8.out
Then the output should be
chandra@ubuntu:~$8g test.go
chandra@ubuntu:~$8l test.8
chandra@ubuntu:~$./8.out
Hello, Go!
chandra@ubuntu:~$
Let see more on tools, compilers and programming techniques on coming posts.
By the way, You can get more document information about 'Go' Language in the following URL's
http://golang.org/doc/install.html
http://google-go-lang.blogspot.com/2009/11/fatal-error-cant-find-import-fmt.html
http://go-lang.cat-v.org/text-editors/vim/
http://golang.org/doc/codelab/wiki/