Posted on

Why MEAN is better than LAMP ?

 

Developing a Web-driven application (either mobile or browser-based) typically requires the provisioning of some server-side infrastructure as well as the development of some code to run on it. Such code will often consume APIs. But occasionally, it provide them as well. For many years, the go-to infrastructure in such situations was affectionately referred to as the LAMP stack and it primarily involved Linux, Apache, MySQL and PHP, Perl or Python. But, thanks in part to Javascript’s applicability to both client and server-side scripting, there’s an another stack that’s now widely considered as an alternative to LAMP; the MEAN stack.

 

What’s LAMP?

linux-2025536_640

Linux, Apache, MySQL and PHP. The holy grail of web development for at least as long as I can remember. This stack represents the foundation of the web.

While its age may be showing, its maturity is strong. The LAMP stack can be altered to replace MySQL with MongoDB, and PHP with Python. The acronym defines a low level configuration for web applications.

What’s MEAN?

Meanstack-624x250

 

MongoDB, ExpressJS, AngularJS and Node.js makes up the MEAN stack. A powerful JavaScript driven stack with diverse capabilities.

Comparatively to LAMP, the database layer is replaced completely with JSON storage using MongoDB. JSON is the native data language of JavaScript. While relatively young, the framework has a growing number of supporters.

This stack is basically a JavaScript lover’s dream.

Now we will look at points , why MEAN is better.

 

Node.js is superfast

 

Apache was great, but these days, Node.js is often flat-out faster. A number of benchmarks show that Node.js offers better performance, while doing much more. Perhaps it’s the age of the code. Perhaps the Node.js event-driven architecture is quicker. It doesn’t matter. These days, especially among impatient mobile device users, shaving even milliseconds off your app’s performance is important and Node.js can do that, while offering a Turing-complete mechanism for reprogramming it.

 

MongoDB is built for the cloud

 

If your Web app plans include making good on the pennies-per-CPU promise of the cloud, the MEAN stack offers a compelling database layer in MongoDB. This modern database comes equipped with automatic sharding and full cluster support, right out of the box. Plug in MongoDB and it spreads across your cluster of servers to offer failover support and automatic replication. Given the ease with which apps can be developed, tested, and hosted in the cloud, there’s little reason not to consider MongoDB for your next project.

 

MySQL’s structure is confining (and overrated)

 

Anyone who has developed or maintained a LAMP-based app for any amount of time knows that MySQL’s strength as a relational database can feel a bit imprisoning at times. Like all relational databases, MySQL forces you to push your data into tables. This isn’t a problem if every single entry fits into exactly the same format, but how often is the world that generous? What if two people share the same address but not the same account? What if you want to have three lines to the address instead of two? Who hasn’t tried to fix a relational database by shoehorning too much data into a single column? Or else you end up adding yet another column, and the table grows unbounded.

MongoDB, on the other hand, offers a document structure that is far more flexible. Want to add a new bit of personal information to your user profiles? Simply add the field to your form, roll it up with the rest of the data in a JSON document, and shove it into your MongoDB collection. This is great for projects in flux and for dealing with data that may ultimately prove tricky to constrain in table form.

 

Angular is a Plus

 

It’s not exactly fair to compare the “A” in “MEAN” with anything in the LAMP stack because LAMP doesn’t include an analog. If you want to do anything on the client side, you’re on your own. Sure, there are plenty of good PHP-based frameworks that work with MySQL, but each is a bit different and moving in its Angular_full_color_logo.svgown direction. AngularJS has been developed as well as maintained by dedicated Google engineers. This means that there is a huge community out there for you to learn from. Apart from that, there are engineers that can help you tackle any challenges you face on the way. It also means that clients get what they want. Most frameworks require programmers to splitting the app into multiple MVC components. After that, the programmer has to write a code to put them together again. AngularJS, however, strings it together automatically. That saves you time, and reduces the app’s time-to-market.

 

AngularJS is more intuitive as it makes use of HTML as a declarative language. Moreover, it is less brittle for reorganizing. AngularJS is a comprehensive solution for rapid front-end development. It does not need any other plugins or frameworks. Moreover, there are a range of other features that include Restful actions, data building, dependency injection, enterprise-level testing, etc. AngularJS is unit testing ready, and that is one of its most compelling advantages.

 

Node.js simplifies the server layer

 

Node.js_logo

Navigating the various layers of the LAMP stack can be a difficult dance of many hats, one that has you shuffling through various config files with differing syntax. MEAN simplifies this through use of Node.js.

