The Go Language – I’m Undecided

I was looking at the Go programming Language. Go was designed in part by the famous Ken Thompson (co-creator of the C language) so that alone got my attention.

After experimenting with Go for several hours, I have mixed opinions. I like the C-like nature of Go because I like C, but I just don’t see enough compelling technical reasons why anyone would want to use Go, that would outweigh the non-technical downsides like small user base.

Go is well-suited for creating lightweight Web services. I created a demo. The first file is Server.go and it creates a dummy Web service in remarkably few lines of code:

package main

import (
  "log"
  "net/http"
  "text/template"
)

type Person struct {
  Name string
}

func main() {
  http.HandleFunc("/", handler)
  err := http.ListenAndServe(":8999", nil)
  if err != nil {
    log.Fatal("ListenAndServe: ", err)
  }
}

func handler(w http.ResponseWriter, r *http.Request) {
  p := Person{Name: "John Smith"}
  t, _ := template.ParseFiles("Hello.html")
  t.Execute(w, p)
}

To run the Go server I issued a go run Server.go command from a shell.

The other file involved is an HTML page to serve up.

golanguageinaction

The HTML file uses a Go template to fetch a person’s name (“John Smith”) from the Server. You can image that thi could be data from a database instead. By navigating to http://(machine):8999 I invoke the Web service and serve up the HTML page.

Well, cool, but my general rule of thumb is that a new technology must give me significant — 5 to 10 times — improvement for me to invest the time and effort for adoption. Go doesn’t give me that.

Bottom line: Go is nice but not a must-have for me.

Advertisements
This entry was posted in Miscellaneous. Bookmark the permalink.