Wednesday, June 22, 2016

Aurelia vs Angular — a Feature by Feature Comparison

In the world of web development and JavaScript, we've seen a lot of paradigms come and go. But one paradigm has stuck around: the single-page web application.

One of the most popular frameworks to land in the past six years was AngularJS. Released in 2010 and backed by Google, it promised quick, easy development of rich, client-side applications through the use of declarative two-way data binding. Gaining a large following, AngularJS quickly established itself as a go-to methodology for web application development, being used by companies like Amazon and Pluralsight.

Today, in 2016, AngularJS has begun to show its age. A new framework, named Aurelia, has become a popular choice for rich, client-side applications. Primarily created by Rob Eisenberg of Durandal Inc., Aurelia targets the same problem space as AngularJS. However, Aurelia uses a modern approach to ease development and solve a lot of the problems that plagued AngularJS.

In this article, we'll take a detailed look at AngularJS and Aurelia, and compare and contrast the two frameworks. For the purposes of this comparison, we'll exclude Angular 2 from our framework comparison. Instead, we'll only be focusing on the AngularJS 1.x framework. Today, using the perspective of a developer in 2016, we'll take an apples-to-apples comparison of the AngularJS methodologies designed in 2010 and the modern methodologies used by Aurelia.

The Rundown

Both AngularJS and Aurelia are client-side JavaScript frameworks targeted at creating single-page web applications. Both AngularJS and Aurelia support intuitive, two-way data binding, client-side routing, and advanced templating features. Both AngularJS and Aurelia encourage extending HTML using custom elements. Both AngularJS and Aurelia ship with default components that wrap common functionality. As stated before, AngularJS and Aurelia target the same problem domain. So where do the similarities end?

Let's take a quick look at the main differences between AngularJS and Aurelia.

AngularJS Aurelia
Proprietary Standards-compliant
Configuration Convention
Complex Simple
Expensive Efficient
Fixed Flexible
Monolithic Modular

Whoa --- wait a minute. You might be saying, hey --- it looks like you've stacked the deck a little bit there. But I'd like to delve more into these claims.

Proprietary (AngularJS) vs Standards-compliant (Aurelia)

Web standards have evolved in the six years since AngularJS was released. While AngularJS was initially designed to adhere to the standards of the time, it was forced to create many proprietary solutions for scenarios that didn't have well-defined rules. Among these were JavaScript language standards and HTML templating.

JavaScript language standards

JavaScript's language and ecosystem are constantly moving forward; its standards, features, and syntax are continually evolving. While AngularJS was designed to take advantage of web browser capabilities in 2010, Aurelia has been designed on top of modern standards.

AngularJS provided a non-standard JavaScript module format implementation which was designed to be used with the AngularJS framework. Aurelia, by comparison, leans on the ES2015 module standard. Additionally, Aurelia takes advantage of new language constructs --- such as ES2016 decorators --- to ease development and support emerging standards.

HTML templating

Both AngularJS and Aurelia allow you, as a developer, to extend HTML in new ways. When AngularJS was created, standards for extending HTML had not matured. Therefore, AngularJS created proprietary solutions for templating and custom elements.

Today, the Web Component spec defines a set of rules for both templating and custom elements. Aurelia actively adheres to these standards, supporting Shadow DOM, the <template> element, HTML imports, and native custom elements.

Configuration (AngularJS) vs Convention (Aurelia)

When I first started playing around with Angular, I thought it was awesome. Learning how to configure AngularJS with its specific code calls didn't take a lot of time. However, as I grew more comfortable with AngularJS and built more applications, all of Angular's configuration began to get in the way.

AngularJS requires you to create an Angular-specific module. Essentially, everything that your application will use must be explicitly registered with the framework, and configured, before the web application has started. As such, it's necessary to attach all controllers, services, and custom directives to an AngularJS module before they can be used. Additionally, AngularJS controllers are coupled to views via code: a view must declare the controller it intends to use. All of this results in a lot of boilerplate. Let's look at an example, using ES2015.

hello.js

// A Hello controller
export class Hello {
    constructor (userService) {
        this.userService = userService;
        this.greeting = "Hello, " + this.userService.getUser() + "!";
    }
};

user-service.js

// A User Service
export class UserService {
    getUser () {
        return "Newman";
    };
};

index.js

import {Hello} from 'hello';
import {UserService} from 'user-service';
// No matter how or where we declare our objects,
// we'll always have to use Angular's registration code
// to let AngularJS know about them.
angular.module('App', []);
    .controller('HelloCtrl', Hello)
    .service('UserService', UserService)
    ... and so on

