Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.java.* > Newsgroup comp.lang.javascript

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2009, 07:09 AM
David Mark
Guest
 
Posts: n/a
Default Google Closure: The Dumb Parts

DOM parts, sorry! Some of them, anyway. There comes a point when
enough is enough and you know you can safely stop reading.

In a few words, appalling and way out of date.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Copyright 2006 Google Inc. All Rights Reserved.

Oops.


/**
* @fileoverview Utilities for manipulating the browser's Document
Object Model
* Inspiration taken *heavily* from mochikit (http://mochikit.com/).

Oh boy.

*
* If you want to do extensive DOM building you can create local
aliases,
* such as:<br>
* var $DIV = goog.bind(goog.dom.createDom, goog.dom, 'div');<br>
* var $A = goog.bind(goog.dom.createDom, goog.dom, 'a');<br>
* var $TABLE = goog.bind(goog.dom.createDom, goog.dom, 'table');<br>

Dollar signs. There's sensible advice.

*
* You can use {@link goog.dom.DomHelper} to create new dom helpers
that refer
* to a different document object. This is useful if you are working
with
* frames or multiple windows.
*
*/

Why do I doubt it?



// TODO: Rename/refactor getTextContent and getRawTextContent. The
problem
// is that getTextContent should mimic the DOM3 textContent. We should
add a
// getInnerText (or getText) which tries to return the visible text,
innerText.


Okaaay.


goog.provide('goog.dom');
goog.provide('goog.dom.DomHelper');
goog.provide('goog.dom.NodeType');

goog.require('goog.array');
goog.require('goog.dom.TagName');
goog.require('goog.dom.classes');
goog.require('goog.math.Coordinate');
goog.require('goog.math.Size');
goog.require('goog.object');
goog.require('goog.string');
goog.require('goog.userAgent');


/**
* @define {boolean} Whether we know at compile time that the browser
is in
* quirks mode.
*/
goog.dom.ASSUME_QUIRKS_MODE = false;


/**
* @define {boolean} Whether we know at compile time that the browser
is in
* standards compliance mode.
*/
goog.dom.ASSUME_STANDARDS_MODE = false;


/**
* Whether we know the compatibility mode at compile time.
* @type {boolean}
* @private
*/
goog.dom.COMPAT_MODE_KNOWN_ =
goog.dom.ASSUME_QUIRKS_MODE || goog.dom.ASSUME_STANDARDS_MODE;


/**
* Enumeration for DOM node types (for reference)
* @enum {number}
*/
goog.dom.NodeType = {
ELEMENT: 1,
ATTRIBUTE: 2,
TEXT: 3,
CDATA_SECTION: 4,
ENTITY_REFERENCE: 5,
ENTITY: 6,
PROCESSING_INSTRUCTION: 7,
COMMENT: 8,
DOCUMENT: 9,
DOCUMENT_TYPE: 10,
DOCUMENT_FRAGMENT: 11,
NOTATION: 12
};


/**
* Gets the DomHelper object for the document where the element
resides.
* @param {Node|Window} opt_element If present, gets the DomHelper for
this
* element.
* @return {!goog.dom.DomHelper} The DomHelper.
*/
goog.dom.getDomHelper = function(opt_element) {
return opt_element ?
new goog.dom.DomHelper(goog.dom.getOwnerDocument(opt_e lement)) :
(goog.dom.defaultDomHelper_ ||
(goog.dom.defaultDomHelper_ = new goog.dom.DomHelper()));
};


/**
* Cached default DOM helper.
* @type {goog.dom.DomHelper}
* @private
*/
goog.dom.defaultDomHelper_;


/**
* Gets the document object being used by the dom library.
* @return {!Document} Document object.
*/
goog.dom.getDocument = function() {
return document;
};


/**
* Alias for getElementById. If a DOM node is passed in then we just
return
* that.
* @param {string|Element} element Element ID or a DOM node.
* @return {Element} The element with the given ID, or the node passed
in.
*/
goog.dom.getElement = function(element) {
return goog.isString(element) ?
document.getElementById(element) : element;
};

