React vs. Angular: The Comparison

Do you want to learn about and discover the differences between React vs. Angular? Then keep on reading! I am going to explain to you the similarities, differences, pros, and cons of both React and Angular in this article. You don’t need to be an expert programmer to understand this post but it is encouraged that you are familiar with JavaScript.

*Disclaimer: I have worked extensively with both React and Angular. I used Angular at my job at IBM and React & React Native at my current job. I personally prefer React but will do my best not to taint the article with bias.

History of React vs. Angular

Angular is a JavaScript framework written in TypeScript. It was developed and is maintained by Google, and is described as a “Superheroic JavaScript MVWFramework” on Angular’s webpage. Angular (version 2 and above), originally released in September 2016, is a complete rewrite of AngularJS (released in October 2010). The newest major release is version 6 at the time of writing. Google AdWords, one of the most important projects at Google, uses Angular – so Angular is likely to be around for a while.

React is a JavaScript library developed and maintained by Facebook. It was released in March 2013 and is described as “a JavaScript library for building user interfaces”. React is used far more at Facebook than Angular is at Google if it’s any indication as to how big Facebook is betting on this technology. By this metric, you can also conclude that React will be around for a very long time.

Both Frameworks are available under the MIT license.

Architecture of React vs. Angular

Framework vs. Library

Angular and React have many similarities and many differences. One of them is that Angular is a full-fledged MVC framework and React is merely a JavaScript Library (just the view). Let me elaborate. Angular is considered a framework because it offers strong opinions as to how your application should be structured. It also has much more functionality “out-of-the-box”. You don’t need to decide which routing libraries to use or other such considerations – you can just start coding. However, a drawback is that you have less flexibility – you must use what Angular provides.

Angular provides the following “out of the box”:

  • Templates, based on an extended version of HTML
  • XSS protection
  • Dependency injection
  • Ajax requests by @angular/HTTP
  • Routing, provided by @angular/router
  • Component CSS encapsulation
  • Utilities for unit-testing components.
  • @angular/forms for building forms

React, on the other hand, gives you much more freedom. It only provides the “view” in MVC – you need to solve the M and C on your own. Due to this, you can choose any of your own libraries as you see fit. You will end up using many independent, fast-moving libraries. Because of this, you will need to take care of the corresponding updates and migrations by yourself. In addition, each React project is different and requires a decision requiring its folder hierarchy and architecture. Things can go wrong much more easily due to this.

React provides the following “out of the box”:

  • Instead of classic templates, it has JSX, an XML-like language built on top of JavaScript
  • XSS protection
  • No dependency injection
  • Fetch for Ajax requests
  • Utilities for unit-testing components

Some popular libraries to add functionality are:

  • React-router for routing
  • Redux or MobX for state management
  • Enzyme for additional testing utilities

Regular DOM vs. Virtual Dom

React’s use of a virtual DOM is one of its features that makes it so blazingly fast. You’ve probably heard of it. It was React’s “killer feature” when it was first released. Let me give you an example scenario:

Let’s say that you want to update a user’s age within a block of HTML tags. A virtual DOM only looks at the differences between the previous and current HTML and changes the part that is required to be updated. Git employs a similar method, which distinguishes the changes in a file.

Conversely, Angular opted to use a regular DOM. This will update the entire tree structure of HTML tags until it reaches the user’s age.

So why does this matter? The example above is trivial and probably won’t make any difference in a real app. However, if we’re dealing with hundreds of data requests on the same page (and the HTML block is replaced for every page request) it drastically affects the performance, in addition to the user’s experience.

Templates – JSX or HTML

React decided to combine UI templates and inline JavaScript logic, which no company had ever done before. The result is called “JSX”. Although it may have sounded like a bad idea, Facebook’s gamble paid off big-time. React uses something called a component, which contains both the markup AND logic in the same file. It also uses an XML-like language that allows you to write markup directly in your JavaScript code. JSX is a big advantage for development, because you have everything in one place, and code completion and compile-time checks work better.

Read more

What is Digital Marketing?

When you get down to it, digital marketing is simply marketing.

It’s how today’s businesses are getting their message in front of their best prospects and customers.

Rule #1 in marketing is to make the right offer at the right time and in the right place. Today, your customers are online: hanging out in social media, staying updated on news sites and blogs, and searching online when they have a need.

