Reactive Programming – Tame the complexity of asynchronous coding

So, you have caught wind of reactive programming, RXjava, responsive extensions and all the promotion around them but you’re not able to get your head around them. You do not know if they are a solid match for your project; whether you should begin utilizing them and where to begin learning. Let’s try to make this easy and simple for you.

With an explosion in both the volume of internet users and the technology powering websites over the years, reactive programming was born as a way of meeting these improved demands for developers. Of course, app development is just as important now and reactive programming is as vital a component in that sphere too.

What is Reactive Programming?

Reactive programming is programming with asynchronous data streams, to be specific, make it responsive. Typical click events are actually asynchronous event streams, on which you can observe and create side effects to make the code easily readable. With Reactive, you are able to create data streams out of anything, not just from events or AJAX calls or Event Buses. To sum up, Reactive programming runs asynchronous data flows between sources of data and components that need to react to that data.

Diagram: RX Observables

Why is being ‘Functional’ important?

Functional reactive programming (or FRP for short) is an asynchronous programming paradigm that allows data flows from one system component to propagate the same changes to other components that have been registered to accept them. Compared to previous programming paradigms, FRP makes it simple to express static or dynamic data flows via the programming language. It came into existence because modern apps and websites needed a way of coding that provided fast, user-friendly results.

On top of the streams, we have an amazing toolbox of functions to combine, create and filter any of those streams. This is when the “functional” thrill kicks in; a stream can be used as an input to another one. In addition, multiple streams can function as inputs to other streams. Furthermore, you can merge two streams and filter a stream to get another one that has only those events you are interested in. You can also map data values from one stream to another new one.

What are the benefits?

There are many reasons why you should use reactive programming as a business or developer.  Some of the most common ones are:

Why use reactive programming?

  1. Asynchronous operations
  2. Smoother UI interactions
  3. Callbacks with Operator Chaining, without that notorious “callback hell”              
  4. Easier complex threading with hustle free concurrency

It is quite clear Reactive programming composes asynchronous operations making smooth UI interactions; here are some of the major benefits you should know:

How does it benefit you?

  1. Enhanced user experience – This is at the very heart of why you should be using reactive programming for your apps or websites. The asynchronous nature of FRP means that whatever you program with it will offer a smoother, more responsive product for your users to interact with.
  2. Easy management – One big bonus with reactive programming is that it is easy to manage as a developer. Blocks of code can be added or removed from individual data streams, which means, you can easily make any amendments via the stream concerned.
  3. Simpler than regular threading – FRP is actually less of a hassle than regular threading due to the way it allows you to work on data streams. Not only is this true for basic threading in an application but also for more complex threading operations, you may need to undertake.

What are the challenges?

While reactive programming is a great tool for developers to use, it does have a couple of challenges to overcome:

  1. Hard to learn – In comparison with the previous ways of working, RP is quite different. This leads to a steep learning curve when you start using it, which may be a shock to some.
  2. Memory leak – When working this way, it can be easy to handle subscriptions within an app or a site incorrectly. This can lead to memory leakage, which could end up seriously slowing things down for users.

In conclusion

Reactive Programming is not easy, and requires tremendous learning, as you will have to move on from imperative programming and begin thinking in a “reactive way”. In a scenario where the code already addresses the issues properly, reactive programming can provide major lines-of-code savings.

We at Nitor believe that Reactive programming brings smoother & quicker programming results and makes user interaction much better. Naturally, this converts into happier customers and more sales for your business.

For more information, please contact marketing@nitorinfotech.com

WebAssembly – Smart technology platform on the block

Since the last decade, JavaScript has been unable to ease the developer burden due to its dynamic nature. Furthermore, for applications in which performance is critical, Javascript is not fast enough. For areas in which significant engineering effort is required in another language, it may not make sense to convert to JavaScript.

Clearly, the need of the hour was to get a cutting-edge technology platform. Technologists found the answer in June 2015, when engineers on the WebKit project, along with Google, Microsoft and Mozilla announced that they were launching WebAssembly. WebAssembly is a new binary format for compiling applications from the web. The idea behind launching WebAssembly was to make it portable bytecode, which can be effective for browsers to download and load.

So what exactly is WebAssembly?

According to WebAssembly.org, WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed to be a portable target for the compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications. Following are the features of the WebAssembly:

  • Fast Execution
  • Useful in CPU-intensive operation
  •  Support for old & new Browsers
  • Secure

WebAssembly is still new, but it is supported in all major browsers such as Chrome, FireFox, Edge, Safari, etc.  Additionally, legacy browsers can be supported with the help of Asm.js. Below is the representation of how WebAssembly works.

                    (Source of the Diagram: Daveaglick.com)

WebAssembly is a relatively new technology. As a result, creating complex applications using this language can be challenging. To understand it better, here are some of the key WebAssembly concepts you need to remember:

  • Module

Represents a WebAssembly binary that has been compiled by the browser into executable machine code.

  • Memory

A resizable array buffer that contains the linear array of bytes read and written by WebAssembly’s low-level memory access instructions.

  • Table

A resizable typed array of references (e.g. to functions) that could not otherwise be stored as raw bytes in Memory (for safety and portability reasons).

  • Instance

A Module paired with all the state it uses at runtime including a Memory, Table, and set of imported values.  An Instance is like an ES2015 module that has been loaded into a particular global with a particular set of imports.

In some ways, WebAssembly gives more power to the web developer. In addition, it changes the dynamics of the web, giving that additional advantage due to its near-native speed.

Some of the advantages include:

Effective and Rapid