How perfectly worthless and inefficient.


/**
* Alias for getElement.
* @param {string|Element} element Element ID or a DOM node.
* @return {Element} The element with the given ID, or the node passed
in.
*/
goog.dom.$ = goog.dom.getElement;


Ugh. They had to pick _that_ one. This is not how to avoid
collisions with other scripts.


/**
* Looks up elements by both tag and class name, using browser native
functions
* ({@code querySelectorAll}, {@code getElementsByTagName} or
* {@code getElementsByClassName}) where possible. This function
* is a useful, if limited, way of collecting a list of DOM elements
* with certain characteristics. {@code goog.dom.query} offers a
* more powerful and general solution which allows matching on CSS3
* selector expressions, but at increased cost in code size. If all
you
* need is particular tags belonging to a single class, this function
* is fast and sleek.
*
* @see goog.dom.query
*
* @param {?string} opt_tag Element tag name.
* @param {?string} opt_class Optional class name.
* @param {Element} opt_el Optional element to look in.
* @return { {length: number} } Array-like list of elements (only a
length
* property and numerical indices are guaranteed to exist).
*/
goog.dom.getElementsByTagNameAndClass = function(opt_tag, opt_class,
opt_el) {
return goog.dom.getElementsByTagNameAndClass_(document, opt_tag,
opt_class,
opt_el);
};


/**
* Helper for {@code getElementsByTagNameAndClass}.
* @param {!Document} doc The document to get the elements in.
* @param {?string} opt_tag Element tag name.
* @param {?string} opt_class Optional class name.
* @param {Element} opt_el Optional element to look in.
* @return { {length: number} } Array-like list of elements (only a
length
* property and numerical indices are guaranteed to exist).
* @private
*/
goog.dom.getElementsByTagNameAndClass_ = function(doc, opt_tag,
opt_class,
opt_el) {
var parent = opt_el || doc;
var tagName = (opt_tag && opt_tag != '*') ? opt_tag.toLowerCase() :
'';

// Prefer the standardized (http://www.w3.org/TR/selectors-api/),
native and
// fast W3C Selectors API. However, the version of WebKit that
shipped with
// Safari 3.1 and Chrome has a bug where it will not correctly match
mixed-
// case class name selectors in quirks mode.
if (parent.querySelectorAll &&
(tagName || opt_class) &&
(!goog.userAgent.WEBKIT || goog.dom.isCss1CompatMode_(doc) ||
goog.userAgent.isVersion('528'))) {
var query = tagName + (opt_class ? '.' + opt_class : '');
return parent.querySelectorAll(query);
}

// Use the native getElementsByClassName if available, under the
assumption
// that even when the tag name is specified, there will be fewer
elements to
// filter through when going by class than by tag name
if (opt_class && parent.getElementsByClassName) {
var els = parent.getElementsByClassName(opt_class);


if (tagName) {
var arrayLike = {};
var len = 0;

// Filter for specific tags if requested.
for (var i = 0, el; el = els[i]; i++) {
if (tagName == el.nodeName.toLowerCase()) {
arrayLike[len++] = el;
}
}
arrayLike.length = len;

return arrayLike;
} else {
return els;
}
}

var els = parent.getElementsByTagName(tagName || '*');

Star with gEBTN leads to problems. Use document.all fallback when
that object is available.

if (opt_class) {
var arrayLike = {};
var len = 0;
for (var i = 0, el; el = els[i]; i++) {
var className = el.className;

// Check if className has a split function since SVG className
does not.
if (typeof className.split == 'function' &&
goog.array.contains(className.split(' '), opt_class)) {
arrayLike[len++] = el;
}
}
arrayLike.length = len;
return arrayLike;
} else {
return els;
}
};

Much ado about nothing.

/**
* Alias for {@code getElementsByTagNameAndClass}.
* @param {?string} opt_tag Element tag name.
* @param {?string} opt_class Optional class name.
* @param {Element} opt_el Optional element to look in.
* @return { {length: number} } Array-like list of elements (only a
length
* property and numerical indices are guaranteed to exist).
*/
goog.dom.$$ = goog.dom.getElementsByTagNameAndClass;