Digital marketing puts you in those same channels, so your best prospects can see you, learn more about you, and even ask questions to learn more about you and your products or services.

If you’re new to digital marketing, it may feel overwhelming to think about mastering all the online marketing tactics used in digital marketing.

We get that…

And yes, there are different tactics you’ll need to learn. But they all work together to create a foundation for your business: attracting prospects, nurturing relationships, and making offers your audience will appreciate and respond to.

Let’s take a closer look at how that happens.

How Does Digital Marketing Work?

In many ways, digital marketing is no different than traditional marketing. In both, smart organizations seek to develop mutually beneficial relationships with prospects, leads, and customers.

But digital marketing has replaced most traditional marketing tactics because it’s designed to reach today’s consumers.

As an example…

Think about the last important purchase you made. Perhaps you purchased a home, hired someone to fix your roof, or changed paper suppliers at your office.

Regardless of what it was, you probably began by searching the Internet to learn more about available solutions, who provided them, and what your best options were. Your ultimate buying decision was then based on the reviews you read, the friends and family you consulted, and the solutions, features, and pricing you researched.

Most purchasing decisions begin online.

That being the case, an online presence is absolutely necessary—regardless of what you sell.

The key is to develop a digital marketing strategy that puts you in all the places your followers are already hanging out, then using a variety of digital channels to connect with them in a multitude of ways…

…Content to keep them updated with industry news, the problems they’re facing, and how you solve those problems…

…Social media to share that content and then engage with them as friends and followers…

…Search engine optimization (SEO) to optimize your content, so it will show up when someone is searching for the information you’ve written about…

…Advertising to drive paid traffic to your website, where people can see your offers…

…And email marketing to follow up with your audience to be sure they continue to get the solutions they’re looking for.

When you put all these pieces together, you’ll end up with an efficient, easy-to-operate digital marketing machine. And while it looks intimidating to build that machine from scratch, it’s as simple as learning and integrating one digital marketing tactic at a time.

Which is why we’ve put together this guide: To help you build or refine your own digital marketing plan without the false starts and missteps that come with doing it alone.

What Are the Benefits of Digital Marketing?

Having a strong digital presence will help you in multiple ways:

  • It will make it easier to create awareness and engagement both before and after the sale
  • It will help you convert new buyers into rabid fans who buy more (and more often)
  • It will kickstart word-of-mouth and social sharing—and all the benefits that come with them
  • It will shorten the buyer’s journey by presenting the right offers at the right time
Read more

Typescript VS Javascript

What is TypeScript ?

On the 27th of April 2017, you wake to begin your morning routine, It’s 4:05 AM, so you don’t see it yet. No screen time till 6:00 am. Personal policy. You meditate. You work out, you make breakfast. This time you decide to slide in the book reading routine for a little while in there. You surely haven’t done that in a while.
It’s 8:00 am you have managed to not have checked that phone screen. Your mind is fixed on getting to the office first. And again you don’t see it. Finally, the morning meetings are over and you have your sanity back for what? An hour? Half an hour maybe before another meeting.
Then you pick up your phone to check for what you believe is a Twitter notification. That’s when your eyes catch it.

Announcing TypeScript 2.3 For those who aren’t familiar, TypeScript is a superset of JavaScript that brings users optional static types and solid tooling. Using TypeScript can help avoid painful bugs people commonly run into when writing JavaScript by type-checking your code. TypeScript can actually report issues without you even saving your file, and leverage the type system to help you write code even faster. This leads to a truly awesome editing experience, giving you time to think about and test the things that really matter.

You wonder, what in Gods name is this? You had just gone through hell with React/Redux, you are still grappling at Vue.js. Somehow you have figured Angular out. Well okay let’s say you did not really have a choice, you were learning on the job. No results meant your job would suffer. And so you learned Angular.

You think of the stress you have to go through to learn this shiny new thing. You check up the usage of this strict syntactical superset of JavaScript, a few days later and you find out it has an army of developers behind it. Do people love this thing? Now as a smart developer you know you have no other job but to keep up with the market as Chad Fowler mentioned in his still very relevant book The Passionate Programmer. I understand perfectly the way you feel. But I personally feel like TypeScript has come to stay.

But What Exactly Is This JavaScript ?

