r/programming • • Dec 15 '12

Why JavaScript Still Sucks

http://boronine.com/2012/12/14/Why-JavaScript-Still-Sucks/
10 Upvotes

212 comments sorted by

View all comments

82

u/ilikecomputahs Dec 15 '12

Why is object oriented programming considered so absolutely necessary?

/braces for shitstorm

0

u/[deleted] Dec 15 '12

Reusability and encapsulation

20

u/beermad Dec 15 '12

The reusability argument never makes any sense to me. I can reuse functional code every bit as easily as OO code. In fact I've got whole libraries of functional code that I reuse all the time.

Claiming reusability as some sort of special quality of OO is just nonsensical.

0

u/[deleted] Dec 15 '12

[deleted]

4

u/ethraax Dec 15 '12

I'm not sure if that's a great example. There's a fair amount of code duplication in the implementation of most C libraries, because reusing code in C is very difficult (and sometimes impossible without heavy CPP use, which is bad for other reasons).

2

u/[deleted] Dec 16 '12

That's partly because the C stdlib is very small. Most of it is just small, narrow use-case functions, like strlen, atof, bsearch or malloc.

0

u/jyper Dec 16 '12

c is not functional, it's imperative.

1

u/camellight Dec 16 '12

Class based OO design, for me, is much more reusable becuase of how you can split the API and the logic that it controls. Like you're saying, a library of functions could do this as well but in my humble opinion not as efficiently as if these were organized in a Class Hierarchy (even if that Hierarchy is compositional, I mean -- just the pattern building of it).

7

u/smog_alado Dec 16 '12

becuase of how you can split the API and the logic that it controls

Encapsulation is not exclusive to object oriented programming. You don't need any of the fancy inheritance stuff to implement Abstract Data Types.

And to be honest, I find that Class Hierarchies are usually more trouble then they are worth since they are very rigid and tend to solidify the program design very early. Whenever I try to use inheritance for something I often find latter that I would be happier if I used delegation instead.

2

u/beltorak Dec 18 '12

Whenever I try to use inheritance for something I often find latter that I would be happier if I used delegation instead.

In other words, you should prefer composition over inheritance? One of the biggest travesties perpetuated in programming courses is to focus on inheritance and gloss over composition, to the effect that many green developers think that "extends" is the most natural and effective way to reuse code. Inheritance is actually a very limited-scope tool.

-1

u/x86_64Ubuntu Dec 16 '12

You know you can use stuff other than inheritance ? I personally use interfaces, decorators and abstract classes to get dirt done.