Go? Go is a programming language, created by Rob Pike at Google, which is: • Statically typed • Compiled • Multithreaded • Garbage collected • Created mostly for networked systems, parallel computing and web applications
are resizable, despite having the length and capacity at the beginning. They support “slicing” operations (well known from Python), which get some defined part of slice.
with the other languages? • Inheritance, polymorphism, templating • Languages like C, C++ or Java are quite old • Dependencies in C and C++ scale very poorly • Python or Scala are easy and readable, but very slow • No system-based threading/concurrency in many standard libraries • Many modern languages don’t have pointers, only non-explicit references
in Go In Go you don’t receive the struct as an argument. Writing methods for structs is very similar to writing methods for classes in object-oriented languages.
vs pointer receivers Value receiver will not modify the contents, because it receives the copy of the struct. Pointer receiver will modify the contents, because it has access to the original object in the memory.
vs pointer receiver You can use both kind of receivers regardless of what kind of variable you have. That means that both: f = Foo{} f.SomeMethod() and f = &Foo{} f.SomeMethod() will work. However, it’s not recommended to mix pointer and value receivers in one struct, one of the next slides will explain why.
inheritance Composition is “has-a” relationship. The object A can contain the object B. Type of A can contain a property of type of B. Inheritance is “is-a” relationship. The object A can have the same properties as the object B. Type of A is a subset of type of B.