Want to change how your app routes requests? Sprinkle in some JavaScript and let Node.js do the rest. Want to change the logic used to answer queries? Use JavaScript there as well. If you want to rewrite URLs or construct an odd mapping, it’s also in JavaScript. The MEAN stack’s reliance on Node.js put this kind of pipework all in one place, all in one language, all in one pile of logic. You don’t need to reread the man pages for PHP, Apache, and whatever else you add to the stack. While the LAMP generation has different config files for everything, Node.js avoids that issue altogether. Having everything in one layer means less confusion and less chance of strange bugs created by weird interactions between multiple layers.

 

JSON everywhere

 

AngularJS and MongoDB both speak JSON, as do Node.js and Express.js. The data flows neatly among all the layers without rewriting or reformatting. MySQL’s native format for answering queries is, well, all its own. Yes, PHP already has the code to import MySQL data and make it easy to process in PHP, but that doesn’t help the client layer. This may be a bit minor to seasoned LAMP veterans because there are so many well-tested libraries that convert the data easily, but it all seems a bit inefficient and confusing. MEAN uses the same JSON format for data everywhere, which makes it simpler and saves time reformatting as it passes through each layer. Plus, JSON’s ubiquity through the MEAN stack makes working with external APIs that much easier: GET, manipulate, present, POST, and store all with one format.

 

Its your choice

 

Of course, if you’re really picky, there’s no reason why you can’t mix it up a bit. Plenty of developers use MongoDB with Apache and PHP, and others prefer to use MySQL with Node.js. AngularJS works quite well with any server, even one running PHP to deliver data from MySQL. You don’t have to be a slave to the acronyms.

programming-1873854_640

This post is inspired from another blog written on this topic

 

Posted on

Use Python for Data Cleaning and Analyzing nicotine dependence

doc(1)

The objective of the project was to study Nicotine Dependence. Nicotine Dependence is an addiction to tobacco products caused by the drug nicotine. At first association between smoking behaviour and Nicotine Dependence was explored. Social behaviour and depression history were then analyzed as explanatory variables. A study at Universiti Teknologi MARA Malaysia concluded that among smokers 5% have high nicotine dependence whereas 18% have moderate nicotine dependence. Another study by the Durham University , UK found that life events and stressful experiences are associated with nicotine dependence.

The data was taken from a survey conducted by National Epidemiologic Survey on Alcohol and Related Conditions (NESARC). Earlier National Institute on Alcohol Abuse and Alcoholism have performed landmark study on Alcohol Abuse and Alcohol Dependence using the NESARC dataset.  The dataset is a representative sample of United States adult population aged over 18. Initially the data consisted of over 43000 data points.

The data was in Comma Separated Value(CSV) format. The variables used for the regression model were.

Variable Name Description
CHECK321 the cigarette smoking status of the individual
S3AQ3B1 the usual frequency when the individual smoked cigarettes
S3AQ3C1 the usual quantity when the individual smoked
TAB12MDX the dependent variable which represented if the respondent had a nicotine dependence in the last 12 months

The dataset contained various missing values. Python was the language used for the data cleaning and analysis purpose. At first using the pandas library in python the dataset was loaded. After loading the the data missing values of the CHECK321 variable were checked. The unknown values of the CHECK321 suggested that the cigarette smoking status of an individual is unknown and so the analysis can not be done for that individual. Hence the data points containing missing values of CHECK321 were deleted. After deleting the missing values we were left with 18000 data points. The target variable TAB12MDX took only two values ‘0’ and ‘1’. ‘1’ denoting the individual is nicotine dependent and ‘0’ denoting that the individual is not nicotine dependent.

telepain

For analysis of the data we split the data and into training and testing set. Training data was used to train our model. Since the target variable is binary we decided to use logistic regression for training the model. For splitting the data we used a python library Scikit Learn also popular as sklearn. The training test split ratio was 80:20. The cleaned data was fed to the model and the model was trained. After training the model we tested the model with the test data we had split earlier. We saw that for 58% of the times our model has correctly predicted whether a person is nicotine dependent.

As the study by the Durham University , UK found that life events and stressful experiences are also associated with nicotine dependence. We decided to introduce two new variables MAJORDEPLIFE and SOCPDLIFE to make our model more accurate.

 

Variable Name Description
MAJORDEPLIFE If the individual suffered depression or not
SOCPDLIFE If the individual has socio-phobia or not

