Hacker News new | ask | show | jobs
by waynerad 1229 days ago
My unpopular opinion, which is less unpopular than it used to be, is that object-oriented programming is a bad idea -- in particular, inheritance -- and the Go programming language demonstrates that you can write everything you need without object-oriented programming. I learned in school that a language is "object oriented" if it has inheritance, encapsulation, and polymorphism. Some years ago, I was feeling like giant class libraries were very complex and asked if that complexity is really necessary? And embarked on an experiment to see if I could stop using object-oriented programming and do everything with regular functions. I discovered in short order I needed polymorphism, and that objects were the easiest way to do that. Encapsulation is nice to have. But amazingly, I never came across a scenario where I needed inheritance. Shortly thereafter I discovered the Go programming language, which does not have inheritance at all, though it does have polymorphism (through the inheritance keyword) and encapsulation (via control of exports at package boundaries). It's not just me: powerful software like Kubernetes has been written in Go. The lack of inheritance doesn't get in your way and in fact enables polymorphism to work the way it would in an ideal world. The decision to leave out inheritance was really bold on the part of the Go language designers and it is my favorite "feature" of the language.