From: VK on 6 Jun 2010 10:15 Recently discussions arose about CC, its authorship and usage priority. As an introduction I want to remind that the "obviousness" of something doesn't make it automatically a community invention nor implies its quick realization. The idea of stickers is damn obvious, but only one person in the whole factory realized how to use the weak glue produced by mistake. The fact that something is well-know and commonly used doesn't eliminate the fact that someone first did it and shared it with others (or others saw it and copied). The idea of dynamic script insertion using document.write(scriptTagWithSrc) is damn obvious and used by nearly everyone. Yet Appeon Corporation from San Jose has proofs of having it invented and first used which are convincing enough for the US patent bureau: so many are using for years a patented technology: http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PALL&p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&r=1&f=G&l=50&s1=6941562.PN.&OS=PN/6941562&RS=PN/6941562 without paying patent fees only because of the good-hardness of Mr. Gao Yang and Co. See also http://jsnet.sourceforge.net/ Now back to the CC: its core concept and usage samples were developed in two independent works: "Private Members in JavaScript" by Douglas Crockford (2001) http://www.crockford.com/javascript/private.html and "Private Static Members in JavaScript" by Richard Cornford (2003) The article is gone but still available over Wayback Machine: http://web.archive.org/web/20031205082329/http://www.litotes.demon.co.uk/js_info/private_static.html (In "Cornford-Crockford Scope Management" name order is alphabetical) It became the "common knowledge everyone knows" with AJAX explosion, when it became necessary to keep "this" pointer between state change calls. Same time the first big wave of C++ and Java programmers was forced to start working with JavaScript and they needed Her Majesty Encapsulation immediately. Note: if something is not encapsulated, a real C++'er or Java'er cannot eat, dring and sleep. She can create a memory killing ineffective monstrosity and happy leave for the week- end. If something left non-encapsulated, the week-end mood will be spoiled completely. As a result CC became severely overused. This madness is still in effect but thanks God lesser than in 2005-2006 CC Scope Management and its terminology didn't appear from nothing of course. First of all nested functions never were kept in secret. They were always mentioned in Client-Side JavaScript Reference at Netscape Developer Center: http://docs.sun.com/source/816-6408-10/function.htm#1225385 But they were just mentioned without any samples of how it could be used and why. I have an impression - possibly a wrong one - that for Netscape JavaScript team it remained just as a bizarre side effect of the original design. The first ever known to me use of the term "closure" in JavaScript sense occurred not in JavaScript but Perl book. In August of 1998 the 1st ed. of "Perl Cookbook" by Tom Christiansen, Nathan Torkington appeared in stores and became very popular. In that book the section "10.16 Nesting Subroutines" describes nested functions in Perl: <quote> 10.16 Nesting Subroutines .... sub outer { my $x = $_[0] + 35; local *inner = sub { return $x * 19 }; return $x + inner(); } .... Now inner() can be called only from within outer() because of the temporary assignments of the closure. </quote> So it was plenty of sources and hints to make 2 and 2 together, yet some people did it first.
|
Pages: 1 Prev: HTML 5 Demos on Apple.com Next: Encapsulation in JavaScript |