brainsteam.co.uk/brainsteam/content/posts/legacy/2018-01-27-how-i-became-a-g...

12 KiB
Raw Blame History

author date medium_post post_meta preview tags title type url
James 2018-01-27 10:09:34+00:00
O:11:"Medium_Post":11:{s:16:"author_image_url";s:69:"https://cdn-images-1.medium.com/fit/c/200/200/0*naYvMn9xdbL5qlkJ.jpeg";s:10:"author_url";s:30:"https://medium.com/@jamesravey";s:11:"byline_name";N;s:12:"byline_email";N;s:10:"cross_link";s:2:"no";s:2:"id";s:12:"452cd617afb4";s:21:"follower_notification";s:3:"yes";s:7:"license";s:19:"all-rights-reserved";s:14:"publication_id";s:2:"-1";s:6:"status";s:6:"public";s:3:"url";s:95:"https://medium.com/@jamesravey/how-i-became-a-gopher-and-learned-myself-an-angular-452cd617afb4";}
date
/social/fd9186efac31241187aa676c2c596b1e3ce5ded926ac95f7354b4fdaf8a47e7d.png
chatbots
work
golang
How I became a gopher over christmas posts /2018/01/27/how-i-became-a-gopher/

Happy new year to one and all. Its been a while since I posted and life continues onwards at a crazy pace. I meant to publish this post just after Christmas but have only found time to sit down and write now.

If anyone is wondering whats with the crazy title a gopher is someone who practices the Go programming language (just as those who write in Python refer to themselves as pythonistas. Theres an interesting list of labels that programmers self-assign here if youre interested).

Over Christmas I decided I was going to have a break from working as a CTO and a PhD student in order to do something relaxing. Thats why I thought Id teach myself a new programming language. I also taught myself how to use Angular.js too but Ill probably write about that separately.

Go Go Gadget… keyboard?

First on my list is the Go programming language. I decided that I would spend 2 weeks over xmas (in between playing with my nintendo switch and of course spending time with my lovely fiancee and our families) building something useful and practical in the language because if theres one thing I cant stand its trying to learn to use a programming language by writing yet another todo list.

Chatty Cathy shes still very much a work in progress

At Filament, we are fast becoming one of the UKs leading chat-bot providers, working with brands like T-Mobile and Hiscox insurance. We have an excellent team of chat-bot builders run by our very own Mr Chat-bot, Rory and supported by  a very stringent but also very manual QA process. I decided I was going to try and help the team work smarter by building a PoC chatbot testing framework.

The general gist of my tool, named Chatty Cathy, is that I can “record” a conversation with a bot, go make some changes to the intents and flows and then “playback” my conversation to make sure the bot still responds in the way Id like.

Why Go?

Gophers are pretty cool!

If you hadnt gathered, Im in to performance-sensitive compute applications: AI, statistical modelling, machine learning, natural language processing. All of these things need a lot of juice. Were also in the business of writing large-scale web applications that serve these kinds of machine learning models to huge numbers of users. I love python and node.js as much as the next man but most machine learning applications that have interfaces in those languages are written in something low level (C or C++) and bound to these higher level languages for ease of use. I know that Go is still higher level than C or something like Rust* but it outperforms all of the interpreted languages and Java in the Benchmark Games and is very easy to learn (see below). It is this trade-off relatively-high-performance-versus-ease-of-use that has me so excited.

*Incidentally I spent some time last year working in Rust and even though I loved it, found it very hard going  – Ive been following Julia Evans Ruby Profiler project and its got me excited about Rust again so maybe Ill dive back in some day soon.

Pros of Working with Go

    • Go-lang is like a pared down, simplistic dialect of C. You could also think about it as a much simplified Java spin off.
    • The build tool is amazingly simple to use. Everything is done based on filenames and locations. No more over-engineered pom.xml or package.json files.
    • Like Python and node.js, Go has a huge number of “batteries included” modules and functions available as part of its standard library. Web applications and JSON are first class citizens in Go-lang and you can build an app that serves up serialized json in ~30 lines of code. (compare that to the 300 lines of code you need just to define your POJOs and your DTOs in Java and you can already see why this is so awesome).
    • Also like Python and node.js Go has a brilliant ecosystem. One of the perks of coming into existence in the golden age of the internet I guess. Gos build tool can automatically grab other projects from git repositories without needing a centralised server like pip/npm/maven which in my eyes makes it even more awesome (no more left pad chaos).
    • Unit testing is also a core part of the language and build tool. Simply adding some files to your library with the suffex _tests.go  running go test is all you need.
    • Gos goroutine interface for parallelism is a super exciting feature. Again, having been designed very recently in the age of multi-core processors, the language treats multi-core processing as a first class citizen. Compared to Python which is held back from multi-processing bliss by the GIL and node.js which uses a single event loop.
    • Biggest pro: learning curve. For someone whos written in any kind of imperative programming language before and has some level of understanding around pointers and referencing, Go is SOOO easy to pick up. I reckon the java developers at our company could be effective in Go within a week or less. (If youre reading Rob, Max, Alex, thats a challenge). It truly is like Java without the bulls***!
  • Cons of working with Go

    • I still find workspaces kind of a strange concept. Instead of checking out one git project and popping it in your $HOME/workspace directory (yes this is a hangover from years of Eclipse development when I was back at big blue), code is stored hierarchically based on where you got it from. For example my workspace looks a bit like this:
    go
    └── src
     ├── github.com
     │ ├── author1
     │ │ └── project1
     │ │ ├── LICENSE.txt
     │ │ ├── README.md
     │ │ ├── somefile.go
     │ │ ├── more.go
     │ ├── author2
     │ │ └── project2
     │ │ ├── LICENSE.txt
     │ │ ├── README.md
     │ │ ├── somefile.go
     │ │ ├── more.go

    Basically, each project gets stored somewhere hierarchically in the tree and all dependencies of your project end up somewhere in here. This can make it a little bit confusing when youre working on really large projects but then perhaps this is no more confusing than a python virtualenv or the node_modules directory of a mature node.js app and Im being silly?

    • Some of the libraries are still a little bit immature. I dont mean to be disparaging in any way towards the authors of these open source libraries that are doing a fantastic job for absolutely zero payment. However, a lot of the java tooling we use at work has been in development for 2 (in some cases nearly 3) decades and a lot of the crazier use cases I want to try and do are supported out of the box.
    • Im still not a massive fan of the way that struct tag syntax works. Again, perhaps this is because I am a programming luddite but I definitely prefer Java Annotations and Python Decorators a lot more.

    Summary

    Go is a really exciting language for me personally but also for many of us still plagued by nightmarish visions of java boilerplate in our sleep. It has a fantastic ecosystem and first-class support for parallel programming and building web services via a really nice set of REST server libraries and JSON serialization libraries that are already built in. There are a few small issues that probably still need addressing but Im sure they will come out in the wash.

    The most exciting thing for me is how well Go slots into the toolbox of any competent imperative language programmer (e.g. C, C++, Java, Python, Javascript, C#, PHP etc.). Whichever language you come from there are likely to be a few minor changes to get used to but the syntax and concepts are familiar enough that you can be up and running in no time at all!

    Is Go ready to be used in prime-time production-ready systems? I definitely think so but if you dont believe me, why dont you ask the Docker Foundation?