hello.html

<div data-ng-controller="HelloCtrl as hello">
    <h1></h1>
    ...my view
</div>

In comparison, Aurelia requires no explicit registration of components before they can be used. The framework knows how to find views and viewmodels without them having to be explicitly configured by using a default convention. (This convention can be overridden if necessary through configuration, but explicit configuration is not mandatory.) Finally, Aurelia viewmodels are not coupled to views by code inside the view.

hello.js

// A Hello controller
export class Hello {
    constructor (userService) {
        this.userService = userService;
        this.greeting = "Hello, " + this.userService.getUser() + "!";
    }
};

user-service.js

// A User Service
export class UserService {
    getUser () {
        return "Newman";
    };
};

index.js

// We don't need to explicitly register our objects with
// Aurelia - so really, we don't even need this.

hello.html

<template>
    <h1>${greeting}</h1>
    ...my view
</template>

This means that getting started with Aurelia is easy: there's less framework-specific code for a developer to learn to use. Aurelia's out-of-the-box conventions support rapid development and decrease the learning curve. However, after getting more familiar with Aurelia, you can change its conventions if you wish --- and if you don't, there's simply less framework-specific code to deal with.

Complex (AngularJS) vs Simple (Aurelia)

In my experience with AngularJS, while some of the basic concepts can be fairly simple, the advanced concepts are structurally and semantically complex. Some things (like writing extensible components and modules) aren't too bad, while other things (complex directives) can be almost arcane. Aurelia aims to simplify the execution of its advanced concepts, creating a flatter learning curve.

Semantics

AngularJS uses complex semantics. A developer has to know them in order to really utilize the framework. For instance, in AngularJS, you can declare a service, a factory, a value, or a constant: AngularJS makes a distinction between all of these. You can also declare a controller, and a directive. Unfortunately, few of these share the same conventions --- especially AngularJS directives.

Directives are a powerful construct in AngularJS --- allowing applications to extend HTML with custom elements, attributes, and behavior. Unfortunately, they are also an advanced concept and they can have a steep learning curve.

Explaining AngularJS directives is beyond the scope of this article, but trust me on this one. Let's just take a look at a sample directive.

index.html

<body ng-controller="MainCtrl">
  <h1>What's your favorite Javascript framework?</h1>
  <choose-framework></choose-framework>
</body>

chooseFramework.html

<div>
  <input id="framework-input" type="text" ng-model="framework" placeholder="Choose a framework" />
  <button data-ng-click="choose()">Choose</button>
  <p ng-if="chosen">You prefer !</p>
</div>

chooseFramework.js

app.directive('chooseFramework', function() {
  return {
    scope: {
      framework: '',
      chosen: false,
    },
    restrict: 'E',
    replace: true,
    templateUrl: 'chooseFramework.html',
    link: function(scope, elem, attrs) {
      // Assume we're using jQueryUI autocomplete.
      $('#framework-input').autoComplete(['AngularJS', 'Aurelia', 'VanillaJS']);
    },
    controller: function ($scope) {
      $scope.choose = function () {
        // Log our preference somewhere.
        alert('Your framework choice has been stored for posterity.');
        $scope.chosenFramework = $scope.framework;
        $scope.chosen = true;
      }
    }
  };
});

Aurelia, in contrast, simplifies all of these semantics and reduces the learning curve. It gets rid of the declaration step entirely, allowing you to inject your code as a dependency in a much simpler manner. Further, Aurelia uses well defined lifecycle methods instead of events, so code conventions are shared between viewmodels and custom elements. This makes writing and reasoning about code simple. Finally, arcane AngularJS directive declarations are replaced by custom elements that work in the same way as Aurelia viewmodels do.

Let's take a look:

index.html

<body>
  <h1>What's your favorite Javascript framework?</h1>
  <choose-framework></choose-framework>
</body>

chooseFramework.html

<div>
  <input id="framework-input" type="text" value.bind="framework" placeholder="Choose a framework" />
  <button click.delegate="choose()">Choose</button>
  <p if.bind="chosen">You prefer ${chosenFramework}!</p>
</div>

chooseFramework.js

@customElement('choose-framework')
export class ChooseFramework {
  constructor () {
    this.framework = '';
    this.chosen = false;
  }

  attached () {
    // Assume we're using jQueryUI autocomplete.
    $('#framework-input').autoComplete(['AngularJS', 'Aurelia', 'VanillaJS']);
  }