Oh here we go.

/**
* Sets multiple properties on a node.
* @param {Element} element DOM node to set properties on.
* @param {Object} properties Hash of property:value pairs.
*/
goog.dom.setProperties = function(element, properties) {
goog.object.forEach(properties, function(val, key) {
if (key == 'style') {
element.style.cssText = val;
} else if (key == 'class') {

Attribute name, not property.

element.className = val;
} else if (key == 'for') {

Again.

element.htmlFor = val;
} else if (key in goog.dom.DIRECT_ATTRIBUTE_MAP_) {

Incomplete attribute name to property name mapping.

element.setAttribute(goog.dom.DIRECT_ATTRIBUTE_MAP _[key], val);

Result of which is passed to setAttribute. This is the worst attr
yet.

} else {
element[key] = val;

Otherwise set a property with the attribute name. Brilliant.

}
});
};




/**
* Map of attributes that should be set using
* element.setAttribute(key, val) instead of element[key] = val. Used
* by goog.dom.setProperties.

Look again.

*
* @type {Object}
* @private
*/
goog.dom.DIRECT_ATTRIBUTE_MAP_ = {
'cellpadding': 'cellPadding',
'cellspacing': 'cellSpacing',
'colspan': 'colSpan',
'rowspan': 'rowSpan',
'valign': 'vAlign',
'height': 'height',
'width': 'width',
'usemap': 'useMap',
'frameborder': 'frameBorder',
'type': 'type'
};


As mentioned, incomplete and safe to assume the height, width and type
entries aren't needed.


/**
* Gets the dimensions of the viewport.
*
* Gecko Standards mode:
* docEl.clientWidth Width of viewport excluding scrollbar.
* win.innerWidth Width of viewport including scrollbar.
* body.clientWidth Width of body element.
*
* docEl.clientHeight Height of viewport excluding scrollbar.
* win.innerHeight Height of viewport including scrollbar.
* body.clientHeight Height of document.
*
* Gecko Backwards compatible mode:
* docEl.clientWidth Width of viewport excluding scrollbar.
* win.innerWidth Width of viewport including scrollbar.
* body.clientWidth Width of viewport excluding scrollbar.
*
* docEl.clientHeight Height of document.
* win.innerHeight Height of viewport including scrollbar.
* body.clientHeight Height of viewport excluding scrollbar.
*
* IE6/7 Standards mode:
* docEl.clientWidth Width of viewport excluding scrollbar.
* win.innerWidth Undefined.
* body.clientWidth Width of body element.
*
* docEl.clientHeight Height of viewport excluding scrollbar.
* win.innerHeight Undefined.
* body.clientHeight Height of document element.
*
* IE5 + IE6/7 Backwards compatible mode:
* docEl.clientWidth 0.
* win.innerWidth Undefined.
* body.clientWidth Width of viewport excluding scrollbar.
*
* docEl.clientHeight 0.
* win.innerHeight Undefined.
* body.clientHeight Height of viewport excluding scrollbar.
*
* Opera 9 Standards and backwards compatible mode:
* docEl.clientWidth Width of viewport excluding scrollbar.
* win.innerWidth Width of viewport including scrollbar.
* body.clientWidth Width of viewport excluding scrollbar.
*
* docEl.clientHeight Height of document.
* win.innerHeight Height of viewport including scrollbar.
* body.clientHeight Height of viewport excluding scrollbar.
*
* WebKit:
* Safari 2
* docEl.clientHeight Same as scrollHeight.
* docEl.clientWidth Same as innerWidth.
* win.innerWidth Width of viewport excluding scrollbar.
* win.innerHeight Height of the viewport including scrollbar.
* frame.innerHeight Height of the viewport exluding scrollbar.
*
* Safari 3 (tested in 522)
*
* docEl.clientWidth Width of viewport excluding scrollbar.
* docEl.clientHeight Height of viewport excluding scrollbar in strict
mode.
* body.clientHeight Height of viewport excluding scrollbar in quirks
mode.

Somebody wasted a lot of time. The FAQ Notes entry from around the
turn of the century tells the story better than this series of
observations.

*
* @param {Window} opt_window Optional window element to test.
* @return {!goog.math.Size} Object with values 'width' and 'height'.
*/
goog.dom.getViewportSize = function(opt_window) {
// TODO: This should not take an argument
return goog.dom.getViewportSize_(opt_window || window);
};


