Go for Java Programmers

Go, also known as Golang, is a programming language invented by three prominent engineers currently working for Google.  Go is a fairly new language, reaching its initial 1.0 release in 2012.  Born out of a belief that C++ has grown too complex and feature-bloated, Go was originally intended to appeal to systems-level programmers.  However, Go has been most enthusiastically embraced by Python developers, and other dynamic language communities. Go can be described as a best of both worlds.  It offers a light and expressive syntax, comparable to high-level languages.  However, it adds static typing, powerful concurrency support, and raw performance comparable to a low-level language.

Java is a fantastic language for large-scale, large-team enterprise projects.  However, Java requires a fair amount of overhead to spin-up and deploy a new application, and its verbose nature can make it a poor fit for small projects or one-off utility tasks.  Therefore, many Java developers keep one or more secondary languages in their back pocket, to easily tackle side tasks.  Experience with other languages broadens a developer’s horizons, and can improve their abilities when working with Java as well.  Go is a fantastic candidate to serve such twin roles in the Java programmer’s toolbox.

Because Go was conceived as a systems-level language, and has been so deeply embraced by dynamic language communities, much of the resources available for learning Go are aimed at either C/C++ or Python developers.  Go is relatively easy to learn (check out some resources), but there is not a lot of material specifically oriented for newcomers accustomed to thinking in Java.

This series of articles is intended to help fill that gap.  Each topic focuses on one area of Go syntax, or the wider Go ecosystem, and explains it from the perspective of a Java developer.  Thanks for reading, and enjoy your experience with Go!

Topics in the Go for Java Programmers Series

  • Introduction – A more detailed background on Go, and how it can it can benefit you as a Java programmer.
  • Packages, Functions, and Variables – Comparing the differences in basic syntax between Java and Go, starting with these three elements.
  • Control Structures – Presenting Go’s version of if, for, and switch… how they differ from their Java counterparts, and give Go programs all the flexibility they need.
  • Formatting Rules – Go has some strong opinions about well-formatted code and other best practices, and some of these opinions are enforced at the compiler level.
  • Simple Types – Comparing Go’s built-in data types to their Java counterparts.

Future Topics

These are some of the topics planned for this series down the road.  If there are any additional subjects you would like to see included, please don’t hesitate to let me know!

  • Custom Types – Understanding structured data in Go, and how Go’s typing system differs from object orientation in Java.
  • Collection Types – Exploring Go’s core collection types (arrays, slices, maps) alongside the familiar Java Collections framework.
  • All You Need to Know About Pointers – SPOILER… not very much!  This can be an intimidating topic for Java developers, reading Go books that are aimed at C/C++ programmers.  However, Go’s garbage collection and static type-checking eliminate the pitfalls that make this such a hairy subject in low-level languages.  Pointers in Go are surprisingly similar to the way that Java uses them under the covers, even if we as Java developers aren’t used to talking about it.
  • Exception Handling – Examining good practices for dealing with error conditions in Go programs, and how to easily adapt from the familiar try-catch Java model.
  • Builds and Dependency Management – The similarities and differences between the “go” utility and Java build systems such as Maven.
  • Concurrency – Multithreading (and beyond), without the pain.
  • IDE’s and Tools – A look at the ecosystem of tools available for working with Go code… on its own, or alongside your Java tools.
  • Documentation, and Idiomatic Best Practices – Comparing godoc with javadoc, and general best practices for structuring Go code.
  • More to come?…