  choose () {
    // Log our preference somewhere.
    alert('Your framework choice has been stored for posterity.');
    this.chosenFramework = this.framework;
    this.chosen = false;
  }
}

Interoperability

Because of the way its change detection works, AngularJS can't detect changes to objects or properties that the framework itself doesn't make. Essentially, if a change happens outside the AngularJS digest cycle, it must be notified so that it can pick it up. In practice, while AngularJS provides some service wrappers for common functionality (like timeouts, intervals, and promises) out of the box, this means that any third-party libraries that make changes must be wrapped to notify AngularJS that a change happened. You end up writing a lot of boilerplate code like this:

$scope.$apply(function () {
    // some asynchronous activity that updates scope, such as a
    // timeout or an interval
    $scope.value = 'updated';
});

(After you realize this, you're okay --- but before you know what's going on, you can easily run into this pitfall, as I did here. After realizing, though, you'll end up writing this code a lot.)

Aurelia doesn't require these wrappers, meaning a reduced footprint and simpler conventions. It also means that integrating third-party components and libraries is a lot easier.

Continue reading %Aurelia vs Angular — a Feature by Feature Comparison%


by Jedd Ahyoung via SitePoint

This Week's HTML5 and Browser Technology News (Issue 245)


Read this e-mail on the Web
HTML 5 Weekly
Issue 245 — June 22, 2016
Adam Simpson
A look at ‘how to harness the machines’ to help you with your front-end dev work using Grunt, Gulp, Webpack and npm scripts, along with examples of how and why each is used.


Pavels Jelisejevs
How to use new properties and values from upcoming CSS specifications today using the PostCSS tool.


Pubnub  Sponsored
Learn to build your own AngularJS chat app with realtime messages and more in no time. View Tutorial.

Pubnub

Ivan Shubin
How do we make sure a site’s layout stays responsive and displays correctly on all kinds of devices with various resolutions? Here’s one solution.


Google
A practical proof of concept design / proposal to persist sessions using Service Workers.


Matt Giuca
A proposed API for sharing data (text, URLs, images) from the web to an app of the user’s choosing.


Jobs

  • Job Offers. No resume necessary.Create your Hired profile to get top companies to start applying to hire you. Get offers from $75,000 - $250,000 on the platform in 1 week. Hired.com

In brief

Curated by Peter Cooper and published by Cooper Press.
Want to post a job? E-mail us or use our self-serve system.

Unsubscribe : Change email address : Read this issue on the Web

Published by Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via HTML5 Weekly

This Week in Mobile Web Development (#113)

Read this on the Web

Mobile Web Weekly June 22, 2016   #113
Peter Cooper recommends
Building for A Future Mobile Web — Paul Kinlan considers how the future mobile web will combine the perks of native apps with the best bits of the web.
Paul Kinlan
Brian Rinaldi recommends
Should All Content Be Responsive? — Derek walks us through a couple of examples where traditional approaches to responsive content may actually hamper people from achieving their goals online.
Derek Featherstone
Brian Rinaldi recommends
Banner Ads Are Dead Because Your Phone Killed Them — Global spending on mobile ads will surpass desktop spending for the first time next year, according to research firm Zenith.
Mark Bergen
Sponsored
Hired is the best place to find engineering jobs. — Bored at work? Want to try a new stack? Find 3500+ great tech companies on Hired who will compete to hire you. Try it today.
Hired.com

Chris Brandrick recommends
Microsoft Project ULink Brings The Equivalent of Web URLs to Mobile Apps
Pradeep Viswav
Brian Rinaldi recommends
The Future of the Web — A lot of debate was stirred, in part by Alex Russell’s tweets related to JavaScript and Progressive Web Apps. Matt tries to bridge the divide between the two camps in the debate.
Matt Griffin
Brian Rinaldi recommends
Weex Framework — Weex is a new framework for building mobile cross-platform UI using web technologies that is in private pre-release.
Alibaichuan
Brian Rinaldi recommends
A Roadmap To Building A Delightful Onboarding Experience For Mobile App Users — Strategic guidelines to keep in mind when designing onboarding UX for your mobile app. With practical examples and techniques.
Anton Kosolapov
Brian Rinaldi recommends
Building NativeScript Apps with React — Chris makes his case that Telerik should add React support to NativeScript.
Chris Geirman
Brian Rinaldi recommends
Jason: Turn Any Data, Website, or API Into an App — The Jason project renders native mobile apps from JSON markup.
Ethan
Brian Rinaldi recommends
Mobile UX Design: What Not To Do — Why do we install apps in the first place? To make our lives convenient. But when an app fails to fulfill this requirement, then it’s for certain that users will go elsewhere.
Nick Babich
Holly Schinsky recommends
Mobile Expert Interview with Ionic Framework's Ben Sperry and Adam Bradley — A podcast with Ben Sperry and Adam Bradley discussing Ionic, it’s future and how to develop killer apps using their framework.
Apperian
Brian Rinaldi recommends
Virtual Insanity with NativeScript Views and Angular 2 — Nathan Walker shares an experimental project that translates NativeScript views for the web within Angular 2 allowing 1 view for web and native mobile.
Telerik Developer Network
Brian Rinaldi recommends
Push Code Updates to Apps Instantly with CodePush — Jay Raj looks at CodePush, a tool from Microsoft that helps you push code updates to Cordova and React Native apps.
@jay3dec
Holly Schinsky recommends
Apache Cordova & The Browser Based Workflow — Microsoft adds their new open source project into VS Code to create a better browser workflow for hybrid app developers.
Visual Studio Blog
Holly Schinsky recommends
How TapBookAuthor.com Helps Users Create Interactive Content with PhoneGap — How TapBookAuthor is using PhoneGap to help users create and publish educational and interactive content for learning and entertainment.
PhoneGap Blog
Sponsored
Try RASON™ – And Start Using Advanced Analytics in Your Web/Mobile Apps — Solve powerful optimization & simulation models in your app easily with RASON™. Use a high-level modeling language embedded in JSON, & a simple, Azure-backed REST API.
RASON.com by Frontline Systems Inc

Curated by Brian Rinaldi and Holly Schinsky for Cooper Press.
Cooper Press is located at Office 30, Fairfield Enterprise Centre, Louth, LN11 0LS, UK
Update your email address
or stop receiving MWW here


by via Mobile Web Weekly

Using Halite for Privacy and Two-Way Encryption of Emails

Cryptography is a complex matter. In fact, there is one golden rule:

* Don't implement cryptography yourself *

Picture of keys hanging on strings

The reason for this is that so many things can go wrong while implementing it, the slightest error can generate a vulnerability and if you look away, your precious data can be read by someone else. Whilst this is not an exhaustive list, there are several important guidelines to follow when using cryptography:

  • Don't use the same key to encrypt everything
  • Don't use a generated key directly to encrypt
  • When generating values that you don't want to be guessable, use a cryptographically secure pseudo random number generator (CSPRNG)
  • Encrypt, then MAC (or the Cryptographic Doom Principle)
  • Kerckhoffs's principle: A crypto system should be secure even if everything about the system, except the key, is public knowledge

Some of the cryptographic terms used in this article can be defined as follow:

  • Key: a piece of information that determines the functional output of a cryptographic algorithm.
  • CSPRNG: also known as a deterministic random bit generator, is an algorithm for generating a sequence of numbers whose properties approximate the properties of sequences of random numbers (or bytes). To be cryptographically secure, a PRNG must:
    • Pass statistical randomness tests
    • Hold up well under serious attack, even when part of their initial or running state becomes available to an attacker.
  • MAC: is a short piece of information used to confirm that the message came from the stated sender (its authenticity) and has not been changed in transit (its integrity). It accepts as input a secret key and an arbitrary-length message to be authenticated, and outputs a MAC.

To further read about cryptography and have a better understanding, you can take a look at the following pages:

Some libraries out there implement cryptography primitives and operations, and leave a lot of decisions to the developer. Examples of those are php's own crypto library, or Defuse's php-encryption. Some PHP frameworks implement their own crypto like Zend Framework's zend-crypt or Laravel.

Nevertheless, there is one library that stands out from the rest for its simplicity and takes a lot of responsibility from the developer on the best practices, in addition to using the libsodium library. In this article we are going to explore Halite.

libsodium
halite

Continue reading %Using Halite for Privacy and Two-Way Encryption of Emails%


by Miguel Ibarra Romero via SitePoint

KM05 KITAMURA MAKURA

Everyone, 30 rotations, a Night During sleep, your head turns over right and left, drawing an arc about 30 times.


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

PS IT Web Solution Restyling

PS IT Web Solution: New Website


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery

Limonija – Premium Shopify Themes

We build Premium Shopify Themes


by csreladm via CSSREEL | CSS Website Awards | World best websites | website design awards | CSS Gallery