1 of 8

Slide Notes

DownloadGo Live

Learning Golang

Published on Nov 24, 2015

No Description

PRESENTATION OUTLINE

Learning Golang

Why it might make you a better programmer

Developed by Google in 2007
C-like syntax
Concurrency support

Go - known for a number of things:

- created by engineers at Google and used by them

- Syntax is loosely based on C, with a few different features

- Language supports concurrency

=> designed for large distributed systems

This has some interesting benefits of novice programmers...

Compiler says no...

Initially one of Go's most frustrating features.

- Your programs will not run if, for example you have unused variables, or import external packages and don't use them

It makes playing around difficult at first, but it means you consistanty write tidy code - you never have to worry about removing useless bits of code before production. They can't exist

All errors must be handled

As a novice developer, I hated error handling:

- takes ages
- boring
- these things might never happen

Obviously this is a bad attitude, things can and do go wrong.

In Go, you can't throw exceptions, errors are variables, so lots of code like this:
- function returns err, since you can't have unused variables, if the error isn't nil, you must handle it.

This is great - forces you to consider error handling as you go, not an afterthought

Readable code is encouraged

2. Applications are organised intuitively


Go applications are organised into packages.

Sample project structure for a photo mosaic app.

There are 3 packages in the project:
main the default package, imagesource
editor.


Code is shared by all files within these packages,
Test files conveniently reside in the same directories as the files themselves.

Very easy to set up and understand directories quickly.

3. Small langauge

Getting familiar with Go can be done relatively quickly because Go is a small language - the spec is only 50 pages long.

it's quick and easy to get to know the codebase and read and write the language yourself.

Any questions?

Go has interesting features that make it useful, not just for building large networked applications, but also for learning and maintaining good programming practices.
- writing clean code
- handling errors
- writing readable applications

Catch me on twitter, and I'm just starting up a blog.

Any questions?