/**
* Helper for {@code getViewportSize}.
* @param {Window} win The window to get the view port size for.
* @return {!goog.math.Size} Object with values 'width' and 'height'.
* @private
*/
goog.dom.getViewportSize_ = function(win) {
var doc = win.document;

if (goog.userAgent.WEBKIT && !goog.userAgent.isVersion('500') &&
!goog.userAgent.MOBILE) {
// TODO: Sometimes we get something that isn't a valid window
// object. In this case we just revert to the current window. We
need to
// figure out when this happens and find a real fix for it.
// See the comments on goog.dom.getWindow.
if (typeof win.innerHeight == 'undefined') {
win = window;
}
var innerHeight = win.innerHeight;
var scrollHeight = win.document.documentElement.scrollHeight;

if (win == win.top) {
if (scrollHeight < innerHeight) {
innerHeight -= 15; // Scrollbars are 15px wide on Mac
}
}
return new goog.math.Size(win.innerWidth, innerHeight);
}

var el = goog.dom.isCss1CompatMode_(doc) &&
// Older versions of Opera used to read from document.body, but
this
// changed with 9.5
(!goog.userAgent.OPERA ||
goog.userAgent.OPERA && goog.userAgent.isVersion('9.50')) ?
doc.documentElement : doc.body;


return new goog.math.Size(el.clientWidth, el.clientHeight);
};


We've been over this one. Clearly inferior to solutions published ten
years ago.


/**
* Calculates the height of the document.
*
* @return {number} The height of the current document.
*/
goog.dom.getDocumentHeight = function() {
return goog.dom.getDocumentHeight_(window);
};

/**
* Calculates the height of the document of the given window.
*
* Function code copied from the opensocial gadget api:
* gadgets.window.adjustHeight(opt_height)
*
* @private
* @param {Window} win The window whose document height to retrieve.
* @return {number} The height of the document of the given window.
*/
goog.dom.getDocumentHeight_ = function(win) {
// NOTE: This method will return the window size rather than the
document
// size in webkit quirks mode.
var doc = win.document;

Why wouldn't this take a document reference?

var height = 0;

if (doc) {

Whatever.

// Calculating inner content height is hard and different between
// browsers rendering in Strict vs. Quirks mode. We use a
combination of
// three properties within document.body and
document.documentElement:
// - scrollHeight
// - offsetHeight
// - clientHeight
// These values differ significantly between browsers and
rendering modes.
// But there are patterns. It just takes a lot of time and
persistence
// to figure out.

// Get the height of the viewport
var vh = goog.dom.getViewportSize_(win).height;
var body = doc.body;
var docEl = doc.documentElement;
if (goog.dom.isCss1CompatMode_(doc) && docEl.scrollHeight) {
// In Strict mode:
// The inner content height is contained in either:
// document.documentElement.scrollHeight
// document.documentElement.offsetHeight
// Based on studying the values output by different browsers,
// use the value that's NOT equal to the viewport height found
above.
height = docEl.scrollHeight != vh ?
docEl.scrollHeight : docEl.offsetHeight;

Mystical incantation derived from observations.


} else {
// In Quirks mode:
// documentElement.clientHeight is equal to
documentElement.offsetHeight
// except in IE. In most browsers, document.documentElement can
be used
// to calculate the inner content height.
// However, in other browsers (e.g. IE), document.body must be
used
// instead. How do we know which one to use?


Curiouser and curiouser.


// If document.documentElement.clientHeight does NOT equal
// document.documentElement.offsetHeight, then use
document.body.
var sh = docEl.scrollHeight;
var oh = docEl.offsetHeight;
if (docEl.clientHeight != oh) {
sh = body.scrollHeight;
oh = body.offsetHeight;
}


Not like that.


// Detect whether the inner content height is bigger or smaller
// than the bounding box (viewport). If bigger, take the larger
// value. If smaller, take the smaller value.
if (sh > vh) {
// Content is larger
height = sh > oh ? sh : oh;
} else {
// Content is smaller
height = sh < oh ? sh : oh;
}
}
}

return height;
};


