by jebarker · 3y ago · 0 comments
In some general sense the principles are applicable everywhere. But trying to actually apply them in some domains is really difficult. For example, I work on developing a large scale ML training framework and I haven't seen an example where avoiding the use of objects and inheritance leads to better code. Having said that, the principles certainly apply lower down the stack when talking about implementing the GPU kernels etc on the hot path.
DOD isn't about "better code" but strictly about "faster code" by letting real-world hardware restrictions dictate how code accesses data (the way I wrote that it may sound like it's a bad thing, but it's really not) - writing software that doesn't fight the hardware it runs on can lead to simpler and easier to maintain code, but that's not guaranteed.
But this wouldn't work for programming language ideologies. Not for the OOP proponents, anyway.
The DOD crowd can at least demostrate how CPU love blasting through data layed out in arrays.
The FP crowd can least explain how the languages can be formalised.
PS ML is the most natural application of dod principles, no?
But things unmeasurable are typically very ephemereal.
Why not? Are you saying that OOP isn't solving any problem?
As I understand it, OOP is mainly about allowing behavior to be reconfigured at runtime. As the introduction to "Design Patterns" puts it: "Polymorphism simplifies the definition of clients, decouples objects from each other and lets them vary their relationships to each other at run-time."
Using this indirection absolutely everywhere probably isn't great for performance, but it seems helpful in moderation.
You're talking about polymorphism, not OOP. While polymorphism also exists in OOP, it is not a concept that is exclusive to it. And polymorphism alone doesn't make OOP.
I certainly would. More precisely, I don’t see OOP having any comparative advantage. I don’t see it being the most suitable tool for any job. Except maybe GUI. And even then I have my doubts.
The actor model though is pretty cool.
That's it, really.
Yes, the principles are helpful and natural in implementing the code that will execute the ML model pass with no unnecessary overhead. But in terms of writing the code that configures and defines a model and the pre- + post-processing, and to some extent dataloaders, it's natural to use objects + inheritance. Now I don't actually think using objects and inheritance are antithetical to DOD but it seems that DOD often gets presented that way.
From the user perspective, it really makes no difference if the same UI was hand coded in assembly or in something much higher level that is still fast because it doesn't work against the CPU, RAM, storage and other things.
And some code gets run on so many devices, by so many users. If starting a phone call took 0.1 seconds longer for all humans on the planet for the next 20 years, even a huge team saving 50 years of their life by cutting a corner and not reducing the delay each would have destroyed more than they gained. And everyone of us uses thousands of programs, millions all in all, and if they all started to prioritize the resources of their makers over yours, it would outpace whatever you can as an individual gain by outsourcing your costs in the same way.
Of course I'm not saying spend twice the time to squeeze out 1% more performance for an installer that's run once. But we are not at risk of that anytime soon; instead we're more in a situation where some people people ship or advocate things that are 10-100 as big as other programs doing the exact same thing, and are ass-backwards and regressive in so many ways. All these github repos with 20 config files and dozens of folders many levels deep, with the "actual" code fitting on a napkin if you added it up, plus a "one-line" install that kicks of a cascade with a gazillion possible failure points. [1]
Partly because so many people flat out don't care, as if actually knowing what is going on under the hood, how the words in the text editor translate into a process, and the wider world it's embedded in, was somehow beneath them (and then they turn around and correctly complain about their managers who treat them like they treat their machines and users). But I think mostly because of this desire to re-invent something badly with a lot of fanfare and in doing that help keep the better thing that exists obscure (especially if that thing is free). That's the majority of professional software development it seems, so I don't worry about which of the laid off people will maintain the discontinued products too much.
[1] Remember NASA World Wind? They had a perfectly fine desktop app before Google Earth existed. Now they have a nodejs thing, so I thought okay, that is something I'll install node for. Alas: https://i.imgur.com/G4mQxjb.png <-- that's the "installer" segfaulting and leaving everything as is. I haven't seen something that bad in like... ever.
And I don't care that I can just roll back, or should have done it in a VM or docker. This, to me, is a joke, and I am not interested in fixing it or using a VM image or anything. I wish the people who maintain that sort of stuff the very best, I think they'll need it.
But lots of stuff isn't that simple, and you end up messily reinventing inheritance with a lot of switches and if statements.
OO has been widely adopted because it maps almost perfectly to most domains.
FP is starting to be adopted because first class support from programming languages and frameworks lowered the barrier to entry by eliminating the need to implement all primitives and infrastructure. FP is being adopted because it maps almost perfectly to some domains.
What's your point, exactly?
So the idea that something would only (easily) apply to academia because it was born out of it feels kind of ridiculous to be honest.
The functional way to make a declarative interface would be to have a single type, `Expression`, and all operators take expressions and return expressions.
However, I would argue the declarative vs. procedural decision is much more important to the resulting code structure then whether you use a single object type or multiple object types with inheritance.
If u squint enough and avoid those baggages and only leverage the type system(hint), then it's kinda usable. U don't have much choices anyway.