The online storage and content platform, Box, open-sourced a new front-end JavaScript framework. Dubbed T3, the framework attempts to solve problems that large applications encounter by decoupling code into small, discrete pieces.
In a post introducing T3, Box Principal Architect Nicholas Zakas says that his team built it to solve internal issues with multiple developers working on a huge code base. "There aren't any existing options that did what we needed," says Zakas in an interview with InfoQ.
Most existing solutions are geared towards MVC-based architectures, and we wanted to go in a different direction. Some other abstractions exist, there just weren't enough already-existing pieces to make what we have in T3.
These components come in one of three types:
- Services
- Modules
- Behaviors
In a typical ToDo List example, the project not only shows the code, but also provides an explanation of what each piece of code does. For example, in describing the code that maintains item status, the description says:
While all modules are independent, each module talks to a service that maintains todo status. The todos-db service manages adding, removing, and marking tasks throughout the apps lifecycle.
T3's concept of services is similar to that of Angular, for example. Developers register a service with the Application
:
Application.addService('router', function(application) {
return {
route: function(url, state) {
history.pushState(state, '', url);
}
};
});
Unlike Angular, which uses dependency injection, services in T3 are accessed through a request on the Application
global:
var router = Application.getService('router');
router.route('/home', {});
Like React, using T3 does not preclude the use of other frameworks. "There's nothing preventing us from using Backbone, React or another framework in addition to T3. T3 really just helps better organize individual code while allowing our engineers to piece together a full client-side stack out of whatever they want," says Zakas.
In a discussion on Hacker News, developers have praised the team's credentials, but have made comparisons between T3's components to those of Ember, Angular, and Meteor. User DigitalSea complains that T3 offers nothing new:
I just do not see why Box needed to create another Javascript framework. Am I missing something here? As a front-end developer I get excited about this stuff, but I just do not see what T3 brings to the table that other frameworks do not.
Zakas says that T3 excels in certain types of apps. "It will work with other approaches as well, including MVC architectures and single-page apps, but it's strength is definitely in progressive enhancement." Box uses T3 on both the desktop and mobile web applications.
T3 is available on GitHub