We again split our data into training and testing sets. The model was trained with the testing set now with two new variables. Now with the introduction of two new variables associated with the life events and stressful experience the accuracy of our model increased to 65%. For 65% of the times we predicted correctly whether a person is nicotine dependent or not by seeing is smoking behaviour and social life.
Research concludes that individual who smoke more heavily than those who don’t are more prone to be Nicotine Dependent. Individuals who have a history of Depression or are Socio-phobic are also more prone to be Nicotine Dependent than those without.Our results seems consistent with the previous findings.

 

 

Posted on

Make portions of image responsive on your web page

Images are nowadays an important part of web pages. We make our web pages look more attractive and appealing to the users by adding images. We can make it more attractive by adding responsive images. So the big question is how can we make an image responsive.

 

responsive

 

The basic formats of images that we use in our daily life are JPEGs , PNGs , BMPs etc. These formats identify image as one whole entity.So how our code will identify small portions that are there in the image.One thing that we could do is crop our image and break it into smaller images of the portions that we want to make responsive. This will be like our brute force approach to the problem not a smart approach. We might be able to do the task but it will be a very complicated solution and we will have to take care of various corner cases.Smart approach of this problem is using a different less common image format SVG. SVG stands for Scalable Vector Graphics.

technology-1283624_640 We can change our image format into SVG easily either by using an online converter or using an image editing software as Illustrator. The benefit of SVG is that we can see and manipulate parts of our image as code. We can see the code by opening a SVG image into any text editor. Small portions of image is represented as small part of the code which we can manipulate.We can use SVG as HTML attribute. We can directly put the code in HTML code of our web page and manipulate the code by adding on-click and on-hover events to the different parts of the images.

Posted on

My new year Resolution for 2017

know-yourself-002

UI5CN is a learning platform and the highest form of knowledge we can acquire is wisdom. We might be in many different situations, many plans may be there in our mind, many challenges we can foresee for that plan to become reality. But the big question is not what is stopping us or may stop us but what keeps us going. And the inner why, which is the reason we do what we do.

Let it tell us not to settle for less and it is not ok to, not to strive for greatness.

So let’s start the New Year with new possibility and believe to be more than what we were.
 

Posted on

Sweet Story of SAPUI5/OpenUI5 and Javascript

Javascript has become new norms for developing applications. Processing at the UI end is becoming more fashionable and every major software-related companies are having their own JS framework. For enterprise giant SAP, SAPUI5/Open UI5 is the new framework. Google and Facebook also have their own framework Angular.js and React.js respectively which are few among the top.

 

The world is changing for good, some may disagree!

When we take a closer look at SAP, ABAP or ABAP/4 was used majorly to create enterprise application and there was a lot of development done with SAP ABAP editor which is inbuilt with SAP Frontend UI also eclipse was second popular IDE used to write ABAP code.

 

Old is Gold.

We also saw the introduction of Web-Dynpro a few years back to leverage Java for developing enterprise applications. After Sun Microsystem was acquired by Oracle and Oracle and SAP are a well-known competitor in the ERP marketplace it was clear for SAP to move away from Java world. Then comes the era of Javascript. In the meantime in the Javascript world after ES6 version of Javascript the possibility and things you can perform were impressive and with HTML5 not only you can leverage the responsive nature of building a mobile application but also can make it much much better looking with CSS3.
And With these open source technologies, UI5 was created.

 

Big moment!

Now comes the major challenge to replace all existing application in SAP with UI5, the answer was SAP Fiori, Fiori means flowers in Italian and apps build with UI5 do follow 5 basic guideline principles to make it look beautiful as a flower. SAP Fiori was launched with 25 applications with HCM, Timesheet apps few popular among the first 25 apps. Now the portfolio of Fiori apps is much bigger covering a wide spectrum of functional fields and more than 500+ apps.

 

Victory!

When we try to predict the future with SAPUI5/Open UI5 and Fiori, we are going to see more of open source stacks coming in like Node.js and Angular.js influence with UI5.

Now the major question comes here: Is it worth learning UI5 or if you are already a UI5 developer it is worth spending time to upgrade the skills and the answer is yes!

 

That’s Right!

Till now we have only seen the tip of the iceberg and there is a lot more to come. At UI5CN we spend a lot of our time( as we don’t have anything else to do) to help people who are starting their career with SAP or upgrade their skills to go to the next level.

 

 

Share this blog if you liked it and tweet it if you want more 🙂