/**
* Gets the page scroll distance as a coordinate object.
*
* @param {Window} opt_window Optional window element to test.
* @return {!goog.math.Coordinate} Object with values 'x' and 'y'.
* @deprecated Use {@link goog.dom.getDocumentScroll} instead.
*/
goog.dom.getPageScroll = function(opt_window) {
var win = opt_window || goog.global || window;
return goog.dom.getDomHelper(win.document).getDocumentScr oll();
};


/**
* Gets the document scroll distance as a coordinate object.
*
* @return {!goog.math.Coordinate} Object with values 'x' and 'y'.
*/
goog.dom.getDocumentScroll = function() {
return goog.dom.getDocumentScroll_(document);
};


/**
* Helper for {@code getDocumentScroll}.
*
* @param {!Document} doc The document to get the scroll for.
* @return {!goog.math.Coordinate} Object with values 'x' and 'y'.
* @private
*/
goog.dom.getDocumentScroll_ = function(doc) {
var el = goog.dom.getDocumentScrollElement_(doc);
return new goog.math.Coordinate(el.scrollLeft, el.scrollTop);
};


/**
* Gets the document scroll element.
* @return {Element} Scrolling element.
*/
goog.dom.getDocumentScrollElement = function() {
return goog.dom.getDocumentScrollElement_(document);
};


/**
* Helper for {@code getDocumentScrollElement}.
* @param {!Document} doc The document to get the scroll element for.
* @return {Element} Scrolling element.
* @private
*/
goog.dom.getDocumentScrollElement_ = function(doc) {
// Safari (2 and 3) needs body.scrollLeft in both quirks mode and
strict mode.


So test that property.


return !goog.userAgent.WEBKIT && goog.dom.isCss1CompatMode_(doc) ?
doc.documentElement : doc.body;
};


So the assumption is that Webkit always reports scroll position on the
body. That's obvious rubbish, past, present and future.


/**
* Gets the window object associated with the given document.
*
* @param {Document} opt_doc Document object to get window for.
* @return {Window} The window associated with the given document.
*/
goog.dom.getWindow = function(opt_doc) {
// TODO: This should not take an argument.
return opt_doc ? goog.dom.getWindow_(opt_doc) : window;
};


/**
* Helper for {@code getWindow}.
*
* @param {!Document} doc Document object to get window for.
* @return {!Window} The window associated with the given document.
* @private
*/
goog.dom.getWindow_ = function(doc) {
if (doc.parentWindow) {
return doc.parentWindow;
}

if (goog.userAgent.WEBKIT && !goog.userAgent.isVersion('500') &&
!goog.userAgent.MOBILE) {
// NOTE: document.defaultView is a valid object under Safari 2,
but
// it's not a window object, it's an AbstractView object. You can
use it to
// get computed CSS style, but it doesn't have the full
functionality of a
// DOM window. So for Safari 2 we use the following hack:


Justification for mystical incantation. And what makes them think
this pile will do anything useful in Safari 2?


var scriptElement = doc.createElement('script');
scriptElement.innerHTML = 'document.parentWindow=window';
var parentElement = doc.documentElement;
parentElement.appendChild(scriptElement);


Who told them they could do that?


parentElement.removeChild(scriptElement);
return doc.parentWindow;


Mystical incantation.


}
return doc.defaultView;


Not always the window object.


};


