tag:blogger.com,1999:blog-34454975.post1021997725406688533..comments2023-06-28T16:58:41.189+02:00Comments on Web Reflection: Google Closure ? I'm Not ImpressedAndrea Giammarchihttp://www.blogger.com/profile/16277820774810688474noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-34454975.post-76688901674213312622010-08-18T16:33:36.839+02:002010-08-18T16:33:36.839+02:00they thought in "Java therms" and this w...they thought in "Java therms" and this was the mistake #1 - you cannot hire JavaScript programmers demanding Java as CV requirement, simply two different worlds and by that time, before this post (out basically the day after) and many others, it was more than evident ;)Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-45610105919047452812010-08-18T15:37:08.230+02:002010-08-18T15:37:08.230+02:00Oh snap, I just saw the release date of the post x...Oh snap, I just saw the release date of the post xD Sry for that, but even back then it was pretty nifty though, you just had to think like the guys from google did - even it was sometimes coding 'around' the problems ;PMaik Khttp://www.linux-web-development.denoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-76710912346210276812010-08-18T13:53:11.532+02:002010-08-18T13:53:11.532+02:00Maik, you did the same, commenting without underst...Maik, you did the same, commenting without understanding what you were commenting ... but it does not matter, old post, the compiler has been improved/changed in the meanwhileso if you are happy, we are ;)Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-53643776835153818482010-08-18T12:36:00.545+02:002010-08-18T12:36:00.545+02:00Your conclusion on the Closure Compiler is right. ...Your conclusion on the Closure Compiler is right. And totally wrong. <br /><br />First of all, you can't really compare packer or YUI with the CC for a simple reason: the CC >>compiles<< as it name says, other engines just compress the scripts. So the CC will produce not just less bytes of code, it also will optimize the code.<br /><br />If you read the docs you will see that there are plenty of tips how to use it and that you just can't use some coding styles. I myself used the compiler for some tests and I have to say if you follow the tips in the documentation you can get short, working code thats cleaned up. <br /><br />Saying that it wouldnt have performance improvements is just dumb. I compile my files to an avarage of 20 to 25% of the original size, what is way better than packer or YUI ever did and saving bandwith IS an improvement. Also it kinda seems that unlike packer the scripts don't need to be "unpacked" on the client because it's just the native code compiled, without the need of eval or base62 shrinks(which indeed needs some ms to parse/decode), so the CC runs also faster.<br /><br />Also the CC needs either unobstrusive JS(inline JS is one of the things that bugs me most if I look at the scripts of other developers.. what's so hard about using getElementById or using $ and $$ functions like in most JS libraries?!) or a simple JS file you ommit to the compiler as externs( also described in the docs)<br /><br />So before bashing again something you don't understand first get the technical background... Google did a great job with the compiler and if you just can't understand how to use it( don't get me wrong but most ppl if shown it were just confused) - that might be because the have some of the best programmers ever, that think way more abstract and complex most people/programmers do..Maik Khttp://www.linux-web-development.denoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-15254499208779250462010-02-18T03:05:59.211+01:002010-02-18T03:05:59.211+01:00Re: Closure Compiler
The docs for advanced compila...Re: Closure Compiler<br />The docs for advanced compilation comes with a big red flag. Your code must be tailored for advanced to work. The author of this blog should know that, because he linked to the docs page. Yet he *didn't* tailor his code and then whined when it didn't work.<br /><br />Sorry, but that's your own damn fault.Unknownhttps://www.blogger.com/profile/13111541865595486491noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-89252724310922781282009-11-13T13:07:54.365+01:002009-11-13T13:07:54.365+01:00@kangax
var foo = (function(){
var foo;
i...@kangax<br /><br />var foo = (function(){<br /> var foo;<br /> if(whatever) {<br /> foo = function foo(){/* 1 */};<br /> } else {<br /> foo = function foo(){/* 2 */};<br /> };<br /> return foo;<br />})();<br /><br />Above one is safe without ADVANCED_OPTIMIZER. <br />var foo=function(){var a;return a=whatever?function b(){}:function b(){}}();<br />correctly referenced via var a inside the function body, if necessary.<br />with ADVANCED_OPTIMIZER things change:<br />(function(){return whatever?function a(){}:function a(){}})();<br />IE should have the fallback as last possible one ;-)<br />But I agree this is more about ADVANCED option gotchaAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-64658857605672314112009-11-13T06:22:39.470+01:002009-11-13T06:22:39.470+01:00Just want to link to SitePoint “interview” of mine...Just want to link to SitePoint “interview” of mine concerns about Closure: http://tr.im/badclosureAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-1840338375423902212009-11-11T13:49:04.420+01:002009-11-11T13:49:04.420+01:00@Andrea
I don't think it's abandoned.. bu...@Andrea<br /><br />I don't think it's abandoned.. but probably since then they're just maintaining code. They don't feel about making revolution as "code is already good enough". Probably :)<br /><br />Anyway in Google closure I smell strong background of some other language that's not that close to JavaScript. When they wrote it, they didn't think in ways we (JS hackers) do.. and probably that's why we're a bit disappointed :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-63593233773267512342009-11-10T20:29:55.527+01:002009-11-10T20:29:55.527+01:00Again not surprised, they are not ready for extern...Again not surprised, they are not ready for external committers ... well, Google, what can I say, you have my CV there since ages, use it!<br /><br />(... but I am sure after this post and related comments they would call me just for a fight and nothing else, lol ...)Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-45817136093670902852009-11-10T20:03:18.062+01:002009-11-10T20:03:18.062+01:00All, the reason I've been nit'n'pick w...All, the reason I've been nit'n'pick with this Closure stuff is simple: Google claims best JavaScript hackers and if this is the result I feel like somebody is kidding me.<br /><br />JavaScript is not properly studied at University, where the OO model is the classic one, and there's no degree/Phd about JS logic and techniques.<br /><br />D. Crockford is just one of the examples that JavaScript is more about experience and that we have to deal with a flexible but extremely difficult language due to numerous VM and missed standards (with few gotchas in ECMA 262 itself)<br /><br />Google is probably hiring Java developers with whatever degree pretending they are best JavaScript hackers? AFAIK Google should know that JavaScript is not Java, an error lot of people do out here.<br /><br />Anyway, hopefully they know it, but reading the library code I am starting to think they are seriously missing real JavaScript hackers and since Google uses JavaScript for everything ... well, think about how many other "things" it could have done with real these developers.<br /><br />Some error is not even about the language (crypt method as example) but a logical operation ... Google has extremely interesting projects and best coders for everything but for the main used programming language, JavaScript, there's no interest in devs like me or others?<br /><br />Missed expectations and a bit deluded about what I've found here, that's it about this post.<br /><br />P.S. I have asked in the ML if I can commit, I'll keep the post updated as soon as I'll know the answer.Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-49127032044856448352009-11-10T19:31:24.538+01:002009-11-10T19:31:24.538+01:00@fearphage I do believe 80% of cases that function...@fearphage I do believe 80% of cases that function will be used in the same window context but in any case that is a single reasonable check specific for IE and nothing else rather than 2 checks plus fallback without that "instanceof" possibility and even for standard/updated browsers.Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-9840697540573792872009-11-10T19:21:06.474+01:002009-11-10T19:21:06.474+01:00Someone pointed out that `if(this instanceof Objec...Someone pointed out that `if(this instanceof Object)` fails across frames. This code is all designed to be used across frames. Aside from that, I think you nailed it. It appears to me that Java developers were writing javascript or this is just a really old library. All the browser sniffing (there's <i>lots</i>) also put me off.fearphagehttps://www.blogger.com/profile/17859362971425712481noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-16041787218610667062009-11-10T16:23:16.520+01:002009-11-10T16:23:16.520+01:00@Andrea
I tried with simple and andvanced, and th...@Andrea<br /><br />I tried with simple and andvanced, and they are both harmful like that. Try compiling:<br /><br />alert(f());<br />var f = function(x){ <br /> return 'redefined';<br />};<br />alert(f());<br />function f(x){ <br /> return 'original';<br />}<br /><br />@Kamil <br /><br />Even if func. expressions are translated into func. declarations for debugging purposes (I don't think that's the case), it should be done in a safe manner.<br /><br />Besides, nothing (well, almost nothing) is stopping you from naming function expressions as well.kangaxhttp://thinkweb2.com/projects/prototype/noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-8051530521738488272009-11-10T15:43:55.028+01:002009-11-10T15:43:55.028+01:00Well arr[i] == "thing" is the slowest wa...Well arr[i] == "thing" is the slowest way to populate an array that I know of.. <br /><br />@Andrea and others, just send along your patches. Just because its google doesn't mean it cant be improved. Closure is apparently *good enough* for production use, but constructive criticism and proactive attitude are always appreciated, no matter the size or reputation of the company.Sam-I-Amhttps://www.blogger.com/profile/05557174239716985941noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-61654808711267457832009-11-10T13:40:33.716+01:002009-11-10T13:40:33.716+01:00I believe that changing function expressions (as k...I believe that changing function expressions (as kangax named it) into function declaration is there, because 'var f = function(){};' creates an anonymous (unnamed) function which aren't that nice to debug with Firebug (not sure about the other tools), because stack trace only shows stack of anonymous functions. On the other hand even with stack trace of anonymous functions we do know where they were declared so with that Firebug extension that Google also created I guess it shouldn't matter. Difficult to say - it's often easier to talk than to implement.Kamil Trebuniahttps://www.blogger.com/profile/07588232200621621110noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-22404644205327777062009-11-10T11:05:51.824+01:002009-11-10T11:05:51.824+01:00@medikoo.com are you saying this is abandoned code...@medikoo.com are you saying this is abandoned code? This would make things even worse!<br /><br />I'd love to use the library only if they'll allow me to commit changes so I can reduce size and improve performances. The way the lib is organized is truly good (so not everything is crap)Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-33843503938606913112009-11-10T10:53:59.059+01:002009-11-10T10:53:59.059+01:00I think this code dates 2003-2004 and then it was ...I think this code dates 2003-2004 and then it was probably best organized and most innovative JS library, now clearly it isn't.<br />It is nice to see code that build such legendary products but I'm also not tempted to use it.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-29640072349019838132009-11-10T09:00:59.197+01:002009-11-10T09:00:59.197+01:00ah ah, @dmitry that's another prove. We all kn...ah ah, @dmitry that's another prove. We all know in JavaScript 1.0 === 1 don't we?<br /><br />@kangax did you try with advanced? That is quite obtrusive change maybe var f is considered dead code ... <br /><br />I am sure a tool able to parse JavaScript and tell us where and when some piece of code is unreferenced is more than welcome, but a "compiler" able to make debug harder 'caues it's too greedy, well I would not call Compiler Enterprise Ready if used with advanced option, but I'll test more ASAPAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-74755528990724937242009-11-10T06:49:29.870+01:002009-11-10T06:49:29.870+01:00Another unsafe thing I noticed about Closure Compi...Another unsafe thing I noticed about Closure Compiler is the way it turns function expressions into function declarations.<br /><br />var f = function(){}; <br /><br />becomes:<br /><br />function f(){};<br /><br />These are far from being equivalent, of course, so we end up with harmful behavior where:<br /><br />alert(typeof f);<br />var f = function(){};<br /><br />becomes:<br /><br />alert(typeof f);<br />function f(){}<br /><br />completely changing program output.kangaxhttp://thinkweb2.com/projects/prototype/noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-15295500281347974812009-11-10T04:39:18.740+01:002009-11-10T04:39:18.740+01:00Can’t agree more. In fact I found lots more of rid...Can’t agree more. In fact I found lots more of ridiculous stuff inside closure. I am pretty sure you can do the same with ease. Just another proof that it was written by Java guys:<br />Math.round(factor * rgb1[0] + (1.0 - factor) * rgb2[0])<br />Who else will write “1.0” to ensure it is float?<br />BTW, coming to your first paragraph, I did a tiny research of the home page of Google. It is not as minimised as we use to think: <a href="http://dmitry.baranovskiy.com/post/201475166" rel="nofollow">The Emperor’s New Clothes</a>Anonymousnoreply@blogger.com