WebAssembly performs at native speed by taking advantage of common hardware capabilities accessible on various platforms. The Wasm stack machine is structured to be encoded in a size- and load-time-efficient binary format.

Secured

Likewise, Javascript, Wasm describes a memory-safe, sandboxed execution environment. However, WebAseembly can enforce the same-origin and permissions security policies of the browsers once embedded in the web.

Open and Debuggable

WebAssembly is designed to look attractive while having a textual format for debugging, testing, experimenting, optimizing, learning, teaching, and writing programs. The textual format will be used when viewing the source of Wasm modules on the web.

Part of the open web platform

WebAssembly is designed to maintain the versionless, feature-tested, and backward-compatible nature of the web. WebAssembly modules will be able to call into and out of the JavaScript context and access browser functionality through the same Web APIs accessible from JavaScript. WebAssembly also supports non-web embedding.

While everyone is very optimistic about the current state of WebAssembly, there are people who are not well versed with its concepts. Here are some important points, which will help you understand WebAssembly better:

Be very clear that WebAssembly is not Java Applet/Active x, which are plugins. The browser natively supports WebAssembly and it is executed by the same virtual machine, which executes JavaScript. It runs in the same sandbox environment as JavaScript runs. Furthermore, WebAssembly is not a security risk. If you do not consider JavaScript as a security risk, then you should not be worried about WebAssembly as it runs on the same sandbox.

Most importantly, you should know that WebAssembly can not fully manipulate the DOM. It cannot directly access the DOM, but it can call out into JavaScript, and JS can then work on the DOM. Also, lot of people are keen on knowing which languages WebAssembly supports. Currently WebAssembly supports c and c++. Rust is also supporting Webassembly. There are also open source projects, which will add support for garbage collected languages such as C# and Java. Blazor is one such project that enables the development of WebAssembly through c#.

Conclusion

WebAssembly is a promising technology. It is web standard and supported by the most browsers. Nitor’s developers have started taking advantage of this technology where performance is critical. Obviously, there are some limitations for now but as technology evolves, they can be overcome.

Nitor thinks WebAssembly is going to do more of what a modern web browser already does: It is turning out to be a proper, cross-language target for compilers, aiming at supporting all necessary features for making a great all-round platform.

Source:

www.daveaglick.com

www.webassembly.org

DevOps

DevOps is the new buzzword of the day. Agile software development used to be the main philosophy when it came to developing and delivering products. However, there now seems to be something missing when it comes to delivering working software to the market at the speed which the Agile methodology promises. DevOps lies somewhere between developing and delivering a software. Let me explain my views about it.

What is DevOps?

In a SaaS and cloud obsessed world, there is constant market pressure to implement newer features in the product and release the products to consumers as fast as possible. Tech companies have embraced the Agile development philosophy to address the concerns surrounding faster release of products.  They have even achieved  success to some extent. However, while Agile development principles help develop a working software faster than any other process, what about releasing the product to market?

A typical Agile scrum based-development has sprints of 2 to 4 weeks. At the end of this sprint, which largely involves Dev, QA, Architect and BA, the product features agreed (sprint backlog items) are  ready for production deployment. Note that the product  is production ready but the actual production deployment can take some time. Typically, production deployment may take another  week which could involve lot of to and fro between the deployment team and the Dev team due to the complexity involved in any SaaS and cloud based product.  On average, the production release can be considered to take around 3 weeks for a 2 week sprint based development plan. If the deployment involves too many complexities, it is possible that the actual deployment time can prolong further. Some common practices involve creation of release sprints dedicated to release related activities. Such a release sprint may be planned after a certain number of sprints and generally involves releasing the product in bigger batches, thus defeating the purpose of the faster release of products.

DevOps is a newer chapter in the book of product engineering. DevOps  makes agile principles stronger by bringing in the Development team and the Operations team (responsible for production deployment) closer. Both  teams work closely to ensure tightly integrated development and deployment, resulting in seamless delivery.  The DevOps processes will make sure that the new product features are integrated with the main product and released to market even faster. This means that at the end of a typical 2 week sprint, the product is not just production-ready but also deployed to production release, ready for  end users.

What does it take to implement DevOps?

Bringing dev and operations team closer is the primary theme of the DevOps methodology. Tight integration of dev and operations would typically involve automation of configuration management, version controlling process, test scripts, creation of staging environment and production environment. With Cloud used prominently for hosting, automating cloud related operations such as setting up virtual machines too becomes part of the DevOps automation plan.

Most cloud setup activities revolve around configuring appropriate Virtual machines. The cloud platforms have matured, and many scripting options are available to automate these operations. With the new Containerization technology, which adds  another layer of abstraction and automation of OS level virtualization, the overhead of maintaining virtual machines is further reduced. Though it was initially available on Linux platforms only, Microsoft and Docker partnered to come up with a Microsoft piece of the same.

In addition to available scripting options, we can consider using various DevOps tools for implementation and continuous delivery. Chef, Puppet and Ansible are some of the popular tools for the same. When it comes to the Microsoft world, Team Foundation Server (TFS) along with Azure runbook will help automate Microsoft Azure related operations.

 Summary

Agile DevOps is becoming the thing when it comes to standing up to the promise of delivering a product to market. The Operations team, which largely consists of Sysadmin, DBA, and network engineers has a  key role to play. Their collaboration with the development team ensures that production deployment is smooth and accurate. Due to the distributed nature of the application architecture, there are too many elements to be considered for automaton These range from code deployment to virtual machine creations. A wide variety of scripting may be required to automate them. This  calls for a highly motivated and skilled Operations team that can jump from one scripting language to another, depending upon the situation.