UPDATE 1/14/2012: Added Batman.js and Angular.js due to popular demand and because they looked impressive.
Over the last several months I have been in a constant search for the perfect javascript MVC framework. Driven by a dire need for the right level of abstraction and features, I have tried out - some more cursorily than others - every framework I could get my hands on. Here lies a brief synopsis of each framework. Lastly, I share the framework which I ultimately decided on.
Specifically, the following four features are very important to me:
- UI Bindings - I’m not just talking about templates, I’m talking about a declarative approach to automatically updating the view layer when the underlying model changes. Once you have used a framework (such as Flex) that supports UI bindings, you can never go back.
- Composed Views - Like all software developers, I enjoy creating modular reusable code. For this reason, when programming UI, I would like to be able to compose views (preferably at the template layer). This should also entail the potential for a rich view component hierarchy. An example of this would be a reusable pagination widget.
- Web Presentation Layer - We are programming for the web here people, the last thing I want are native-style widgets. There is also no reason for a web framework to create it’s own layout manager. HTML and CSS are already the richest way to do style and layout in existence, and should be used as such. The framework should be centered around this concept.
- Plays Nicely With Others - Let’s face it, jQuery is pretty amazing. I don’t want a framework which comes bundled with a sub-par jQuery clone, I want a framework which recommends using jQuery itself.
The Contenders
Here is a table showing all of the frameworks support for the above features. Click through the title for more detail.
Backbone.js | ✗ | ✗ | ✓ | ✓ |
SproutCore 1.x | ✓ | ✓ | ✗ | ✗ |
Sammy.js | ✗ | ✗ | ✓ | ✓ |
Spine.js | ✗ | ✗ | ✓ | ✓ |
Cappuccino | ✓ | ✓ | ✗ | ✗ |
Knockout.js | ✓ | ✗ | ✓ | ✓ |
Javascript MVC | ✗ | ✓ | ✓ | ✓ |
Google Web Toolkit | ✗ | ✓ | ✗ | ✗ |
Google Closure | ✗ | ✓ | ✓ | ✗ |
Ember.js | ✓ | ✓ | ✓ | ✓ |
Angular.js | ✓ | ✗ | ✓ | ✓ |
Batman.js | ✓ | ✗ | ✓ | ✓ |
1. Backbone.js
Backbone.js is the web’s darling framework. You can’t go anywhere without hearing about it and they have an impressive list of brands using it. This was naturally one of the first frameworks I tried. I used it to build some of our internal administrative features at GroupTalent.
Pros: Strong community and lots of momentum. Underscore.js (which it uses heavily) is also a great framework.
Cons: Lacks strong abstractions and leaves something to be desired. The entire framework is surprisingly lightweight and results in lots of boilerplate. The larger an application becomes, the more this becomes apparent.
2. SproutCore 1.x
SproutCore is what Apple used on its iCloud initiative. Despite having a horrible name, it is actually an extremely well thought out framework. It is also one of the largest frameworks.
Pros: Bindings support. Solid community. Tons of features.
Cons: Overly prescriptive. Hard to decouple from unneeded features. Forces a native-like paradigm. I have a serious problem with any framework which discourages using html for layout.
3. Sammy.js
Sammy.js was a smaller framework that I stumbled upon. Due to its simplicity, it almost didn’t make this list. It’s core feature is a routing system to swap out areas of an application with AJAX.
Pros: Simple learning curve. Easier to integrate with an existing server side app.
Cons: Too simple. Not sufficient for larger applications.
4. Spine.js
Based on the name, Spine.js is obviously heavily influenced by backbone. Like backbone, it is very lightweight and follows a similar model.
Pros: Lightweight with good documentation.
Cons: Fundamentally flawed. A core concept of spine is “is asynchronous UIs. In a nutshell, this means that UIs should ideally never block”. Having built a serious non-blocking realtime application in the past, I can say this is entirely unrealistic unless the backend has something like operational transformation.
5. Cappuccino
Cappuccino is one of the more unique frameworks, coming with its own language Objective-J. Cappuccino tries to emulate Cocoa in the browser.
Pros: Large thought-out framework. Good community. Great inheritance model.
Cons: Out of all the languages you could emulate in javascript, Objective-C would be my last choice. This is coming from an iOS developer. I simply can’t get past the idea of programming Objective-J in the browser.
6. Knockout.js
Knockout.js is an MVVM framework that receives lots of praise from its supporters. It stresses declarative UI bindings and automatic UI refresh.
Pros: Binding support. Great documentation and amazing tutorial system.
Cons: Awkward binding syntax and lacks a solid view component hierarchy. I want to be able to reuse components easily. I also feel like identifying as an MVVM framework is deleterious. Hardly any of these frameworks are MVC, but are of the MV* variety (MVP, MVVM, etc).
7. Javascript MVC
Javascript MVC, in the interest of full disclosure, is a framework that I didn’t spend very much time evaluating.
Pros: Solid community and legacy.
Cons: Awkward inheritance model based on strings. Controllers are too intimate with views and lack bindings. The name is way too generic - the equivalent would be if RoR was called “Ruby Web Framework”.
8. Google Web Toolkit
GWT is a serious client-side toolkit that includes more than just a framework. It compiles Java to Javascript, supporting a subset of the standard java library. Google used it internally for Wave.
Pros: Comprehensive framework with great community. Solid Java-based component inheritance model. Great for behemoth client-side applications.
Cons: Despite what Google says, GWT is not going to stand the test of time. With initiatives likeDART its clear that Java is not the future of the web. Furthermore, the abstraction of Java on the client is slightly awkward.
9. Google Closure
Google Closure is more of a toolkit than simply a javascript framework. It comes bundled with a compiler and optimizer.
Pros: Use by Google for many of their major apps. Nice component-based ui composition system.
Cons: Lack of UI-binding support.
10. Ember.js
Ember.js (formerly Amber.js SproutCore 2.0) is one of the newest contenders. It is an attempt to extricate the core features from SproutCore 2.0 into a more compact modular framework suited for the web.
Pros: Extremely rich templating system with composed views and UI bindings.
Cons: Relatively new. Documentation leaves lots to be desired.
11. Angular.js
Angular.js is a very nice framework I discovered after I originally posted this review. Developed by Googler’s, it has some very interesting design choices.
Pros: Very well thought out with respect to template scoping and controller design. Has a dependency injection system (I am a big fan of IOC). Supports a rich UI-Binding syntax to make things like filtering and transforming values a breeze.
Cons: Codebase appears to be fairly sprawling and not very modular. Views are not modular enough (will address this in more detail in the cons of Batman.js).
12. Batman.js
Batman.js, created by Shopify, is another framework in a similar vein to Knockout and Angular. Has a nice UI binding system based on html attributes. The only framework written in idiomatic coffeescript, it is also tightly integrated with Node.js and even goes to the extent of having its own (optional) Node.js server.
Pros: Very clean codebase. Has a nice simple approach to binding, persistence, and routing.
Cons: I very much dislike singletons, let alone the idea of enforcing singleton controllers. Suffers from the same ailments as Knockout and Angular with regards to nested components. I want to be able to declaratively reuse more than just templates. What Ember has over these frameworks is a way to declaratively re-use entire components that are backed by their own (possibly controller-level) logic.
The Winner
At the end of the day, Ember.js is the only framework which has everything I desire. I recently ported a relatively small Backbone.js application over to Ember.js and, despite some small performance issues, I am much happier with the resulting code base. Being championed by Yehuda Katz, the community around Ember.js is also amazing. This is definitely the framework to watch out for.
Of course this list is far from comprehensive. Almost all of these frameworks here were discovered by sheer notoriety, word of mouth, or by being mentioned on Hacker News. I am also not reviewing proprietary frameworks (or frameworks with disagreeable licenses - ExtJS anyone?).
What MVC framework do you use?
相关推荐
scratch少儿编程逻辑思维游戏源码-工厂逃生.zip
房地产 -辉盛阁项目介绍.pptx
少儿编程scratch项目源代码文件案例素材-新拉力赛.zip
scratch少儿编程逻辑思维游戏源码-混乱弹球.zip
scratch少儿编程逻辑思维游戏源码-过马路.zip
少儿编程scratch项目源代码文件案例素材-侠盗地牢冒险.zip
少儿编程scratch项目源代码文件案例素材-我的领土.zip
scratch少儿编程逻辑思维游戏源码-机器人闯关.zip
少儿编程scratch项目源代码文件案例素材-天空中的英雄.zip
少儿编程scratch项目源代码文件案例素材-突击尖峰.zip
“即刻青旅”前景广阔,随着青年旅舍行业快速发展,2030年市场规模预计达650亿。创作旨在为年轻旅行者打造专属平台,填补国内专门青旅预定空白。融合微信小程序、Spring Boot等技术,实现青旅查询预定、订单管理、活动职位查看及社区分享等功能。 后端框架: 基于Java的SpringBoot快速开发框架 借助Mybatis-plus构建ORM模型进行数据库操作 第三方API:高德地图、腾讯地图
少儿编程scratch项目源代码文件案例素材-像素猫3.zip
内容概要:本文是一份详细的10bit 50MHz SAR ADC学习指南,旨在帮助新手掌握从基础理论到实际电路设计的全过程。文中详细介绍了Cadence仿真工具的应用以及SMIC 40nm工艺库的具体使用方法。重点讲解了栅压自举开关、CDAC(电荷再分配模数转换器)、比较器和SAR逻辑等核心模块的设计原理和技术要点。此外,还提供了测试电路的构建方法及其性能评估手段,如INL/DNL曲线绘制。最后提到了更高性能TI ADC的扩展接口,为后续深入研究打下基础。 适合人群:对模拟集成电路设计感兴趣的电子工程专业学生或刚入行的研发人员。 使用场景及目标:适用于希望深入了解SAR ADC架构、提高自身硬件设计能力的学习者;目标是在实践中掌握关键技术和优化技巧,能够独立完成类似项目的开发。 其他说明:文章不仅提供理论知识,还包括大量实用的操作提示和常见错误避免建议,有助于读者快速上手并减少试错成本。
scratch少儿编程逻辑思维游戏源码-防空火力 3D.zip
智慧消防安全与应急管理是现代城市安全管理的重要组成部分,随着城市化进程的加速,传统消防安全管理面临着诸多挑战,如消防安全责任制度落实不到位、消防设施日常管理不足、消防警力不足等。这些问题不仅制约了消防安全管理水平的提升,也给城市的安全运行带来了潜在风险。然而,物联网和智慧城市技术的快速发展为解决这些问题提供了新的思路和方法。智慧消防作为物联网和智慧城市技术结合的创新产物,正在成为社会消防安全管理的新趋势。 智慧消防的核心在于通过技术创新实现消防安全管理的智能化和自动化。其主要应用包括物联网消防安全监管平台、城市消防远程监控系统、智慧消防平台等,这些系统利用先进的技术手段,如GPS、GSM、GIS等,实现了对消防设施的实时监控、智能巡检和精准定位。例如,单兵定位方案通过信标点定位和微惯导加蓝牙辅助定位技术,能够精确掌握消防人员的位置信息,从而提高救援效率和安全性。智慧消防不仅提升了消防设施的管理质量,还优化了社会消防安全管理资源的配置,降低了管理成本。此外,智慧消防的应用还弥补了传统消防安全管理中数据处理方式落后、值班制度执行不彻底等问题,赋予了建筑消防设施智能化、自动化的能力。 尽管智慧消防技术在社会消防安全管理工作中的应用已经展现出巨大的潜力和优势,但目前仍处于实践探索阶段。相关职能部门和研究企业需要加大研究开发力度,进一步完善系统的功能与实效性。智慧消防的发展既面临风险,也充满机遇。当前,社会消防安全管理工作中仍存在制度执行不彻底、消防设施日常维护不到位等问题,而智慧消防理念与技术的应用可以有效弥补这些弊端,提高消防安全管理的自动化与智能化水平。随着智慧城市理念的不断发展和实践,智慧消防将成为推动社会消防安全管理工作与城市化进程同步发展的关键力量。
scratch少儿编程逻辑思维游戏源码-节奏空间.zip
scratch少儿编程逻辑思维游戏源码-黑白色.zip
scratch少儿编程逻辑思维游戏源码-简单射击游戏.zip
少儿编程scratch项目源代码文件案例素材-头头连连看.zip
少儿编程scratch项目源代码文件案例素材-移动小球.zip