News for hackers. Stuff that matters.
Re:These are things in PHP which make me sad by mryall on Friday May 27, 2011 @07:31PM (#2593449)
Even though JS doesn't have language constructs for public/private, there are a number of different ways to write modules with hidden members by use of closures.

Crockford explains with some examples here:

http://javascript.crockford.com/private.html

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.

Re:These are things in PHP which make me sad by Tomek_ on Saturday May 28, 2011 @05:15AM (#2594191)
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.