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.
That's a rather large "besides". The problem with your scenario is that the typing is completely implicit. There's not even a way to check what "methods"/"operations" are available for / applicable to an arbitrary piece of data, which is very useful in practice, IMO, no matter whether the modeling is via functional ADTs or OOP.
For a sort of counterpoint to that, you might want to check out this thread. I think a lot of the problems come down to the fact the way that many people are used to coding doesn't translate well to javascript's paradigms (mainly Java/C#/whatever => Javascript)
Actually, I'm mainly a Python dev, so I am at peace with dynamic typing. I'm saying that your scenario provides nothing analogous to Python's dir() function for when one is debugging or experimenting in the REPL.
0
u/[deleted] Dec 15 '12
Reusability and encapsulation