引言
自己一直在用MooTools架構, 偶然看見這篇文章,作者是MooTools Team的成員之一,講解了jQuery和MooTools的一點點區別,主要是我覺得他寫JavaScript代碼和他的思維方式很值得學習。另外,對 JavaScript的編程思想和對架構的選擇都有很多很好的建議,對於猶豫在各種架構上的人有很好的指導作用,另外對於想深入對架構進行研究或者想自己 開發架構的人也有很好的建議。文章雖然很長,但是我覺得不錯,然後就翻譯了。水平有限,文筆粗陋,其中有少數地方自己都覺得翻譯得有些牽強,歡迎批評指 正。
譯者:Fdream
譯者部落格:Fdream's Blog
原文:jQuery, MooTools, which is the most popular and well represented framework and What Really Makes One Framework Different From Another
標題:
jQuery, MooTools, which is the most popular and well represented framework and What Really Makes One Framework Different From Another
jQuery和MooTools,哪一個架構更受歡迎有更好的表現以及它們之間的真正區別是什麼
I've been experimenting with several javascript libraries as well… the problem is finding the right mix of features… Ext.js is very extensive, but very large and complex: steep learning curve.
我一直在嘗試一些不同的JavaScript庫,試圖找到一些合適的特性組合:Ext.js非常好擴充,但是太大太複雜,學習難度很大。
jQuery is very easy to learn, has some great features, but soon you start looking in the plugins database for much needed functionality that's missing in the official library. The plugin feature is great, but there's a downside as well… soon you get drowned by the number of available plugins, spending a lot time checking out which ones match the quality of the core library. It's a good thing some plugins get listed on the main site, but still, it takes a great deal of effort to find that right mix. I've been working with Microsoft Ajax library as well, but don't like their control extension framework (which is quite complex).
jQuery非常容易學習,有很傑出的特性,但是當你從外掛程式庫裡去找更多的功能時,發現官方的庫裡面根本就沒有。外掛程式特 性非常好,但是也有很不好的地方……很快你就會被無數個可用的外掛程式弄得暈頭轉向,你需要花很多時間去確定哪些外掛程式才和核心庫的品質相匹配。如果首頁上列出 了這些外掛程式還好,但是,還是要花費很大的力氣去找到合適的特性組合。我也同時在使用Microsoft Ajax庫,但是不喜歡他們的控制項擴充架構(它們實在是太複雜了)。
So, I must first attest that hands down, jQuery was the most popular and well represented framework there. They ruled the roost. John Resig (creator of jQuery) spoke 7 times in 3 days, Microsoft demonstrated how jQuery is included in its SDK, and the crowd attending was definitely there to talk about the framework. More than anything, this made it clear to me that jQuery is doing something right.
因此,我必須首先很輕而易舉地證明:jQuery是最受歡迎以及有更好表現的架構。他們是最 好的。John Resig(jQuery的作者)在三天裡曾七次說:“Microsoft示範了怎樣把jQuery包含進了它的SDK,出席會議的人也非常肯定地談論了 這個架構。這些都清楚地讓我看到:jQuery正在做一些正確的事情。”
Part of the task I set for myself in attending the conference was to attend as many of these jQuery sessions as I could both to learn as much of jQuery as I could (I have, in the past, dug into it, but I wanted to soak up as much as I could from the development team and John) and also to see if I could pick up on what accounts for the popularity of the framework.
我去參加這個會議的一部分任務就是儘可能多地參與jQuery的交流和學習(我曾經也很深入地學習過,但是我希望從Team Dev和John那裡學習到更多東西),同時也可以看一下我是否能夠找到這個架構受歡迎的原因。
This requires a bit of explanation. The MooTools team (of which I am a part) has never really focused on how popular the framework is. We are interested in writing it for our own use and for its own sake, but we don't really spend much energy trying to convince other people to use it. We don't consider ourselves adversaries to other frameworks - as I've heard it put on numerous recent occassions, we're at war with the browsers, not each other. In my own posts on the topic, my suggestion to people is to try a couple of options and choose the framework that suits your needs and your styles. You really can't make a bad choice (so please stop arguing about it!). jQuery, Prototype. YUI, Dojo, MooTools - we're all doing the same things just using different methods. More on this in a little bit, because I've started to think about this more lately.
這裡需要一些解釋。MooTools團隊(我也是其中之一)從來沒有真正關注過這個架構有 多受歡迎。我們只是對寫這個架構感興趣,為我們自己使用和它本身目的去寫,但是我們真的沒有花很多精力去讓其他人去使用這個架構。我們從不認為其它架構是 我們的競爭者——因為我曾經在很多場合都聽說過這樣的話,我們在和瀏覽器進行鬥爭,而不是相互鬥爭。在我的這篇文章中,我給你們的建議是:多嘗試一些選 擇,然後選擇適合你的需求和你的風格的架構。你真的不能做一個壞的選擇(因此,請停止爭吵!)。jQuery、Prototype、YUI、Dojo、 MooTools——我們都只是用不同的方法在做同樣的事。關於這一點寫得有點多,因為我最近一直在思考這個。