I had a great weekend following the Learn Go with Tests online book. I spent about 15 hours going through the whole book and fire up a few practice projects.
I know it’s not a lot to come to a conclusion, but I had enough experience with other languages to find the pros and cons of the language. As we all know, the biggest and most exciting features of Go area the goroutines and channels. It’s built for concurrency and it’s so stupid simple to work with it.
Go comes with its own little problems. You need to pass Context around, down to the deepest of your call stack. At the time of this post, Go doesn’t have generics, it’s on the way though. Check out the last blog post about it on Golang blog for yourself. Don’t get excited about the syntax though…
// Print prints the elements of any slice.
// Print has a type parameter T and has a single (non-type)
// parameter s which is a slice of that type parameter.
func Print[T interface{}](s []T) {
// same as above
}
What’s the fuss about the syntax?
I’m a JavaScript developer who switched from C, Java, C#, PHP languages in this particular order. If you ever worked with those languages – and I bet you did -, then you know the drill :
type variableName = value;
function functionName(MyType $val) {}
public static void main(String[] args) {}
You know, going left to right. Type to variable name. Then Go comes to the show and…
func SayHelloToThePeople(people []Person) (hellos []string) {}
Left to right, then right to left. Like, what in the name of Gopher is happening here?
Maybe the problem lies in me, I should’ve gone down the route of exotic languages rather than the mainstream ones.
After all, as a full-time JS developer, I’m not sure if these two languages can live together in one muscle. As you get used to writing out type variableName
then suddenly switching to variableName []type
really twitches my muscle memories. Practice makes perfect though.
Simplicity of Go
Did you know Go only has 25 keywords? We got 32 in C, 54 in Java, 54 in PHP, 59 in JavaScript, and 102 in C#. That’s according to a mid-2017 reddit post. God knows how many keywords now C# got… Anyway, I was lazy to look it up on my own so probably those numbers are off – according to my one minute Google research C# only got 79 keywords. You still get the point, right? Go has few keywords and they managed to stuff the magic of Go – concurrency – into those few keywords.
Let’s talk about the included batteries, in my opinion that’s still something that belongs to the simplicity section. Go comes with all the fun stuff without any external dependencies. Let’s see what we got here:
- Code formatting (
gofmt
) - Code linting (
golint
) - More code static checks (
go vet
) - Tests (
go test
) - Test coverage (
go test -cover
,go test -coverprofile=coverprofile.out
,go tool cover
) - An awesome standard library
If you are just starting with Go then you probably don’t need to do anything other than just installing Go. That’s a huge plus for me. Whenever I fire up a new JS project I need to go through setting up a linter, a formatter, a test runner, and many many dependencies (depends on the project though).
Our modern world of programming is very bloated I must say. I miss the good old days of just putting together a few PHP files and uploading them via FTP.
What’s next?
Well, Go 2 is coming and I’m thrilled but scared at the same time. Hopefully Go 2 will follow what Go 1 started.
I’m hoping for the best regarding the future of Go. I love the current state of the language and I’ll probably continue learning it and putting together a few projects with it.
Top comments (0)