/**
* Returns a dom node with a set of attributes. This function accepts
varargs
* for subsequent nodes to be added. Subsequent nodes will be added
to the
* first node as childNodes.
*
* So:
* <code>createDom('div', null, createDom('p'), createDom('p'));</
code>
* would return a div with two child paragraphs
*
* @param {string} tagName Tag to create.
* @param {Object|string} opt_attributes If object, then a map of name-
value
* pairs for attributes. If a string, then this is the className
of the new
* element.
* @param {Object|string|Array|NodeList} var_args Further DOM nodes or
strings
* for text nodes. If one of the var_args is an array or NodeList,
its
* elements will be added as childNodes instead.
* @return {!Element} Reference to a DOM node.
*/
goog.dom.createDom = function(tagName, opt_attributes, var_args) {
return goog.dom.createDom_(document, arguments);
};


/**
* Helper for {@code createDom}.
* @param {!Document} doc The document to create the DOM in.
* @param {Arguments} args Argument object passed from the callers.
See
* {@code goog.dom.createDom} for details.
* @return {!Element} Reference to a DOM node.
* @private
*/
goog.dom.createDom_ = function(doc, args) {
var tagName = args[0];
var attributes = args[1];

// Internet Explorer is dumb: http://msdn.microsoft.com/workshop/author/
// dhtml/reference/properties/name_2.asp


Pot kettle black.


// Also does not allow setting of 'type' attribute on 'input' or
'button'.
if (goog.userAgent.IE && attributes && (attributes.name ||
attributes.type)) {
var tagNameArr = ['<', tagName];
if (attributes.name) {
tagNameArr.push(' name="', goog.string.htmlEscape
(attributes.name),
'"');
}
if (attributes.type) {
tagNameArr.push(' type="', goog.string.htmlEscape
(attributes.type),
'"');
// Create copy of attribute map to remove 'type' without
mutating argument
attributes = goog.cloneObject(attributes);
delete attributes.type;
}
tagNameArr.push('>');
tagName = tagNameArr.join('');
}


Outrageously bad workaround for a very old problem that is easily
avoided.


var element = doc.createElement(tagName);

if (attributes) {
if (goog.isString(attributes)) {
element.className = attributes;
} else {
goog.dom.setProperties(element, attributes);

We saw what that did.

}
}

if (args.length > 2) {
function childHandler(child) {
// TODO: More coercion, ala MochiKit?
if (child) {
element.appendChild(goog.isString(child) ?
doc.createTextNode(child) : child);
}
}

for (var i = 2; i < args.length; i++) {
var arg = args[i];
// TODO: Fix isArrayLike to return false for a text node.

Cut! That's a wrap. Bury it.
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 11-18-2009, 10:16 PM
David Mark
Guest
 
Posts: n/a
Default Re: Google Closure: The Dumb Parts

On Nov 18, 3:09*am, David Mark <dmark.cins...@gmail.com> wrote:
> DOM parts, sorry! *Some of them, anyway. *There comes a point when
> enough is enough and you know you can safely stop reading.
>


Unfortunately, it seems that loudmouth bloggers have got this all
wrong. Who could have predicted that?

http://www.sitepoint.com/blogs/2009/...e-javascript/#

Promising title: "Google Closure: How Not to Write Javascript".
Unfortunately:-

"His biggest fear, he told me, was that people would switch from truly
excellent JavaScript libraries like jQuery to Closure on the strength
of the Google name"

What this person doesn't realize is that under the hood, these two
scripts are based on the same circa 2006 misconceptions, which were
bunk then and certainly bunk now. It doesn't get any more futile than
deliberately passing (some) property names to setAttribute. Have any
of these guys ever tested anything in IE? You'd think that before
they build "create" wrappers, they would check that the attribute
related methods work as advertised. Of course, the advertisements
(documentation) are usually as inaccurate as the logic (though often
in different ways).

But this one takes the cake:-

http://blog.louisgray.com/2009/11/st...e-googles.html

"On Thursday, Google caught the eyes of Web developers around the
world with the company's move to open source its Closure JavaScript
compiler, library and template system to the Web community - the very
same tools that power popular applications, including GMail, Google
Docs, Google Maps, Google Reader, and no doubt many others."

Oh, no doubt. And where have I seen that list before? Oh yeah, it
was Jorge's "argument" for Google's alleged browser scripting
proficiency. Other than GMail, which nobody (sane) would tout as a
competent example. The rest of them are the usual Google suspects.
They've been throwing exceptions and blocking "unsupported" browsers
for years. Who would want to replicate these awful results? And I
know, the sites are just so popular. That's hardly a validation of
their incompetent programming (more a validation of their marketing
budget).

So they've actually been _using_ this tripe all these years. That
fits.

"Closure tools optimize Web code to be compact and high-performance,
essentially reducing page load and redraw times while also enabling
uncompromising capabilities."

He must have been looking at some other script. The one I saw was
horribly inefficient (appallingly so). And for a script called
"Closure" it is very strange that it doesn't exploit closures at all.
Kind of like how Prototype tried to work around prototypal
inheritance. And their "compiler" isn't going to be able to do much
with all of those goog.* references. What were they thinking?

"Around the Web, you could see the release elated geeks both inside
and outside Google, many of whom previously worked with the tools
while working for the Mountain View tech giant."

I really dislike gushing fools. They give others very bad ideas.
What (sane) user of Google web properties would be elated that Google
is dumping their battered old blob of bad practices and blithering on
the unsuspecting open source community (which is in bad enough shape
as it is).

"The Closure compiler dates back to GMail's launch in April of 2004.
Paul Buchheit, now of Facebook, via FriendFeed and previously Google,
largely credited for the founding of GMail, highlighted the
announcement this week on his FriendFeed, calling it the "Gmail
JavaScript compiler". The library and template system were initiated a
few years following."

There it is. GMail as a selling point. Paul, take your "Gmail
JavaScript (sic) compiler" and...

"With Closure implemented, benefits to Google Reader users are clear.
Mihai estimates that without Closure, Reader's JavaScript code would
be a massive 2 megabytes, which reduces to 513 kilobytes with Closure,
and all the way down to 184 kilobytes using gzip, supported by nearly
all browsers"

Pimping GZIP and http compression. It's always the same. And 2MB
without the magical "Closure" tools? What size would it have been if
Mihai knew the first thing about browser scripting?

"The excitement around Closure's release was palpable from developers
through Silicon Valley and beyond as you could see from blog posts by
Erik Arvidsson, a co-creator along with Dan Pupius, and a series of
posts at bolinfest.com. Other excited Tweets came from Mike Knapp, the
aforementioned Chris Wetherell and Kushal Dave."

Who are these people? Have they even glanced at this code? Perhaps
they figure if they use Google's Javascript (from 2006), it will turn
them into a behemoth in 2009. Good luck with that.

"As Mihai says, "You can tell that there's something special about
this when you look at the ex-Googlers cheering about its release. If
it had been some proprietary antiquated system that they had all been
forced to use, they wouldn't have been so excited that it was out in
the open now."

But it is a proprietary and (very) antiquated system. It would have
been unacceptable in 2001. Today it is just a peek into the lunacy
that was/is Google JS. What ex-Googlers are cheering about that?
Perhaps they wrote some or all of it and really think they did a good
job.

"Now clearly I'm no developer beyond simple HTML and JavaScript, but I
know good Web apps when I see them, and Google's Web apps (as well as
Brizzly) are among the best in the world."

Good night. Let the jQuery vs. Closure blithering begin...
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Groups currently not forwarding to [comp.lang.c++.moderated] Alf P. Steinbach Newsgroup comp.language.c++.moderated 1 09-24-2009 08:44 AM
How to understand this form (something) (param); john_woo Newsgroup comp.lang.javascript 56 08-07-2009 06:37 PM
Auto Parts Warehouse and Parts Train Services kizk Newsgroup comp.lang.c 0 08-02-2009 07:26 AM
OT Re: Google docs IS as secure AS ajay ohri Newsgroup comp.soft-sys.sas 0 11-15-2008 07:16 AM
Re: OT for a Friday: A new-to-me Google Feature Schechter, Robert S Newsgroup comp.soft-sys.sas 0 01-28-2005 06:28 PM



All times are GMT. The time now is 02:26 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.