Saturday, August 31, 2019

Upgrading from Node 6 to Node 8: performance comparison


We get several major upgrades with Node.js versions every year. Node 6 upgraded to Node 8. As it is an upgraded version, it posses some changes that enhance performance factor. This results in more efficiency and reducing the cost of a development. It was not difficult to upgrade to Node 8- It will take only 10 minutes. Also it will not break a single library. You can easily install it on macOS with .pkg file from a website. It was smooth running. It also works like a charm on Windows machine. Also, it doesn’t require manual steps, no broken packages. Also it doesn’t require much time to upgrade. 
These performance comparisons are for  medium to large React site with a single page. With the server it takes a JSON object with a thousand of properties and returns with 2113 nodes.

Upgrading from Node 6 to Node 8: performance-

1. Server rendering time-

Start with the important metric- Time taken to do the server rendering of the page. 
At a first look, there are no drastic difference. But, at the eighth version, the render time reduces. Node 6 was getting the job done in about 104ms while Node 8 was taking about 80ms.
Server rendering time
That’s really 23% reduction in render time. Or, more concretely, a 23% reduction in the hardware required to serve the site. 
Here’s the same test, but using React in dev mode:
React renderToString (dev mode)
After the first few, there was an average reduction of about 31%. This chart shows that it is important to set NODE_ENVto ‘production’ and ship the production version of libraries.

2. Running a test suite-

This suite of  500 Jest tests involves most of the  mounting and unmounting React components, and obviously just general JavaScriptery.
Suite of Jest tests
A 10% reduction, perhaps the improvement is less pronounced here because the JavaScript engine isn’t doing any optimizations (each run was a fresh start of Node). This is just a guess. Corrections/explanations are most welcome.

3. Webpack Build-

The Webpack build is a little bit of disk I/O. It is a bunch of Babel transpiling, JS uglifying/minifying, all for about 500 KB of JavaScript.
Webpack build
Node 8.0 causes the 7% reduction in run time. 

4. NPM installs-

Node 6 LTS shipped with npm@3. This brought some good improvements to the next versions. With Node 8 LTS, we’ll be getting npm@5. This has brought some insanely impressive features and performance. Some new features include such as,lockfiles, local caching with fallbacks, SHA512 checksums and a suite of other small features. In case of performance, one can expect up to 5x performance increases in the best cases. On average, you can expect 20-100% faster npm installs. Check the npm@5 from the npm team to analyze more about the new version, and see the improvements you will get in with Node 8  LTS.

Specific performance Updates-

  1. Creating object- Creating objects in Node8 is five times faster than in Node 6.
  2. Function size- The V8 engine decides whether a function should be optimized based on several factors such as function size. Small functions are optimized whereas large functions are not.
  3. TurboFan and Ignition- V8 includes turboFan and Ignition. These are major updates to the internals of V8 which gives impressive performance hike across a variety of JavaScript operations.
  4. One of the most exciting things to be added recently to the core JavaScript language is coming to Node.js 8 LTS – async/await. Many see async/await as the next evolution of asynchronous programming in Node.js, beating out both callbacks and promises. There’s a lot of excitement around async/await, so I highly suggest checking out this article on reasons why async/await is awesome for a more brief introduction.
Apart from this, you can see the new features of Node 8 at- Node 8: Six New Features You must Know .
Are you looking for a web development to boost your business? Then you are at the right place. Solace expert’s are well trained to use Node 8 for effective development. To get a free quote for any web development, contact us. We are happy to help you get started through our expert’s.

10 JavaScript concepts every Node.js programmer must master


Read more
Node.js owes much to JavaScript for its higher popularity. JavaScript is a multi-paradigm language. It supports many different styles of programming, including functional programming, procedural programming and object-oriented programming. It also allows the developer to be flexible and take advantage of the various programming styles. Hence it is necessary for Node.js programmer to be a master in some JavaScript concepts. Let’s see which are these concepts.

JavaScript concepts every Node.js programmer must master

1. JavaScript(ES6) Class-

