- cross-posted to:
- hackernews@lemmy.bestiver.se
- cross-posted to:
- hackernews@lemmy.bestiver.se
I always find it funny to see calls to “unlearn oop”. It’s a tool, useful in some contexts and not useful in others. At some point industry treated it like a silver bullet, and now people are reacting to it by checks notes treating the hot new paradigm as a silver bullet.
learn oop, learn fp, learn logic programming, learn whatever you want. Also, learn when not to use them.
It’s a tool, useful in some contexts and not useful in others.
In my opinion this is a thought terminating cliche in programming and the IT industry in general. It can be, and is, said in response to any sentiment about any thing.
Now, saying what sort of context you think something should or should not be used in, and what qualities of that thing make it desirable/undesirable in that context, could lead to fruitful discussion. But just “use the right tool for the right job” doesn’t contribute anything.
In my opinion this is a thought terminating cliche in programming and the IT industry in general. It can be, and is, said in response to any sentiment about any thing.
Sure, I agree it can be. But it doesn’t make it less true that “it depends” is often the answer. As I see it, my job is often to think “what applies in this case”. Including thinking about things like:
- what matches the mental model the company has about this
- what’s the shape of the problem
- what type of abstractions do we already use
- what aspect do I want to make available, how is this expected to change?
- etc
Now, saying what sort of context you think something should or should not be used in, and what qualities of that thing make it desirable/undesirable in that context, could lead to fruitful discussion. But just “use the right tool for the right job” doesn’t contribute anything.
Sure. I lean towards object oriented design when things represent a simple well known object with a stable set of “nouns and verbs” that are unlikely to change. In my case this tends to be around UI elements or the data layer very basic things, where I don’t care too much about “data transformation”, but want to encapsulate an action (eg. I think being toggleable is intrinsic to a switch, so switch.toggle feels like a stable api and I can design an object like this that others can understand without having to care about the internals)
Some design patterns that come from the oop tradition (not exclusive to oop, but very much part of the toolkit) that I find exceptionally useful. For example, the strategy pattern is something I’ve used often when building things like data exporter and importer tools. I can structure my logic in this way, move all the specific logic to the leaves.
I can’t be exhaustive, but for me oop is all about encapsulation, and so I use it when it calls for that. I think it also makes APIs easy to test.
——
Functional programming I absolutely love. Whenever I’m transforming data, i think in functional terms. Composable functions, immutable data. It’s just a lot easier, and for me it makes it easier to test processes and operations. I tend to lean to this this in a business logic layer. If I can describe operations in a way that we talk about them in the company, and make those units of transformation testable, then bigger processes become safer and auditable.
Another thing from functional programming languages that I love is things like algebraic data types. It just pains me to use a language without sum types now.
——
A while back I used “aspect oriented programming”. That didn’t catch on, but moving some things like logging, event tracking, etc. to aspects makes sense to me. If a language supports function annotations, I /will/ try to move those sorts of aspects to a function annotation.
——
I spent a while doing prolog, and that language is just something else. I wish I had an easy to embed prolog that I could use for constraints on data. This one I don’t “get to mix and match” because multi purpose languages don’t include aspects of it. But thinking in terms of reversing operations (eg. Given this result, what set of constraints produce it) is still a tool that helps me understand how to shape a problem.
——
There’s a lot of nuance to this, more than can fit in a comment, and definitely nuance that doesn’t apply to imaginary problems or problems/sotuations that we don’t share. Also, you and others will probably think about it differently. to me that’s kind of the point, both thinking in terms of a diverse toolkit, and having a team with diversity of thought.
I, too, have wished to be able to easily embed prolog, or at least its reduced non-turing-complete version, datalog, into a less declarative language.
Also, I think integration with answer set programming for static code analysis could be useful. This is sort of a mid-way point between test driven development and something like the type level programming in languages such as Haskell or semi-automated theorem proving in languages like Coq.
FP has been around a long time, and yes, it is outright better than OOP. Sorry. I write Haskell professionally, and never have I ever felt like something would be easier done in an OOP language. Quite the opposite.
Unrestricted mutation makes programming really hard, and OOP and mutability go hand-in-hand. If you try to make immutable objects, then you’re just doing FP with worse ergonomics.
I would humbly suggest FP may seem especially natural to you precisely because that’s what you use all day.
I mean, I have an OOP background. I found FP as a result of my dissatisfaction with OOP. In fact, I used to teach OOP languages to new students and saw the same mistakes over and over again, mistakes that are simply not possible in FP. It’s a very similar story for everyone I work with, too. We all had jobs in various OOP languages before we managed to get jobs writing Haskell.
Oh, and I’m currently teaching Haskell to someone at work who has a CS degree and has only done OOP languages (and C), and while it’s different than what he’s used to, he’s still picking it up very quickly (working towards making him a junior engineer, which I think shouldn’t take too much longer). In fact, just the other day we pair programmed on a bug ticket I have and he was not only following along with the code, he spotted issues I hadn’t seen yet. Part of it is certainly that’s he smart (which is why I’m doing this in the first place), but part of it is also that, with a bit of familiarity, FP languages are incredibly easy to read and follow. The primary difference is that FP does everything explicitly, whereas OOP encourages a lot of implicit (and hidden) behavior. When you organize code around functions, there’s necessarily more explicit arguments and explicit return values, which makes it far, far easier to follow the flow of logic of code (and test!). Recently I was trying to read through our Kotlin codebase at work (for our Android app), and it was so much harder because so much is implicit.
Please Grok tell me why was I so invested in this discussion, even if I’m not quite sure what OOP is?
It’d be fun to talk shop with the fast code in slow languages folks. I do that for a living. I remember three ways, but I’m sure there’s more:
- “Just use a better data structure”
- “My language is a DSL for a faster language” (Polars, Numpy, etc)
- “My compiler is surprisingly good if I’m careful” (Julia, JVM, etc)
It’s almost always slow is ways that the language choice doesn’t matter even a little
“Key Search Words 101”. Make it quicker and easier to find other programmers solutions on the web.
I’ve never seen a course on functional programming. That would be interesting.
It’s what the Wizard Book (Structure and Interpretation of Computer Programs) was written for.
I had one. I wish I remembered more of it.
i took two courses on functional programming through coursera. it was based on scala.
My uni had one. Sadly I couldn’t fit it into my schedule because of overlaps and other requirements.

I would actually love to take 3300! That sounds fun.
As for 4020, writing performant code in Python typically means calling into libraries that are written in C.
At what level is SOLID good, and when insanity begins.
You have to learn this through suffering. Class would have to be project based.






