3 ms·
IMO with Go. Yes, it eschews object-oriented programming. Yet, funnily enough, whenever I use Go, I am noticing that I can work fine with it when thinking about
by mettamage 5y ago
IMO with Go. Yes, it eschews object-oriented programming. Yet, funnily enough, whenever I use Go, I am noticing that I can work fine with it when thinking about it in an object-oriented way. Structs + methods were all the features I used in object-oriented programming anyway.
- el_oni 5y agoI've been going a similar way. Data and the methods to act upon the data. But i also find myself writing in a more functional style too, limiting the amount of side effects, pure functions when i can manage it. It makes testing so much easier when you don't have to have a bunch of set-up and teardown logic to get your object into the right state before running a test.
- filoeleven 5y ago> Data and the methods to act upon the data. This logical grouping is what Rich Hickey called the attractive thing about objects. So a namespace in Clojure does exactly that: lets you refer to “a logical grouping of data and the functions specific to acting upon it” with a meaningful name. (It also handles the specifying of dependencies, and seems like the right place to do that, but that’s not relevant here.) Clojure also supports private functions with “defn-“ but oddly requires using metadata for binding ns-private vars. I wonder how many folks have written their own “def-“ macro to do this. It’s never come up for me, but I haven’t written production code with it either.
- dgb23 5y agoIt eschews inheritance and achieves polymorphism and abstraction through structural typing and implicit interfaces. Whether it is more "object oriented" than other languages is a bigger discussion.