JavaScript classes are introduced in ES6. These classes are primarily syntactical sugar over JavaScript’s existing prototype-based inheritance. The class syntax does not introduce a new object-oriented inheritance model to JavaScript. In early ES5 using function expression. 
Classes are special functions and you can define function expressions and function declarations. Class syntax has two components-
 1. Class expressions  
 2.Class declarations.
ES6 Class-
class Bike{
 constructor(color, model) {
   this.color= color;
   this.model= model;
 }
}
Benefits of using class-
  1. Convenient and self -contained syntax.
  2. A solitary, accepted approach to copy classes in JavaScript.
  3. More familiar to people those are using class-based language.

2. JavaScript Prototype-

When an object is created in JavaScript, JavaScript engine adds a _proto_property to the newly created object. This is called _proto_points to the prototype object of the constructor function.
function Car(model,color){
 this.model = model,
 this.color = color
}
Car.prototype.getDetails = function(){
return this.model+’ bike is ‘+this.color;
}
var carObj1 = new Car(‘BMW’,’Black’);
console.log(carObj1.getDetails());
The carObj1 object, which is created using the Car constructor function. It  has a __proto__ property which points to the prototype object of the constructor function Car. In below code, both carObj1 it’s __proto__ property and Car.prototypeproperty is equal. Let’s check if they point at the same location using === operator.
console.log(carObj1.__proto__ === Car.prototype );//output : true
So using prototype property, how many objects are created functions are loaded into memory only once and we can override functions if required.

3. JavaScript Closure-

Closure is a combination of a function and the environment within which that function was declared.  It is an inner function that has access to the outer function’s variables – scope chain. Closure has three scope chains – 
  1. It has access to its own scope 
  2. Closure has access to the outer function’s variables
  3. It has access to the global variables 
Closure Example-
function User(name){  var displayName = function(greeting){
  console.log(greeting+’ ‘+name);
 }
return displayName;
}
var myFunc = User(‘Raj’);myFunc(‘Welcome ‘); //Output: Welcome Raj
myFunc(‘Hello ‘); //output: Hello Raj
In this code, the outer function User() returns an inner function as displayName(),The inner function will have access to the variables in the outer function scope, even after the outer function has returned.

4. Module Pattern-

In JavaScript language, a module is referred as a small unit unit of independent and reusable code. Modules are the strong base for many JavaScript design patterns. These strong base are necessary for building any non-trivial JavaScript-based application. JavaScript module export as the value instead of define a type, as JavaScript module can export an object, Modules that export a string containing an HTML template or a CSS stylesheet are also common. JavaScript language don’t have private keyword. But we can achieve private methods and properties using closures.
var myModule = (function() {
   ‘use strict’;
   var _privateProperty = ‘Good Morning’;
   function _privateMethod() {
       console.log(_privateProperty);
   }
   return {
       publicMethod: function() {
           _privateMethod();
       }
   };
}());
myModule.publicMethod();                    // outputs ‘Good Morning’  
console.log(myModule._privateProperty);     // is undefined     
protected by the module closure
myModule._privateMethod();                  // is TypeError protected by the module closure
These modules can be exported to the other JS files using the export keyword,
//myMOdule.js file 
exportdefault myModule;
You can import module to another JS file.
//second.js file
import myModule from ‘./myModule’;
Use of Module-
  1. Namespacing
  2. Reusability
  3. Maintainability

5. Hoisting-

Hoisting is a JavaScript mechanism in which variables and function declarations are moved to the top of their scope before execution of code.
Simply, explanation for Hoisting with code,
         console.log(Hoist);
         var Hoist = ‘The variable Has been hoisted’;
         //output : undefined//
JavaScript has hoisted the variable declaration. Hence the code above looks like to the interpreter.
        var Hoist;
        console.log(Hoist);
        Hoist = ‘The variable Has been hoisted’;
JavaScript only hoists declarations, not initialization.
Definitely, this implies regardless of where functions and variables are declared. They are moved to the top of the scope regardless of whether their scope is global or local. Hence this also match for a variable of function level scope also hoisted.
Hoisting let-
  1. Var, const keyword in JavaScript (ES6)
  2. Hoisting classes
  3. Hoisting Functions

6. Scope-

