9 ms·
>Apparently oop as envisioned by Alan Kay was supposed to work like cells in the body that pass messages between each other and take actions independently. IIR
by javajosh 3y ago
>Apparently oop as envisioned by Alan Kay was supposed to work like cells in the body that pass messages between each other and take actions independently.
IIRC he was interested in an abstraction that worked "all the way up" - he wanted the abstraction to essentially be a tiny computer. It's a cool idea with a lot of power. But it really is too powerful for applications, and leads to the same complexity problems you get in large distributed systems. And to not have 'function' as a primitive is inexcusable in any language.
Java's lack of a function primitive is a key weakness. It means you must have at least one "utility class" per project - a public class with static methods that are themselves simple functions. (The relatively recent introduction of lambdas, or anonymous inner classes, does not really address the problem. That's just ugly syntax sugar).
- jayd16 3y agoIs the fact that static methods in Java need to be namespaced to a class really anything to even worry about? Like, whats even a single issue with it?
- deleted 3y ago[deleted]
- brianide 3y agoPersonally issue with it (besides the pointless noise of having to make a private constructor and such) is that you can't alias them like you can with actual namespaces/modules in most languages, which becomes a pain when eg. you need functions from both Apache's StringUtils and your own StringUtils in the same file.
- jayd16 3y agoAh, I suppose it can get wordy in Java. I'm more used to C# where you can alias the class name if need be.
- extasia 3y agoTheres an argument that it teaches new programmers poor habits.
- deleted 3y ago[deleted]
- thfuran 3y agoWhat poor habit and what argument?
- nailer 3y agoUnnecessary wrappers. Obviously anything longer than print('hello world') is a waste. If the language violates Exupery's law why shouldn't developers?
- __MatrixMan__ 3y agoGenerally it goes with unnecessary boilerplate that gets copied around without any thought to whether it's necessary. People who have been harmed by too much oop won't just define a function and call it. They'll define a class solely to contain that function and then call it more verbosely. On the face of it it's not that bad but once you start tolerating a habit for doing things because that's how they're done and not because you actually think it's the right way you end up picking up all of these fragments from places where they do belong and forcing them into places where they don't. Or at least, that's what I struggled with when I was new and insecure and wanted people to look at my code and think that I knew what I was doing because I showed evidence of knowing the dogmatic patterns, and I've seen it in others too.
- AtlasBarfed 3y agoClasses are basically namespaces, and trivial code doesn't need them, but quickly you do. A lot of the criticisms being leveled here at oop actually me question their programming experience. There are many valid criticisms, but not a lot levelled here.
- prewett 3y agoThe problem with Java's everything-must-be-a-class OO fundamentalism is that a computer is actually has data AND executable code. Java forces everything into a noun (class/data), but some things are actually verbs. You can these because they have awkward names, like Runnable. See Steve Yegge's rant: https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html https://steve-yegge.blogspot.com/2006/03/execution-in-kingdo...
- jayd16 3y agoOh sure. Java should have had function pointers sooner. The functional interfaces are just ok. C#'s actions and delegates are a bit better, imo. But the parent went so far as to say that scoping functions to a class name is bad and I just don't see it. I think a pure global scope would make Java worse.
- wizofaus 3y agoYou've never seen Java (or C#) code where a bunch of unrelated functions belong to some meaningless class like "Utility"? I do think both languages would benefit from allowing/ encouraging namespace-level functions (C# comes close with static classes but that's pretty clearly an abuse of any logical definition of the word "class"). However I probably wouldn't use them for implementing "controllers" in web applications - while I tend to agree it's not a good use of OOP, having key information about the current request/response available via properties of the current controller (and hence kept separate from function-level parameters that represent semantics specific to the endpoint being handled) plus various built-in functionality at the framework-supplied "controller" level isn't something I'd see a benefit in giving up. But I'll admit there are few cases where a single controller class with methods for various CRUD like operations on a particular resource type makes any sense from an OOP perspective. I did think for C# what might actually work is to be able to define extension methods on the framework Controller class and have an automatic routing mechanism based on convention (e.g. if you defined an extension function "Get_Widget" then GET requests to /widgets would be automatically routed to it. Or it could be based on the namespace). But in general it would likely make the code more verbose (lack of implicit "this") for questionable gain.
- igouy 3y ago> And to not have 'function' as a primitive… "A block is essentially an anonymous function." [ :x | 1 + x ] value: 2 ⇒ 3 https://cuis-smalltalk.github.io/TheCuisBook/Block-syntax.html https://cuis-smalltalk.github.io/TheCuisBook/Block-syntax.ht...