4 ms·
I don't see why "Object Orientated Programming" requires for loops, over map / streams (which Java has). Is there a definition of "OOP" which requires using fo
by CJefferson 7y ago
I don't see why "Object Orientated Programming" requires for loops, over map / streams (which Java has).
Is there a definition of "OOP" which requires using for/while? This doesn't really sure any OOP at all.
A better example would be to show a case where OOP would be useful, say having a base class and deriving it several times (iostreams for example). Show me how FP does somewhere where (traditionally) OOP is considered strong.
- anaphor 7y agoHaving for/while loops definitely isn't fundamental to OOP at all. Languages like Erlang and Racket capture the essence of OOP fairly well, yet you don't need to use loops to write programs in them.
- ChrisSD 7y agoIt depends what you mean by "OOP". Generally most mainstreams programming languages are mixed: that is they support more than one paradigm (e.g. procedural, class based OOP, functional, etc). Though I've noticed that programmers these days often equate OOP with classes. Therefore anything with classes is OOP whereas anything without isn't. This comes up a lot with languages, such as Rust, that are OOP but lack the class keyword.
- commandlinefan 7y ago> I don't see why "Object Orientated Programming" requires for loops Yeah, I think he (and most people who talk about FP vs. OOP) actually use OOP as a short-hand for "not FP": Scala is actually very object-oriented and very functional at the same time; they're not mutually exclusive.
- ezrast 7y agoAgreed. Ruby is a very fundamentally OO language, but its Enumerable interface is more comprehensive than many FP languages' equivalents (in addition to the standard map/reduce/select, it has methods for iterating over permutations of elements, n-sized slices, etc, all of which can be made lazy), and because it's an interface you can use it with custom data types easily. But FP enthusiasts often speak as if the ML and Lisp language families have a duopoly on higher-order functions. It's odd.