Scope is the accessibility of variables, functions, and objects in some particular part of your code during runtime. In other words, scope determines the visibility of variables and other resources in areas of your code. According to this definition of scope, the point in limiting the visibility of variables and not having everything available everywhere in your code. Types of Scope-
  1. Global Scope
  2. Local Scope
var greeting=’Welcome to blog’;
(function(){
 console.log(greeting); //Output: Welcome to blog
})();
in the above code, greeting variable should be global scope, it can access inside the function,
(function(){
 var greeting = ‘Welcome to blog’;
 console.log(greeting); //Output: Welcome to blog
})();
console.log(greeting); //Output:Reference-Error greeting not defined
Consider the above code for local scope,
In scope level variables in JavaScript ES6 has updated hoisting variable let, var, const type check with that, In order to learn the scope, you need to understand hoisting also.

7. Currying-

Currying is a technique of evaluating a function with multiple arguments, into a sequence of function with a single argument. When a function takes the first arguments (instead of taking all arguments at one time) and return a new function that takes the second one and returns a new function which takes the third one, and so forth until all arguments have been fulfilled.
consider below example code:
var add =   function (a){
                return function(b){
                      return function(c){
                             return a+b+c;
                             }       
                       }
                 }
console.log(add(2)(3)(4)); //output 9
console.log(add(3)(4)(5)); //output 12
this currying achieving through closures. Hence the above program variables a,b private properties of the parent function.
Use of currying-
It helps to create a higher order function. It is extremely helpful in event handling.

8. Memorization-

It is a programming technique which attempts to increase a function’s performance by caching its previously computed results. Because JavaScript objects behave like associative arrays, they are ideal candidates to act as caches. When each time a memorized function is called, its parameters are used to index the cache. If the data is available, it will be returned without execution of complete function. If the data is not cached, the function is executed and the result is added to the cache. The function is an integral part of programming. They help for modularity and reusable to our code. As per above definition, memorization is an optimizing our code.
const memoizedAdd = () => {
 let cache = {};
return (value) => {
 if (value in cache) {
  console.log(‘Fetching from cache’);
  return cache[value];
 }
 else {
  console.log(‘Calculating result’);
  let result = value + 10;
  cache[value] = result;
  return result;
 }
}
}
// returned function from memoizedAdd
const newAdd = memoizedAdd();
console.log(newAdd(9)); //output: 19 calculated
console.log(newAdd(9)); //output: 19 cached

9. Callback Function-

Definition-
A reference to executable code, or a piece of executable code that is passed as an argument to other code. 
According to the above definition, the callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
function greeting(name) {
console.log(‘Hello ‘+name);
}
function processUserInput(callback) {
 //var name = prompt(‘Please enter your name.’);
 name=’William’;
 callback(name);
}
processUserInput(greeting); //output Hello William
In this program, function greeting passed as an argument to the processUserInput function

10. Polymorphism in JavaScript:

Polymorphism is one of the fundamentals of Object Oriented Programming(OOP). It allows the designing of objects to share behaviors and to be able to override shared behaviors with specific ones. Polymorphism takes advantage of inheritance in order to make this happen.
let’s look at the sample code for override a function in JavaScript
var employee = new Employee(‘William’);
//override function
//this method going to execute
Employee.prototype.getDetails = function(){
   return this.name.toUpperCase();
}
console.log(employee.getDetails());  //outPut: William
//object and prototype function
function Employee(name){
  this.name = name;
}
Employee.prototype.getDetails = function(){
  return this.name;
}
In the above program, prototype based method for an Employee constructor function has to override by another prototype function as return the Name as UpperCase. Hence, we can override a function in different Scope, and also possible for method overloading. JS doesn’t have method overloading native but still, we can achieve.
Are you looking for a web development to boost your business?Then you are at the right place. We at Solace believe in benefits and effectiveness of using Node in development. We have a team expert in javascript and node development, which will give you the best solution using new features of Node. To get a free quote for any software development using Node, contact us.


Friday, August 30, 2019

What you should do to get more downloads to your app(app store optimization tips)?

