[WIP] Programming with Go

April 9, 2025

Reflections on the paradigm shift I experienced while transitioning to Go from other languages.

ConceptJavaPythonGoCC++
PrimitivesPass-by-valuePass-by-value (immutable)Pass-by-valuePass-by-valuePass-by-value
ObjectsReference passed by valueReference passed by value (mutable objects can be modified)Structs passed by valueStructs passed by valueCan be passed by value or reference (&)
ArraysReference passed by valueReference passed by value (mutable lists/tuples)Slice header passed by valuePassed as pointer (int arr[])Passed as pointer or reference (int &arr)
PointersImplicit (references)Implicit (everything is an object reference)Explicit (*T)Explicit (*)Explicit (*), but references (&) preferred

Formerly trained more "hands-on" languages like C, C++ and Java, where worrying about pointers, references, garbage collection and pass-by-value/pointer/reference, and eventually shifted to Python for AI/ML-centric software development.

If you're passing a struct by value, you shouldn't expect to be able to modify the struct in any function calls; whereas if you're passing the struct by pointer, that should be expected. Hence when combining with interfaces, the method sets (functions "inherited") of struct addresses should include function that indicate both struct and struct pointers in the receiver, whereas structs only inherit functions with struct receivers. (safety accorded through the interface)

When doing manual calls outside of interfaces, it resolves automatically to allow it either way (oversight is given to the programmer, somewhat like editing dictionaries in Python)

More to come...