A couple of years ago, the development team at AnyPresence was tasked with implementing a back-end server API generator for a large customer that wasn’t comfortable using Ruby on Rails in production and preferred an option in the Java ecosystem. To meet this requirement, the AnyPresence platform team invested a significant amount of time implementing a Java version of the generator in the Play framework. However, it was taking too long to implement features to match what was already available in the Rails version, so the team eventually started to look at alternative frameworks.
That search ultimately led us to adopt Node.js and Sails.js, which is an MVC framework for Node.js. This article attempts to explain the reasoning behind these choices.
Problem No. 1: Java, .Net, or Node.js?As an enterprise dev platform for Web, mobile, and IoT apps, AnyPresence needed a secure, scalable, and well-supported development framework and runtime environment that could be used in large-scale production scenarios. Java and Microsoft .Net were the obvious options. Given Java’s rock-solid foundation, IDE support, threading capabilities, debugging features, and vast array of libraries, it is still regarded by many as king in the world of programming. But Java has its downsides, primarily related to speed of development and the burden of legacy overhead, making it a questionable choice when it comes to modern, streamlined Web app development.
Microsoft .Net also has a huge following in the enterprise, but adopting .Net would require picking a specific .Net language like C#, and that would mean alienating the large swath of Java developers. Given these challenges, AnyPresence considered Node.js, which had a strong following with an impressive amount of documentation, tools, and best practices considering its age, and it was rapidly gaining adoption among enterprise IT organizations.
With further research, the AnyPresence team concluded that Node.js was the best option for both technical and business reasons. The three main reasons:
- Node.js offers speed and a nonblocking I/O API. Node.js was created because concurrency is difficult in many server-side programming languages, and often leads to poor performance. Node.js provides an event-driven architecture and a nonblocking I/O API that optimizes an application's throughput and scalability. Developers write simple code and Node.js takes over. Node.js uses an event loop, instead of processes or threads, to scale. Callbacks are defined, and the server automatically enters the event loop at the end of the callback definition. Node.js exits the event loop when there are no further callbacks to be performed.
Problem No. 2: Choosing a Node MVC frameworkAfter AnyPresence decided on Node.js, we faced the question of which MVC framework to select. The top five we considered included Express.js, Meteor.js, Sail.js, Derby, and SocketStream. Ultimately, we chose Sails.js for its permissive license, robust community, flexibility, and readiness out of the box.
AnyPresence is architected with separation between design and runtime environments. The platform provides developers with full access to the source code across the entire application stack. Therefore, an ideal framework for us would have a permissive open source license based on MIT or BSD, enabling modification and distribution without sacrificing confidentiality of proprietary components. Sails.js comes with the MIT license.
Sails.js boasts a large and active community on GitHub, with thousands of people who either follow the repository or who have forked it. Such a large following indicates solid adoption from the community, which ensures a more mature and robust product.
While being very full-featured out of the box, Sails.js is based on Express.js, perhaps the most pervasive Node.js application framework in existence. As a benefit, any Express-based middleware can be plugged into Sails.js and utilized, giving Sails developers access to hundreds of open source packages that run on the Express.js platform.
Finally, because Sails.js comes with so many basic features out of the box, we immediately got many capabilities we wanted without having to reinvent anything. These included the following features:
- Waterline ORM. Waterline was the perfect ORM for us, as the team could write a pluggable database adapter to connect to many different systems. Some frameworks only allow for relational databases or specific NoSQL databases such as MongoDB. If you wanted one for SOAP, you had to use a different solution. Having one layer to connect to different data sources was key for AnyPresence.
- A plethora of database adapters. Adapters are available in the Sails.js community for MySQL, MongoDB, PostgreSQL, Redis, and Microsoft SQL Server. This was important for the AnyPresence platform because being able to use a single framework regardless of the back-end data store makes life much simpler.
- Rapid and agile development. With Sails.js, it's very quick and easy to get stuff up and running using prototyping. You can iterate more quickly. It’s easy to view and test changes, which is not the case if you are developing with Java or .Net. Enterprise Java development, for example, is very bloated and cumbersome compared to development with Sails.js. Using Sails.js, developers are more productive due to the shorter code/test cycle.
If you're building your next-generation applications -- especially APIs for mobile and Web integration in IoT -- or if you are creating something new that depends on those underlying services, Node.js is a runtime system that could very well work for you. It has certainly worked well for AnyPresence and its customers.
Rick Snyder is a software engineer and architect with more than 11 years of experience developing enterprise software. His particular interests include middleware, concurrency, scalability, and performance. Snyder is currently director of engineering at AnyPresence, an enterprise platform for digital transformation that enables API microservices, enterprise mobility, and IoT app ecosystem initiatives.
New Tech Forum provides a venue to explore and discuss emerging enterprise technology in unprecedented depth and breadth. The selection is subjective, based on our pick of the technologies we believe to be important and of greatest interest to InfoWorld readers. InfoWorld does not accept marketing collateral for publication and reserves the right to edit all contributed content. Send all inquiries to email@example.com.