User acquisition is a big challenge for app marketers. From the many surveys it has been concluded that, smartphone users download an average of three apps per month. It is a small number in comparison to how many apps are currently available. As of June 2016, the Google Play app store and Apple’s App Store sell over four million apps combined. There are many options are available so attracting user interest is a difficult task. Fortunately, there are numerous successful ways that can encourage more users to download your app. Here are nine tricks to help you boost your marketing efforts, and metrics you should track to gauge your success. Let’s discuss one by one.

App store optimization tips-

App Store Optimization

1. Encourage User Reviews- 

Increasing the visibility of your app is one part of improving downloads. After user found your app, you’ll need to convince  
Them to download. And here reviews are most important because users normally trust to word of mouth recommendations, for eg., user reviews.  Reviews not only shows the quality and importance of your app to potential downloaders, but also provide an excellent opportunity for you to engage with customers. If reviewers provide suggestions or even complaints, you can respond and show potential users how responsive you are to feedback. By doing this all the time, you’ll inspire trust and encourage more app downloads as a result.

2. Check that your app is crash- free –

If your users are facing any problems with your application, they’ll share their experience online so you can easily detect if your application is defective. After you react to their complaints, your developers should fix the problem quickly so that your app never crashes again.
However, it’s more effective to take a proactive approach—your app should undergo vigorous testing so that your developers can identify all bugs and resolve them before you make your app available to the public.
Metrics to track:
  • Crash rate
  • Retention rate

3. Motivate users to make referrals-

Referrals are another approach to exhibit quality, relevance, and trust, which will help to increase downloads. You can transform your existing users into brand ambassadors by giving them an incentive to refer your app to their friends.
For example, for a ride-sharing app, you can provide free ride credits in exchange for a referral.
Metrics to track:
  • Number of in-app referrals
  • Number of downloads

4. Pay attention to content-

Creating attractive and relevant content to promote your app can help you to engage more users. You can use online articles, videos, or infographics. For a gaming app, you can upload walkthrough videos to show off your game’s high quality visuals and gameplay to impress your audience. You can also share user-generated content to help community.

5. Engage on social media-

Social media is there to help you to show off your app. It is an effective way to extend your reach and introduce your app to new clients.
However, your intended target group will spend time on one platform over another, so analyzing the attention of your users demographics is important. Responding to your followers and encouraging them to share their thoughts exhibits that you care about your audience’s sentiments.

6. Measure, analyze and optimize-

It is important to continuously analyze how users are interacting with your app in order to ensure that they remain engaged. Are they effectively utilizing the application the manner in which it was intended to be utilized? Are there any issues that are restricting you from monetizing your app? You can use these analysis to optimize your future campaigns. Perhaps you’ve seen that many users from a specific source stop interacting with your app after a day or two. This can be because they weren’t a qualified audience, so you can decide to redirect your battle endeavors to other securing sources.

7. Put your mobile-best foot forward

App stores are only becoming more saturated, and with the industry moving toward the convergence of mobile web and mobile apps. It’s careful to consider how your brand translates across multiple channels instead of focusing on just your app experience. 

8. Influencer and community outreach-

Surveys from perceived specialists carry more presentation to your application, however they additionally impart more trust in your app. By researching the right specialists you can set up a helpful organization that will construct your brand and boost application downloads.

9. App store optimization-

App store SEO is the process of optimizing mobile apps for achieving a higher rank in the app store search results. It is similar to Search engine Optimization for websites so it is also referred as App Store Optimization.

App Name and Keywords-

Use of keywords in your title can result upto 10.3% boost in the rankings. Both Google and Apple’s search algorithms scan the app name for keywords when user performs a keyword search. Both the platforms give high priorities to apps with app names that have search input. 

App Name Format-

Keep the actual brand name short and sweet. You can then append this short brand name with a few keywords, typically preceded by a dash or a semicolon. App Name Format – Use the format – “Brand Name – Keywords” or “Brand Name: Keywords” For eg., Google Maps – GPS Navigation, Amazon – Shopping made easy, eBay: Buy & Sell – Find Deals.

App name length-

Apple limits the app name to a maximum of 30 characters in iOS 11 whereas, in Google Play Store App name is limited to 50 characters.

App Subtitle-

