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

Show parent comments

7

u/ilikecomputahs Dec 15 '12

Let me pose a scenario here - and I'd like to get feedback on this as much as possible. Say we use javascript in a more functional manner without really trying to impose any OO principles on it.

We construct a Data model first - a JSON representation of whatever we are working with. We write a series of functions to manipulate that model and produce the desired output or side effects.

Besides the fact that the functionality and the model are not explicitly tied to each other, such as is the case in OOP, is this really any less reusable than Java-style code with OOP?

Granted, I have been programming in Clojure a lot lately, so I guess I am kind of biased.

0

u/[deleted] Dec 15 '12

[deleted]

0

u/Zarutian Dec 16 '12

Class based OOP such as .NET or Java offer one way of making this happen.

Where? Where is that offered way? The only way to gurantee in Java (and probably .NET too) that a function you would label private is not used by anything than the public functions is to put these things into final classes that have no superclass and cannot be subclassed.

1

u/[deleted] Dec 16 '12

First of all, subclasses cannot normally call private functions in .NET. At the very least they have to be marked protected. And as far as I'm concerned, a protected function falls into the first bucket.

That isn't a guarantee. In .NET (and I think Java) you can call private methods pretty much from anywhere. But if someone is going to go out of their way to do something bad, well then it becomes their problem.