Re:These are things in PHP which make me sad
by ryan-allen on Friday May 27, 2011 @10:40PM
(#2593738)
I'd say that using closures and functions to create public apis with internal private structure does qualify it to have 'language constructs for public/private'.
It just took programmers collectively over 10 years to figure it out. I blame the 'new' keyword in JS, it feels completely grafted on after the fact.
Lua has been using this method of designing modular programs for years.
I know you can do it, but it produces quite an overhead and it's ugly. But that's for another discussion ("sad things in JS" maybe) - here my main point was that, no, public/protected/private is not a dumb idea in dynamic languages.
Crockford explains with some examples here:
http://javascript.crockford.com/private.html