JavaScript the very dynamic programming language that everyone was drawn to because it didn’t “house them in” like C++ did. Its untyped nature and its unique prototypal inheritance was perfect bait. To justify my gut feeling about this just days after TypeScript was released by Microsoft, Angular picked it up and abandoned the plain ES6 that was another available option. Initially, their idea was to go with actionScript, a javascript scripting language that extended Typescript and got published by Google’s AngularJS team exactly two years after the forerunner TypeScript. In fact, it was going to run on the TypeScript of course as an extension.

With all that being said since then a decorator proposal has appeared for ES and it seems to be quite close to what original actionScript did. But before we jump the gun here really. What is this decorator proposal ES utilizes ?

A Decorator is:

  • An expression
  • That evaluates to a function
  • That takes the target, name, and decorator descriptor as arguments
  • And optionally returns a decorator descriptor to install on the target object

Read more here. But if you don’t want to branch out into another page until you are done with this article, a decorator is basically a high order function? An high order function ‘takes in’ another function and when it runs, it extends the behavior of the latter function without explicitly modifying it.

UA very simple python decorator

So if our function myFunction(as a higher function) here takes in a function it won’t necessarily modify that function, though the output will turn out differently.

One of the first things that put me off with decorators was the ‘@’ sign. It immediately felt like I was reading another language other than JavaScript. I am sure this was the experience for a lot of other people too. Either ways the ‘@` tells the parser that everything (in that block of code) after that sign is a decorator. Sounds easy now? It is simply just talking to the computer directly what is about to happen which is that a function will be decorated by another function and the results will be passed back up.

And the computer says; ‘Got it! Fine, go on’ . The computer then treats that block of code as a different kind of function, kind of like how a parent would treat a favourite child and as a result of this special attention from the ‘parent’, it becomes a function that can do cool things like memoization, authentication, logging and so on. Again I won’t go deeply into the details of this for now but when you think of decorators think of them as this:

A decorator at work

…Instead of this train wreck.

Imagine you have a couple of functions you want to wrap around themselves. It would be a nightmare to code and maintain such program. All said and done about ES6, of course, you would still have to deal with typing somehow in ES. And TypeScript is a natural fit there(when it comes to typing). You can complement ES with a solution like Flow to get gradual typing after all. Maybe we’ll see two bigger camps. One for ES (Babel guys) and one for TS.

What is Static vs Dynamic Typing ?

Typing has always been about the variables in the program. If I create a static typing language I don’t have to immediately tell the compiler that this particular integer and will always be an integer. It will be exactly what I stored in the program even If I forget while coding and changed its value by passing it to another class or something. A number of good language examples are C, C++, Java. Dynamic typing, on the other hand, is the direct opposite of what the above is about. Ruby, Perl and of course our poster boy: JavaScript. This doesn’t mean any one of these languages is inherently weak or bad. And that should be the focus.

Example of Java (Static and Strongly Typed)

There is no way the system can go wrong in evaluating the value of ‘foo’, ever.

Example of Javascript (Dynamic and Strongly Typed)

As opposed to Java or C++, which are both strongly typed languages, Javascript is intelligent enough to know/interpret what variable type you want to use. but because of the laxness that this creates or can create in code quality it is also called a weakly typed language. But we know better. Especially if you follow best practices.

Example of PHP (Static and Weakly Typed)

Between the two up there they are just paradigm ways of coding, it doesn’t mean Static typing is bad or Dynamic typing is good. The devil that should be your sole attention should be weak and strong type languages. Here is what you lose by overlooking a scripting language that is focused on improving the life its users.

  • Generic functions & Polymorphism
  • Higher order functions
  • Object composition

Again. Dynamic types DOES NOT =/ No type checks. on that topic check out this article that Dynamic Typing is NOT Weak Typing Taking a step back what if we combined both sides of the coin, meaning we take what made C++ be C++ and introduced that into Javascript?

  • Speed: Static languages are generally faster
  • Efficiency/Effective Static languages make the programmer more accountable. Dynamic programming sometimes creates a moral hazard and encourages bad programming habits

Here is JavaScript Dynamically typed

Here is Javascript Strongly Typed

And that is TypeScript!

If this article makes Typescript sound interesting, you can delve more into Typescript and see if it’s something you want to invest time and energy into. This is just a very brief article talking about these tools in a very peripheral manner.

Read more