Thursday, September 5, 2013

First impression of Golang

I have been playing with Go for 2 weeks. Here are my first impressions.

Good things

  • Concise and clearly expressed syntax - Its syntax smells like C and Python. It also has some small interesting improvements over typical C-family languages. 
    • if with a short statement. It might be just a syntactic sugar but I think it makes the code more concise.
    • I like the idea of having only for loop and C's while is a version of for
    • Capitalization means it is exported. Very simple and good formatting in the same time.
    • switch with break by default.  Yeah. It's arguable but break by default is my choice.
  • goroutine and channels - After I have been busy with thread-safe and concurrent issues using Java and Obj-c for a while, synchronized block, locks, java.util.concurrent, GCD and dispatch_async(), etc. I think this is another simple and amazing abstraction to deal with synchronization and concurrency in addition to a single thread and event-loop in nodejs.
  • Easily add methods to almost any types even function
  • Interface are satisfied implicitly - This is a 'wow' for me.
  • Toolchain included - testing, package management, formatting and documentation. This helps Go developers to have a uniform development flow.
  • Only one style and consistency - go fmt forces some styles and convention such as tab indentation. You might be annoyed if your preferred style is different from what the Go team has chosen. While I'm writing this, I found a very good explanation on why this is a good idea.

Interesting but in question

  • One place for packages - Go needs every packages to be under GOPATH and wants developer to avoid local/relative import. It provides a good structure for that. It needs to specify fully qualified name in code when import a package. For example, import "".  It seems to be a good idea but I wonder if the url changes. Do I have to changes every import lines in my code?
  • No versioning on package management - As opposed to npm, go get just get the latest version. I'm not sure if it is a good idea. Some said that you have to snapshot your tree. Some said that you need to use versioned path /v2/mylib instead.
  • Only static linking

Finally, I am very new to Go so I have no comments on speed/performance aspect and I am still not sure what Go fits but it is quite fun to explore the language.

No comments:

Post a Comment