This field is available in the iOS App Store only. App subtitle appears under your app name, and is limited to 30 characters only.

App description-

Near about only 5% of the users click on read more button below the short description. So use each character to specify your product and also to grab the attention. Avoid blank lines and interrupted sentences.

App Promotional Text-

Your app’s promotional text appears at the top of the description and is limited to 170 characters. Despite the fact that the promotional text is NOT indexed in the app store search, the good news is you can change this text anytime without releasing a new version.

App Icon-

A good icon can increase your app downloads up to 560%! Keep your icon design simple and eye-catchy. Do not squeeze the small space with many items or words. You want people to remember the icon after the first impression. Likewise, guarantee that your symbol will even now look great when it is downsized to the littlest size required by App Store/Google Play. It should also look good against light and dark background.

App Screenshots-

 60% of users won’t swipe your first two screenshot images. A better version of your first two screenshots can boost your conversions by 25%! Make sure each screenshot is telling a single message about your app. Show your strongest messages in the first two screenshots. The best apps use all five screenshot slots to impress their users, and you should do the same. Adding short caption texts on your screenshots can help, but make sure they are on a clean background. And try to create a positive impression in the viewers’ mind at all times.
Also there are some ways that you can use to boost your app downloads. These ways are- App store keywords, App preview video, App store ratings, App indexing, app conversion rates, App size, App pricing, App updates. Know the latest trends of mobile app development at- Best Mobile App Development Trends in 2019. 
Do you want to develop an effective mobile app for your business. Then Solace is the right place. Expert at solace are well trained to develop an application that will be the face of your business. Contact us for mobile app development that helps you to boost your business to the next level.  

All you need to know about MongoDB 3.2


What is MongoDB?

MongoDB is an open-source document database that provides high performance, high availability, and also automatic scaling. An open-source database was released in 2009. Now it is available under the Free Software Foundation’s GNU AGPL Version 3.0 commercial license terms.
A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are like JSON objects. The values of fields may include other documents, arrays, and also with arrays of documents. If you are new to MangoDB, you can get the detailed comparison between Firebase, AWS and MongoDB at- Three Modern Technologies Software Stacks: Firebase vs. AWS vs. MongoDB.
The advantages of using documents are:
  • Documents (i.e. objects) correspond to native data types in many programming languages.
  • Embedded documents and arrays reduce need for expensive joins.
  • Dynamic schema supports fluent polymorphism.

Key Features of MongoDB-

1. High Performance-

MongoDB provides high performance data persistence. In particular,
  • Support for embedded data models reduces I/O activity on database system.
  • Indexes support faster queries and can include keys from embedded documents and arrays.

2. Rich Query Language

MongoDB supports a rich query language to support read and write operations (CRUD) and also:
  • Data Aggregation
  • Text Search and Geospatial Queries.

3. High Availability-

A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and also increasing data availability.
MongoDB’s replication facility is known as replica set. It provides:
  • automatic failover and
  • data redundancy.

4. Horizontal Scalability-

MongoDB provides horizontal scalability as part of its core functionality:
  • Sharding distributes data across a cluster of machines.
  • Tag aware sharding allows for directing data to specific shards, such as to take into consideration the geographic distribution of the shards.

5. Support for multiple storage engine-

MongoDB supports multiple storage engines:
  • WiredTiger Storage Engine (including support for Encryption at Rest)
  • In-Memory Storage Engine and also
  • MMAPv1 Storage Engine
In addition, MongoDB provides pluggable storage engine API that allows third parties to develop storage engines for MongoDB.

6. MongoDB CRUD Operation-

1. Create Operations-

Create or insert operations add new documents to a collection. If the collection does not currently exist, insert operations will create the collection. MongoDB provides some methods to insert documents into a collection. These methods are as follows-
  • db.collection.insert()-
To insert a single document, pass a document to the method, and also to insert multiple documents, pass an array of documents to the method. The following example inserts a new document into the users collection.
db.users.insert(
   {
      name: “sue”,
      age: 19,
      status: “P”
   }
)
The following example inserts multiple documents into the users collection. Since the documents do not specify an _id field, MongoDB adds the _id field with an ObjectId value to each document. See Insert Behavior.
db.users.insert(
   [
     { name: “bob”, age: 42, status: “A”, },
     { name: “ahn”, age: 22, status: “A”, },
     { name: “xi”, age: 34, status: “D”, }
   ]
)
  • db.collection.insertOne() New in version 3.2-
