In the last few years, we came across different client side projects which were traditionally built on J2ee or other Open Source Technologies such as PHP, Ruby etc. On the other hand, the year 2013 saw increasing popularity of several javascript frameworks like Angular.js, Backbone.js which in turn gained momentum in client side development. These strong winds of change were brought about structural framework, coding and performance enhancement in development and production environment became absolutely imperative. On top of that emerging small sized projects and start-up companies have shown growing interest in adapting those new technologies.Evolving trends for storing non-structure data within repository is collectively called nosql in 2013. It is obvious that these fresh trends are clearly coming with new set of tools in software which revolve around javascript and nosql related repositories.Today javascript is not merely used for client side validation. It offers server side development for web applications along with node.js platform. In this book, we have tried to show start-up experimentation with some of these tools.
The aim of this book is to show the use of some of the above mentioned tools in application and how we can start development of application with those tools. The book deals with some of the Proof-of-Concept Applications with the help of those tools. Apart from that,brief descriptions of some important aspects of these tools have also been incorporated . Being a developer from the very begining of my career, I always tried to find the codes which I can put together to generate new concepts in work. This book is a collective outcome of my efforts and experimental view with that acumen in mind. So there will be continuous updation of fresh knowledge from time to time.One personal opinion of mine is, working with new technologies like Javascript and NoSql related products is fun and I am thoroughly enjoying this phase. Also just to accompany, I am not an author but a programmer by profession; so writing things with all the theories and explanations was not my intention, rather I prefer to include practical working examples.
People with web programming backgound with javascript knowledge will find this book useful because this book is a collective knowledge source of usages of Javascript based tools and different application areas with those. The chapters of the book are explained with important aspects of the tools and covered with various coding explanations rather than just original theories. It is worth mentioning that I tried to incorporate explanations of the concepts as and when required. This book is not for beginner programmer but for the programmers with intermediate knowledge and for advanced programmers who have already mastered the traditional web programming with age-old J2ee, PHP, Dot net or other open source web technologies (like me..).
Starting the Web Server with Javascript
We have found server side javascript framework like node.js platform is quite useful in development. We have not explained much about node.js in chapters of this book, but below is a litte introduction about node.js, which is used for most of the proof-of-concepts in this book.
Now-a-days developers know about Node.js as a server -side javascript execution platform.
According to nodejs.org
Node.js is a platform built on Chromes JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Now node.js opens a new way of performing or serving to the web requests or any other type of server requests which is called Non-blocking IO Operation.
We have came across the following link - http://code.danyork.com/2011/01/25/node-js-doctors-offices-and-fast-food-restaurants-understanding-event-driven-programming/, which is an excellent way of showing the non-blocking concepts of node.js with relate to real-life working scenarios.
As my background for last 5-6 years as J2ee Programmer, I knew and understood the Servlet Programming Model in J2ee Environment, which is a multi-threaded programming model i.e. when a web request come to java based web server, the request hit to the servlet with the request and the servlet opens a new thread to handle the request and response the data back to the client. All the database related methods or any server resource intensive call, which are shared in nature, are to be handled carefully from the servlet to avoid any deadlock or other unwanted situations which will be related to shared objects.
Though through this way a process parts in threads and serves the web request within thread which are having relatively small overhead as compared to server processes. But still if some database call amounts to a significant time within the execution of request and response which is within a thread call, it will hold the client for this with their synchronous activity which is blocking IO operation.
Now it is time to understand the non-blocking I/O, on which node.js platform is defined.
First of all, node.js application environment will run on a single threaded programming model.
All the web requests and server requests call in node.js are of non-blocking I/Os. An web request comes in node.js web server and the web server accepts this request and handle this request to a listener object to process the response. Also this web server will remain ready to accept any new web request. And the previous response handling will remain in a queue for performing the rest of operations. Now the node.js environment takes care of preparing the web response which again can be a database call from the actual application. Also this database query can also consists of callback functions with the response from database as being ready. Those operations are executed in a queue and also called as event driven programming and all of these operations are asynchronous in nature.
So the whole point to discuss here is, all the function calls within node.js context are non-blocking input-output operations. In node.js environment, the performing operation is executed by one object and the results of the operation are handled by the callback functions.
For understanding node.js we recommend an excellent book at (http://www.nodebeginner.org/).
We have used the node.js based web server for most of the next applications in this book.
Javascript in OOP Way - some interesting study