3 ms·
Generics feel like OOP creeping back into popular programming culture. Everything just goes in a big circle. OOP is the bees knee's for like 20 years and then
by rank0 5y ago
Generics feel like OOP creeping back into popular programming culture.
Everything just goes in a big circle. OOP is the bees knee's for like 20 years and then everyone decides that OOP is the devil for unnecessary abstraction. Then everyone gets all exited about functional programming, but they miss some of the convenience of abstract classes and inheritance.
After developers make sufficient noise, we wind up with effectively the same OOP functionality *GASP. We just avoid words like "class"....
EDIT: You guys are right about generics in FP. I guess my larger point is that lots language paradigms provide the same features just with different names and backlash is silly.
- yashap 5y agoGenerics are wildly, WILDLY popular in functional programming - far more so than in imperative flavours of OOP, really. Basically every functional data structure is full of things like List[A].map(func: A => B): List[B] Also, it’s really not “OOP or functional”, there are tonnes of languages mixing OOP and functional very effectively (Scala is both very functional and very object oriented, but honestly most languages are a mix to some degree). Functional vs. imperative is more of a divide.
- jaytaylor 5y agoAnd yet, FP remains less popular overall than OOP (personally, I love love FP :). Many of the people targeting the most popular FP language of all time aren't writing the Javascripts because it's their first choice. Just look at the pretty WILD popularity of Typescript, an OOP bolt-on language which transpiles to Javascript. The simpler (in some ways) imperative programming model still dominates developer mindset.
- vereis 5y agoTypeScript bringing a half decent type system to JavaScript is orthogonal to OOP JavaScript is OOP already. TypeScript just provides better typing like what you would find in Haskell, Ocaml or other functional languages
- jaytaylor 5y agoYou are technically 100% correct, however the bultin object system in Javascript is so bad that a reasonable argument can be made that it's not particularly accessible or ergonomic to many of the folks who actually write it for a living. I know lots of folks here on HN are super highly competent, and this contrasts with my IRL experience with colleagues who are less passionate about programming and just want to do their job- these folks aren't going to be teaching lessons in proper usage of objects in JS.
- ovao 5y agoIt’s hard to tell, but are you referring to prototypical object inheritance here? If so, JavaScript has long since implemented more traditional class definition ergonomics, such that explicit prototyping is almost largely unused in modern codebases. In truth, even classes are becoming increasingly uncommon in JavaScript codebases, and most object usage in JS these days is struct-like, where the ergonomics are pretty similar (or identical) to other languages.
- herbstein 5y agoGenerics have been used in functional programming before OOP and classes were but a twinkle in a researchervs eye
- Jtsummers 5y agoThey've also been in procedural languages for over 40 years. Ada started with generics and the first spec was published in 1983.
- eweise 5y agoGenerics has nothing to do with OOP
- pie_flavor 5y agoObject-orientation has nothing to do with generics. Generics are static typing v2, object-orientation is an entire programming paradigm encompassing program design, idioms, the fundamental way you think about flow, etc., and doesn't require static typing v1 either. JS, the most object-oriented language under the sun, doesn't have generics; C, the least, does.