Method db.collection.insertOne() inserts a single document into a collection.
The following example inserts a new document into the users collection. The new document has three fields name, age, and status. Since the document does not specify an _id field, MongoDB adds the _id field with an ObjectId value to the new document.
db.users.insertOne(
   {
      name: “sue”,
      age: 19,
      status: “P”
   }
)
  • db.collection.insertMany() New in version 3.2
db.collection.insertMany() inserts multiple documents into a collection.
db.users.insertMany(
   [
     { name: “bob”, age: 42, status: “A”, },
     { name: “ahn”, age: 22, status: “A”, },
     { name: “xi”, age: 34, status: “D”, }
   ]
)

2. Read Operation-

Read operations retrieves documents from a collection; i.e. queries a collection for documents. MongoDB provides the following methods to read documents from a collection:
  • db.collection.find()
You can specify query filters or criteria that identify the documents to return.
db.users.find(
{ age: { $gt: 18 } },
{ name: 1, address: 1 }
) limit(5)

3. Update Operations- 

Update operations modify existing documents in a collection. MongoDB provides the following methods to update documents of a collection:
  • db.collection.update()
  • db.collection.updateOne() New in version 3.2
  • db.collection.updateMany() New in version 3.2
  • db.collection.replaceOne() New in version 3.2
In MongoDB, update operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.
You can specify criteria, or filters that identify the documents to update. These filters use the same syntax as read operations.
For eg.,
db.users.update(
{ age : { $gt : 18 } },
{ $set : { status : “A” } },
{ multi : true }
)

4. Delete Operations- 

Delete operations remove documents from a collection. MongoDB provides the following methods to delete documents of a collection:
  • db.collection.remove()
  • db.collection.deleteOne() New in version 3.2
  • db.collection.deleteMany() New in version 3.2
In MongoDB, delete operations target a single collection. All write operations in MongoDB are atomic on the level of a single document.
For eg. , db.users.update(
{ status : “D” }
)

7. Storage-

The storage engine is the primary component of MongoDB responsible for managing data. MongoDB provides a variety of storage engines. This allows you to choose the one most suited to your application. The journal is a log that helps the database recover in the event of a hard shutdown. There are several configurable options that allows the journal to strike a balance between performance and also reliability that works for your particular use case. For eg., GridFS is a versatile storage system suited for handling large files.

8. Authentication-

Authentication is the process of verifying the identity of a client. When access control, i.e. authorization, is enabled, MongoDB requires all clients to authenticate themselves in order to determine their access. Although authentication and authorization are closely connected, authentication is distinct from authorization. Authentication verifies the identity of a user; authorization determines the verified user’s access to resources and operations.
  •  Use the mongo command-line authentication options (–username, –password, and –authenticationDatabase) when connecting to the mongod or mongos instance, or
  • Connect first to the mongod or mongos instance, and then run the authenticate command or the db.auth() method against the authentication database.

9. Encryption- 

Transport Encryption-

You can use TLS/SSL (Transport Layer Security/Secure Sockets Layer) to encrypt all of MongoDB’s network traffic. TLS/SSL ensures that MongoDB network traffic is only readable by the intended client. There are two broad classes of approaches to encrypting data at rest with MongoDB: Application Level Encryption and Storage Encryption. You can use these solutions together or independently.

10. Auditing-

The auditing facility can write audit events to the console, syslog, a JSON file, or a BSON file.

Audit Events and Filter-

Once enabled, the auditing system can record the following operations:
  • schema (DDL),
  • replica set and sharded cluster,
  • authentication and authorization, and
  • CRUD operations (requires auditAuthorizationSuccess set to true).
Are you looking to develop software with MongoDB? Then you are at the right place. Solace team is there to help you. Experts at solace believe in the effectiveness of using MongoDB. Develop your best software with solace that means to the success that your business deserves. Contact us for any software development.