Go is not OOP

days_64

Python64

Posted on February 27, 2020

Go is not OOP

Go is a programming language that was created as an experiment.

If you programmed in languages like Java, C#, C++ or Python you may be used to having classes and objects everywhere in your code.

It may surprise you that Golang is not object orientated. In fact, Go intentionally leaves out many features of modern OOP languages.

  • No classes. All code is split into packages. Go has only structs.
  • No support for inheritance
  • No Execeptions
  • No generics
  • No annotations
  • No constructors

Everything is just a little bit different, but it's a very powerful language that is great for concurrency.

In 2009 Go came around, during that year multi-core processors were already available. Go is designed while keeping concurrency in mind.

Go has goroutines instead of threads. You can run as easy as

go function()

Compare that to threading in Java! You can spin millions of goroutines at any time.

  • Goroutines have faster startup time than threads.
  • Goroutines use channels (a built-in way to safely communicate between eachother).
  • Goroutines and OS threads do not have a 1:1 mapping. A single goroutine can run on multiple threads. Goroutines are multiplexed into small number of OS threads.
💖 💪 🙅 🚩
days_64
Python64

Posted on February 27, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related