KotlinConf kicks off with Kotlin 1.2 RC

The Kotlin programming language is getting a number of new updates and improvements as part of the inaugural KotlinConf taking place in San Francisco this week. Kotlin is a statically typed programming language for modern multiplatform applications developed by JetBrains.

The big announcement from the conference’s keynote was the release of Kotlin 1.2 Release Candidate. The new release will include experimental support for multiplatform projects, language improvements, support for array literals in annotations, and compiler enhancements.

In addition, the Kotlin team announced support for iOS development with Kotlin/Native. Kotlin/Native is designed to compile Kotlin directly to machine code. iOS support is being released as part of Kotlin/Native 0.4. “This support is still in its early days, but it’s there, and it’s a major step on our path of enabling Kotlin development on all platforms,” Dmitry Jemerov, software developer for JetBrains, wrote in a post.

Earlier this year, the programming language made headlines when Google announced it would support Kotlin in Android. Since then, the Android team has seen more than 17% of Android Studio projects using Kotlin.

“We are really excited about the strong momentum, and we are thrilled that Android developers all over the world are discovering the joy of Kotlin programming,” James Lau, product manager for Android, wrote in a post. “Kotlin for Android is production-ready. From startups to Fortune 500 companies, developers are already using Kotlin to build their apps. Developers from Pinterest, to Expedia, to Basecamp — and many others — are finding their use of Kotlin is increasing productivity and their overall developer happiness levels.”

Google recently released Android Studio 3.0 with Kotlin support built-in.

Other announcements from the keynote included: Kotlin/Native IDE support, a initial preview version of the Kotlin/Native plugin for CLion; Ktor 0.9, a asynchronous coroutine-based Web framework built from Kotlin; and official Kotlin wrappers for React.js. According to the team, the new wrappers are perhaps the biggest news for web front-end development with Kotlin. The new feature enables developers to create modern web apps using React and Kotlin, without having to worry about project setup and build configuration.

“As for the future evolution of the language, our main goal at this time is to enable better and broader code reuse between the platforms supported by Kotlin. We plan to extend the set of libraries available on all platforms with the same API to include I/O, networking, serialization, date handling and more,” Jemerov wrote.

The focus of Kotlin 1.3 will include internal changes such as better performance, improved type inference, and improved responsiveness of IDE plugins.

User experience remains front and center for web application developers

In baseball, it’s three strikes and you’re out. In this age of app fatigue and digital transformations, the rules of America’s favorite pastime don’t apply to web application development. For most brands and enterprises, they have seconds to delight a user or they are skipping out of the ball park and onto the next competitor. Because for web app users today, having a fantastic application isn’t enough — if it doesn’t exceed their expectations in terms of performance, accessibility and responsiveness, you’re out.

While it’s getting harder to find quality web apps and software that works, development teams can build the best apps possible if they put the user front and center — this means considering usability testing as part of a software development lifecycle, looking into today’s modern technologies and frameworks, and finding new ways to give users the experiences they need so they always come back.

Usability testing
One of the ways to really hone in on the user’s wants and needs is to consider focused sessions as part of targeted user experience testing, according to engineering director at Sencha, Mark Brocato. This can cut down on development time since issues and potential problems are highlighted before the web application reaches its launch date.

Usability testing is an easy way to see how something is used, from real users, he added. Typically these users are asked to perform certain tasks, and it gives teams the ability to see where users may stumble and it helps the development team see if users are tripping up in any areas that they shouldn’t be, said Brocato.

Brocato said that his team has learned much about their own users at Sencha from conducting usability tests, and he said it’s better than trying to guess in your head what people are going to do (or not going to do) within a web application.

There are a few added benefits to usability testing. For instance, it gives teams direct feedback from the target audience to the project team, any internal debates can be resolved by testing issues with real users, and it minimises the risk of the web application failing when it goes into production.

Of course, there are a few disadvantages to usability testing, according to an ExperienceUX report. Usability testing is not always representative of the real life web app scenario, and it is qualitative, so it doesn’t provide large samples of feedback that an online questionnaire might, according to the report.

But, usability testing can help development teams gather information about the user’s needs when it comes to design, like the functionality and features of the web application. It won’t necessarily give teams an understanding of the needs that goes into the delivery of the application.

According to head of products at NGINX, Owen Garrett, the way to figure out those needs is to ask questions like, where is my user located? What is the standard of performance they expect? What devices are they using? How is the web application going to be deployed? Will the application need protection from spikes of traffic? These are the important questions to ask if you want the answers that directly relate to the user’s use of a web application, he added.

Considering developing a web app?
Even after a development team thinks about what they are going to build, and after they get that feedback from potential users, they still need to put the user experience front and center.
Users have so many choices right now, and if they are unhappy in the slightest bit, they know that they can go somewhere else because they’re not locked into one application anymore, said Rod Cope, CTO at Rogue Wave.

Performance continues to be a challenge for organizations, because like Cope mentioned, users want to stay in their flow and experience no delay. According to Rogue Wave’s research, they’ve seen that a one second delay in page load time leads to a 7% decrease in purchase conversion. That’s significant, said Cope.

Consider an ecommerce site that gets 100,000 business transactions per day, said Cope. With a one second page delay, it could cost the business $2 million a year just from a one second page load time.

“[We’re at] the point where you click something and you don’t want to notice that there is a delay, and if there is, you are already frustrated,” said Cope. “We are getting more and more used to having everything instantaneously.”

When it comes time to actually develop a web application, development teams need to think about more than just performance. They need to take a different approach than they would with developing a mobile application, too. For a long time, according to vice president and principal analyst at Forrester, Michael Facemire, businesses would take their website and jam it into mobile application. Now, businesses are looking at their mobile apps and considering how they can replicate that design and user experience as a web application, according to Facemire.

Instead of taking a mobile application and trying to recreate that same experience in a web application form, it makes more sense to consider users’ channels. For instance, if they are on a desktop, they are probably okay with a longer session with more in-depth experiences, whereas on a mobile device, users often want quick sessions, said Facemire. He added that the average session on a mobile device floats around a minute or minute and a half, and on a desktop, it’s longer than that, so a development team needs to deliver a much more detailed experience on the web, he said.

Screen real estate plays a role in web application development as well. Web application development requires different viewport sizes, the resolution, and web layouts. On a smaller device, users interact with their finger, swiping, tapping, and holding their finger down to complete a given task. On a larger device like a desktop, users lose that ability to tap and swipe.

According to Brocato, it’s the little things that can sway a user from using one application to its competitors. User’s tolerance for any experience, especially in the consumer setting, is very low, he said.

One solution to this development challenge is to simply build smaller releases, said Facemire. Software is shipped often and the releases are getting smaller and smaller, yet they still include something valuable to the customer. Shipping small allows development teams to gather feedback, conduct an analysis, and determine if the release was successful or not. And if it’s not, it shouldn’t cost a team 16 months in turnaround time, said Facemire. Teams need to fail fast and understand why their customers were unsatisfied.

“The concept of failing fast is important here,” said Facemire. “Let’s fail quickly, and then learn from that — you don’t have to get it right the first time, but if you don’t have it right, let’s understand why and let’s not make the same mistake again.”

Web application technologies
Another challenge for web application developers today is the “never-ending war of the frameworks,” as Brocato puts it.

“It’s like Game of Thrones, web style,” he said. “A year ago, when I went to my local Java meetup, the talk was all about React, now it’s shifting a bit.” He said that now, Angular is still fairly popular, but there are things like web components and additional frameworks that keep evolving, and fast.

Chances are, the framework you pick today is going to be close to outdated by the time you “finish” your web app. And if it’s not the framework, Brocato said it’s the language. Web application developers need to come to terms with this, they need to figure out a strategy for development and how to update and manage the apps so their app doesn’t look antiquated, said Brocato.

However, when it comes to languages, JavaScript still remains king of the castle. There are new flavors of the language for web development, with TypeScript and Flowscript getting some attention, according to Cope. They are compatible with JavaScript so developers can write in those languages and write code that runs in all browsers and devices.

Of course, added Cope, PHP is still popular, Java and Python continue to make moves in artificial intelligence, too. Other software and coding sites highlighted technology like AngularJS, React, Node.js, Ruby on Rails, ASP.NET, and Vue.js provide additional functionalities that can be utilized within your own web application development project.

When it comes time to actually develop a web application, Cope said that he thinks about it in two separate “camps” of development. Some teams think web applications need to be a separate mobile application written from the ground up, and those need to be native because you want maximum performance and the best user experience, he said.

Then there’s another camp: “Instead of doing all this extra effort to write these native apps in separate languages, let’s just use standard web technology and basically write a web application that runs on mobile devices, looks good and performs well,” said Cope.

He added, “I think you’ll see different companies going different directions, depending on what they are comfortable with.”

Development teams should also consider the microservice approach for the server side of the application, which allows you to build applications in a cloud native fashion so they are broken down into independent components which will scale and update individually. NGINX’s Garrett said that this gives teams flexibility and security as compared to monolithic application.

The convergence of mobile and web
While users are still mobile-first, and there are specific technologies that are better suited for mobile development, leaders in the development space are starting to see the technology that separates mobile applications and web applications is now starting to converge, according to Garrett.

For example, desktop web applications are operating at a mobile style, mobile apps rely on web page technologies and HTML renders custom code, he added.

But in terms of practical differences, Garrett said that mobile applications tend to use API requests much more than web apps. Web applications do traditional HTTP requests and mobile uses standardized APIs. Mobile apps go to great pains to batch up API requests so they can make as ingle large network request rather than multiple small ones, he said, however, one technology that is unifying both web and mobile is HTTP/2, which is a major revision of the HTTP network protocol used by the World Wide Web, and it is derived from the earlier experimental SPDY protocol.

“It’s a new way of delivering web content; it has security built in and performance optimization built in, and it allows mobile and web apps to get a great level of performance even if the underlying network is high latency,” said Garrett.

Also, what started as responsive design in the mobile application space is now becoming standard for web applications. HTML, web rendering technologies on the desktop — it’s all becoming the de facto standard for a great many web applications, said Garrett.

The Whopper Coin, Movidius Myriad X VPU, and DxEnterprise v17

Burger King has launched the Whopper Coin in Russia, which uses blockchain technology as a secure system for rewards points.

Customers will be able to scan their receipt with a smartphone and will be rewarded with 1 WhopperCoin for every rouble ($0.02) spent on a Whopper sandwich at the fastfood chain. When a user amasses 1,700 WhopperCoin (five or six burgers worth of purchases), they can redeem them for a free Whopper.

Since the crypto-currency is hosted on the Waves platform, it can be freely traded and transferred like any other.

“Eating Whoppers now is a strategy for financial prosperity tomorrow,” Burger King Russia’s head of external communications, Ivan Shestov said.

DH2i adds Linux, Docker support to high availability container solution
High availability and disaster recovery developer DH2i has launched DxEnterprise v17, adding support for Linux to the previously Windows Server-exclusive virtualization management software.

The new release adds support Docker containers for the first time, as well as updated support for SQL Server 2017.

“DH2i’s expanded capabilities have made the underlying infrastructure and platform essentially irrelevant for our customers,” said OJ Ngo, co-founder and CTO of DH2i. “Our customers are able to enjoy an extremely simplistic management experience with our unified interface for Windows, Linux and Docker—all while our Smart Availability technology dynamically ensures that workloads only come online at their best execution venue.”

Introducing the Movidius Myriad X vision processing unit (VPU)The Intel subsidiary Movidius is announcing its Movidius Myriad X vision processing unit, which is intended for deep learning and AI acceleration in vision based devices. Such devices include, drones, cameras, and AR/VR headsets.

The Myriad X features a Neural Compute Engine, which lets the Myriad X achieve over one trillion operations per second of peak DNN inferencing throughput. It also comes with a Myriad Development Kit, which includes all development tools, frameworks and APIs to implement custom vision, imaging, and deep neural network workloads on the chip.

Using Preact instead of React There are plenty of alternatives to React, and one open source project thinks that it is the best choice.

With the thinnest possible Virtual DOM abstraction on top of the DOM, Preact is a “first class citizen of the web platform,” according to the Preact team.

Preact is a speedy, lightweight library option, and it’s designed to work with plenty of React components. Preach is also small enough that the code is actually the largest part of the application, according to Preact’s team, which means less JavaScript to download, parse and execute. It includes extra performance features, and it’s optimized for event handling via Linked State. Developers can use Preact for building parts of apps without complex integration.

GitHub project of the week: Downshift

When Paypal realized they’d need a versatile item selection solution for their site, engineer Kent C. Dodds sat down and came up with Downshift.

Downshift is a set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete/dropdown/select/combobox components. It will be rolled out on Paypal.com next week, but in a post on Medium, Dodds outlined how his code, built with Facebook’s React JavaScript library, is a versatile outline for item selection in all its forms.

“We actually have several other item selection experiences in our app that have slightly different use cases and necessitated us having multiple implementations of an autocomplete component in the same app!” Dodds says in the post. “So that’s why I build downshift: so we could have a single implementation that was flexible enough to cover all the use cases.”

Dodds credits the versatility of his solution on his use of “Function as Child” and “Controlled Props” patterns, taking the rendering of menu selections out of React’s hands and leaving it up to the developer to determine what’s rendered in the selection field and how it’s rendered.

Also, Downshift has slowly been gaining popularity. It already has 900 stars on GitHub and 7,000 downloads per month, even before its official 1.0 release. That means it’s being used in several places, but according to Dodds, the first production deployment that he is aware of is in codesandbox from Ives van Hoorne.

Top 5 projects trending on GitHub this week:
#1. Interface: The Interface font family
#2. rendertron: A dockerized, headless Chrome rendering solution
#3. write-a-hash-table: Learn how to write a hash table in C
#4. weweChat: Unofficial WeChat client built with React, MobX and Electron.
#5. oni: An IDE powered by Neovim

Angular, React, Vue as most popular JavaScript frameworks at present, we just discuss Angular 1.x, Angular 2 / 4, React 15+ (Redux), and Vue 2+ here. There is no Angular 3, if you have not noticed before.

Client side is a battle field

In past 6–8 years, the Restful API has been accepted as one of standard web interfaces for most web applications, solution architect can simply add REST API on the top of existing web layer or business layer to provide REST API and support multiple client devices. So the developers can continue to develop or maintain system with their favorite programming language, framework or technical stacks.

On the contrary, it is a completely different story on the client-side, there are tons of variant JavaScript frameworks emerged in the last 10 years. It is good to have more options, but it is a nightmare for web developers who are working in such battle field, because they need to try a lot of different stuff to make a decision, especially when the project schedule is tight, it makes tech lead or architect quite stressed. Something becomes much worse is when the development team try to adopt new framework for the new project, it is not easy to work out which framework we should choose.

Don’t forget there is another big risk to adopt new programming language(ES 6 or Typescript) with the new framework, as well as new development, build and test tool, if the team has no enough skills or experience. As solution architect, they need to think it through for development team, and also consider if the team can really pick it up quickly. That is why we have to compare those frameworks here before we make a decision.

Performance is not a priority or crucial criterion for choosing a framework

We can find lots of comparison between those frameworks, and so many of them are related to performance, programming language, design pattern, etc. Actually many web applications in the world are just small to median size web application, we don’t need to build the web application as Google, Facebook or Twitter. In my opinion, the performance of framework is the not critical benchmark, at lease it is not first priority which we need to consider if it is right for the team. Except performance, we have more concern on tech stacks, community and ecosystem involved with the framework, which have more impact on team’s productivity and system’s maintainability.

The difference of those framework

Let’s look into the frameworks and list the difference of these frameworks.

Basic tech stacks

Cool stuff is not always the best

We have seen so many cool stuff which are finally abandoned in the past, the Silverlight is one of such examples. We shouldn’t choose new framework because it looks cool or it is the latest one. We choose the new one because it really can solve our problem, improve our productivity and quality in the long run. Don’t forget there is always some cost to adopt new things. We need to balance the cost and outcome of the technical investment, and we need to work it out if it is right time to do it.

Programming language is still the barrier

If we need to use new programming language, we have to evaluate with the existing development team. Even ES6 or TypeScript (TS) claims it is compatible to Vanilla JS, but when you start to look into new framework or sample project, which are coded with ES6 or TS, it still makes you so confused if you are not familiar with such syntax. It will significantly impact the efficiency of learning new framework. So there is always a learning curve, which we cannot ignore, to code something in a new programming language.

Someone complaints all those JS frameworks makes the build process much more complicated than the old web frameworks, because of the new programming language. Does it really matter? The short answer is Yes, but we are not going discuss the advantage in details here. If your team comes from .Net Web Form or Java MVC background, it would be a steep curve for the team to pick up ES6 or TypeScript and Component-based framework, not to mentioned new build and test tools.

No wonder a few .Net teams were struggling with Node stack integration on Visual Studio, especially when the team members have no Node.js experience. So we need the whole team to discuss the difficulties before we adopt new technology and framework. It is helpful to make sure the team has the same view, and it is also important to plan our training and decide how to transform development team step by step.

Where to start

For the team which comes with Web Form, with Vanilla JS background, we can start with Angular 1.x (Up to 1.4) on some small projects, or we can build something training project, because the MVC pattern is very similar to their previous coding experience.

One more thing, I have to mention is the Angular 1.x application can be built without any Node.js tools, such as Gulp, Grunt, Webpack, etc. It makes the team feel comfortable to adopt it without prior experiences. Also, it gives the team some buffer to organize the training to pick up Node.js tools for the future.

For the team which has experience of Angular 1.2 ~ 1.4, they can choose to stay on later version of Angular 1.x, e.g. Angular 1.5+, and they can start to convert coding pattern from MVC to Component-based. After that, if the team is planning to move to Angular 2 / 4, it is better to do some TypeScript training. In my view, so far the ecosystem for Angular 2 / 4 is still under development. It is a bit risky to use Angular 2 / 4 to build the real-world production. There are quite many gotchas which you have to figure out on your own.

For the team which has TypeScript or ES6 experience, they can choose what they prefer. They can spend more time on UI integration. There are a few customized UI package for bespoke framework. That is what we are going to discuss in the next.

Responsive UI library support

To build a real-world application, we need to integrate some popular responsive UI libraries instead of building all styles on our own. Let’s take a look the support of Bootstrap or Material-Design for different frameworks.

From what we can see now, the Bootstrap 4 is similar to Material-Desgin. So it is good news for developer. They just need to pick their favor, and they will always get analogical effect.

Actually there are tons of UI libraries / CSS framework available on Github, so many are platform neutral framework, i.e. It can be integreated with Angular, React or Vue. Be honest, integration is always not easy, it will take you or your team some extra effort. Keep it in mind, to integrate platform neutral framework you need to take care of dependencies and build, test tools on your own, such as webpack or yarn.

Stable API

Against to Angular 1.x, the Angular 2 is completely a new animal. Angular 4 comes with some breaking changes, which breaks a few Angular 2 dependencies (third parties). Since the API of Angular 4 is still under active development, we cannot use it for production. According to Angular team’s announcement, they want to fix all Angular-2’s bugs and issues in Angular 4 and keep all built-in libraries sync to Angular 4. It will take a long while to get things ready. If your project uses Angular 1.2–1.4, I’d like to suggest you to keep it, until Angular 4 is finalized.

React-Redux is much more popular than React-Flux recently, but it doesn’t means it is better than React-Flux pattern. In my opinion, React-Flux is much more straight and close to original React design. If you ready use React-Flux, you have better to stick with it.

Vue 2 comes with some breaking changes. There is migration guide for Vue 1.x to Vue 2. It doesn’t seem very different. Vue 2 is ready for production.

How to compare

In order to compare those frameworks properly, I use those frameworks to create a small real-world web application, which has built-in authentication support for the back-end API service, and integrated with some responsive UI framework, e.g. Bootstrap or Material-Design.

You will find there is no project built on the Angular 1.x, because my team and me have done a lot real-world application upon Angular 1.x. We know Angular 1.x, inlcuding its ecosystem is quite reliable, which you replicate any web application with this framework.

On the other hand, Angular 1.x is built with Vanilla JS, i.e. you don’t need transpiler to build Angular 1.x app, so it is a bit unfair to compare with the framework which is coded with ES 6 or TypeScript, because the build tool and setup for Angular 1.x is easier than others. I mention the Angular 1.x here to remind them, actually there is other option for the team comes from traditional MVC stacks. It would be proper way to transform the team smoothly.

Following are the projects and related screenshots

Comparison of projects for different framework

Let’s go back to projects above and take a look. Basically they are implemented almost the same features as real-world simple CRM application.

Features

  • Authentication & Token support for Restful API
  • Customer CRUD functions
  • Order CRUD functions
  • Dashboard including two charts (Bar/Line/Doughnut)
  • Integrate with Material Design (Angular project includes bootstrap)

According to above the dependencies, code size, we can see the project based on Vue.js is much simpler than other two projects.

In my view, Vue 2 is my favor for next new project. It combines advantages of Angular and React. It also addresses some problems which we found in Angular and React.

Vue.js uses Virtual DOM, which avoids many dirty checking in Angular 1.x, and the complicated coding pattern (Observable & ReactiveJs, IMO) in Angular 2 / 4.

Vue.js makes the handling of immutable and mutable variables much easier than React. Its template is very handy and straight. It is the same as regular HTML, it is very easy to convert the mock-up HTML into Vue template, especially when you need to customize you styles. Vue’s template and directive is similar to Angular.

Vue.js is not just cool, it is elegant and simple. I am pretty sure if you have Angular or React background, you will pick it up in a couple hours or days. Once you start to use it, you won’t want to go back. Its official routing system is quite stable and easy to use. Compare with Angular-Router or React-Router, it is much more reliable.

Generally, Material-Design libraries for React is not handy as other customized version for Angular or Vue. The special coding style of JSX needs to convert all CSS and HTML into JSX format. To be honest, I am not so convinced by React’s JSX, because it is not straight as final HTML or CSS. Compare to other framework, it is a bit verbose and inconvenient. We cannot simply copy the style code from the browser’s dev tool when we debug it on the browser. i.e. You need to put more effort to make your page pretty.

Angular’s Material-Design library has very limit components. To build a real-world application you need to add another UI library to supplement the former missing components. Last but not least, the Vuetify is the best Material-Design so far we have found and tested.

Repositoies

Summary

Before we make any conclusion, we have to be aware the world keeps changing. Perhaps when I was writing this article, some problem of framework have been solved, or some small problem became worse and worse. We have to review the decision we made from time to time and correct them ASAP if we find the cost is overweight the outcome.

  • Team with Web Form and Vanilla Js background should starts with Angular 1.4 and take some time to be familiar with Node.js tools
  • Team with Vanilla Js background should start to learn ES 6 or TypeScript, since sooner or later all the browsers, including mobile devices, will support ES 6 or TypeScript.
  • Team with ES6 /TypeScript background can choose any framework you prefer, the integration with other UI library will take you some time to make a judgement.
  • Team with React-Flux can continue or switch to React-Redux. It maybe reduces some boiler code, but I don’t think it is a big deal.
  • For the newcomer of React, I will recommand React-Redux, because it has better community support.
  • In my opinion, if you continue to invest anything on Angular 2, it is a bit waste, because Angular team hopes you to move to Angular 4 as soon as possible once Angular 4 is ready for production, and they are planning to fix Angular 2’s issues in Angular 4.
  • Angular 4 and its ecosystem are under active development, but please be careful if you want to use them in your production.
  • Vue.js framework is a very nice one. Give a go on your next project.

 

Article Originally appeared on Medium

React is best known as a client-side JavaScript framework, but did you know you can (and perhaps should!) render React server-side?

Suppose you’ve built a zippy new event listing React app for a client. The app is hooked up to an API built with your favorite server-side tool. A couple weeks later the client tells you that their pages aren’t showing up on Google and don’t look good when posted to Facebook. Seems solvable, right?

You figure out that to solve this you’ll need to render your React pages from the server on initial load so that crawlers from search engines and social media sites can read your markup. There is evidence showing that Google sometimes executes javascript and can index the generated content, but not always. So server-side rendering is always recommended if you want to ensure good SEO and compatibility with other services like Facebook, Twitter.

In this tutorial, we’ll take you through a server side rendering example step-by-step. including working around a common roadblock for React apps that talk to APIs.

#The Benefits of Server-Side Rendering

SEO might be the conversation that starts your team talking about server-side rendering, but it’s not the only potential benefit.

Here’s the big one: server-side rendering displays pages faster. With server-side rendering, your server’s response to the browser is the HTML of your page that is ready to be rendered so the browser can start rendering without having to wait for all the JavaScript to be downloaded and executed. There’s no “white page” while the browser downloads and executes the JavaScript and other assets needed to render the page, which is what might happen in an entirely client-rendered React site.

#Getting Started

Let’s go through how to add server-side rendering to a basic client rendered React app with Babel and Webpack. Our app will have the added complexity of getting the data from a third-party API. We’ve provided starter code on GitHub where you can see the complete example.

The starter code has just one React component, hello.js, that makes an asynchronous request to the ButterCMS API and renders the returned JSON list of blog posts. ButterCMS is an API-based blog engine that’s free for personal use, so it’s great for testing out a real-life use case. The starter code comes hooked up with an API token, but if you want you can get your own API token by signing into ButterCMS with your GitHub account.

import React from 'react';
import Butter from 'buttercms'

const butter = Butter('b60a008584313ed21803780bc9208557b3b49fbb');

var Hello = React.createClass({
  getInitialState: function() {
    return {loaded: false};
  },
  componentWillMount: function() {
    butter.post.list().then((resp) => {
      this.setState({
        loaded: true,
        resp: resp.data
      })
    });
  },
  render: function() {
    if (this.state.loaded) {
      return (
        <div>
          {this.state.resp.data.map((post) => {
            return (
              <div key={post.slug}>{post.title}</div>
            )
          })}
        </div>
      );
    } else {
      return <div>Loading...</div>;
    }
  }
});

export default Hello;

Here’s what else is included in the starter code:

  • `package.json` – for dependencies
  • Webpack and Babel configuration
  • `index.html` – the HTML for the app
  • `index.js` – loads React and renders the Hello component

To get the app running, first clone the repository:

git clone ...
cd ..

Install the dependencies:

npm install

Then start the development server:

npm run start

Browse to http://localhost:8000 to view the app:

If you view the source code of the rendered page, you’ll see that the markup sent to the browser is just a link to a JavaScript file. This means that the contents of the page are not guaranteed to be crawlable by search engines and social media platforms:

#Adding Server Side Rendering

Next we’ll implement server side rendering so that fully generated HTML is sent to the browser. If you want to view all the changes at once, view the diff on GitHub.

To get started, we’ll install Express, a Node.js server side application framework:

npm install express --save

We want to create a server that renders our React component:

import express from 'express';
import fs from 'fs';
import path from 'path';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import Hello from './Hello.js';

function handleRender(req, res) {
  // Renders our Hello component into an HTML string
  const html = ReactDOMServer.renderToString(<Hello />);

  // Load contents of index.html
  fs.readFile('./index.html', 'utf8', function (err, data) {
    if (err) throw err;

    // Inserts the rendered React HTML into our main div
    const document = data.replace(/<div id="app"><\/div>/, `<div id="app">${html}</div>`);

    // Sends the response back to the client
    res.send(document);
  });
}

const app = express();

// Serve built files with static files middleware
app.use('/build', express.static(path.join(__dirname, 'build')));

// Serve requests with our handleRender function
app.get('*', handleRender);

// Start server
app.listen(3000);

Let’s break down whats happening…

The handleRender function handles all requests. The ReactDOMServer class imported at the top of the file provides the renderToString() method that renders a React element to its initial HTML.

ReactDOMServer.renderToString(<Hello />);

This returns the HTML for the Hello component, which we inject into the HTML of index.html to generate the full HTML for the page on the server.

const document = data.replace(/<div id="app"><\/div>/, `<div id="app">${html}</div>`);

To start the server, update the start script in package.json and then run npm run start:

"scripts": {
  "start": "webpack && babel-node server.js"
},

Browse to http://localhost:3000 to view the app. Voila! Your page is now being rendered from the server. But there’s a problem. If you view the page source in the browser. You’ll notice that the blog posts are still not included in the response. What’s going on? If we open up the network tab in Chrome, we’ll see that the API request is happening on the client.

Although we’re rendering the React component on the server, the API request is made asynchronously in componentWillMount and the component is rendered before the request completes. So even though we’re rendering on the server, we’re only doing so partially. Turns out, there’s an issue on the React repo with over 100 comments discussing the problem and various workarounds.

#Fetching data before rendering

To fix this, we need to make sure the API request completes before the Hello component is rendered. This means making the API request outside of React’s component rendering cycle and fetching data before we render the component. We’ll take you through this step-by-step, but you can view the complete diff on GitHub.

To move data fetching before rendering, we’ll install react-transmit:

npm install react-transmit --save

React Transmit gives us elegant wrapper components (often referred to as “higher-order components”) for fetching data that work on the client and server.

Here’s what our component looks like with React Transmit implemented:

import React from 'react';
import Butter from 'buttercms'
import Transmit from 'react-transmit';

const butter = Butter('b60a008584313ed21803780bc9208557b3b49fbb');

var Hello = React.createClass({
  render: function() {
    if (this.props.posts) {
      return (
        <div>
          {this.props.posts.data.map((post) => {
            return (
              <div key={post.slug}>{post.title}</div>
            )
          })}
        </div>
      );
    } else {
      return <div>Loading...</div>;
    }
  }
});

export default Transmit.createContainer(Hello, {
  // These must be set or else it would fail to render
  initialVariables: {},
  // Each fragment will be resolved into a prop
  fragments: {
    posts() {
      return butter.post.list().then((resp) => resp.data);
    }
  }
});

We’ve wrapped our component in a higher-order component that fetches data using Transmit.createContainer. We’ve removed the lifecycle methods from the React component since there’s no need to fetch data twice. And we’ve changed the render method to use props references instead of state, since React Transmit passes data to the component as props.

To make sure the server fetches data before rendering, we import Transmit and use Transmit.renderToString instead of the ReactDOM.renderToString method.

import express from 'express';
import fs from 'fs';
import path from 'path';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import Hello from './Hello.js';
import Transmit from 'react-transmit';

function handleRender(req, res) {
  Transmit.renderToString(Hello).then(({reactString, reactData}) => {
    fs.readFile('./index.html', 'utf8', function (err, data) {
      if (err) throw err;

      const document = data.replace(/<div id="app"><\/div>/, `<div id="app">${reactString}</div>`);
      const output = Transmit.injectIntoMarkup(document, reactData, ['/build/client.js']);

      res.send(document);
    });
  });
}

const app = express();

// Serve built files with static files middleware
app.use('/build', express.static(path.join(__dirname, 'build')));

// Serve requests with our handleRender function
app.get('*', handleRender);

// Start server
app.listen(3000);

Restart the server browse to http://localhost:3000. View the page source and you’ll see that the page is now being fully rendered on the server!

#Going further

We’ve done it! Using React on the server can be tricky, especially when fetching data from API’s. Luckily the React community is thriving and creating lots of helpful tools. If you’re interested in frameworks for building large React apps that render on the client and server, check out the Electrode by Walmart Labs or Next.js. Or if you want to render React in Ruby, check out AirBnB’s Hypernova.

As the JavaScript library for building user interfaces React increases in popularity, one open-source project wants to help developers build their components. React Native UI Kitten is a mobile framework that provides a customizable and reusable React Native component kit.

According to the team, there are no frameworks that give developers access to commonly used React Native components, and allow them to style them according to their vision or goals.

“[React Native UI Kitten is a framework that contains a set of commonly used UI components styled in a similar way. The main idea of this framework is to move style definitions into a specific place making components reusable and styled in a single way. You just focus on business logic and it takes care of visual appearance,” the team wrote on the project’s GitHub page.

With this solution, developers can create style configuration of commonly used components, configure them once and use them anywhere, according to the team. Since it is just a set of UI components, developers don’t have to worry about working in a specific library.

“You’re able to use it with any existing react native component. You can add custom UI components, use Redux as a state container or any other library you like. react-native-ui-kitten aims only to simplify your experience with some basic components, like buttons, checkboxes, images etc,” Vlad Lugovsky, CEO and co-founder of Akveo (creator of React Native UI Kitten), wrote in a post.

To further the success of React Native UI Kitten, the team recently announced the Kitten Tricks apps as well as a complete refactor of the framework. Kitten Tricks is designed to be a starter kit for cross-platform React Native app development. It features an app loader, authentication screens, social screens, articles, a dashboard, settings and different navigation types.

“During several recent months we have been working really hard to bring our open-source react native products to the next level. We know that our initial attempt with react-native-ui-kitten was not really successful because of lack of functionality, no Android support and some other things. But we’re not the ones who leave the product on the half-way and give up, that’s why we decided to change the approach as well as our original idea,” the Akveo team wrote in a post.

Going forward, the team will continue to add new features to both the framework and app.

 

Top 5 trending projects on GitHub this week:

#1. VirtualAPK: A plugin framework for Android.
#2. Project Guidelines: Best practices for JavaScript Projects.
#3. Python: The Python programming language. Learn more about the language’s history here.
#4. Apollo: An open autonomous driving platform.
#5. Formik: A minimal Higher Order Component designed to make it easier to work with React.

With a few bug fixes and improvements, Facebook’s release of React 15.6 paves the way for the final release of React 16.0. React 15.6 cleans up a few issues, improves inputs, and includes a couple of new warnings for upcoming deprecations.

According to a blog by software engineer at Facebook, Flarnie Marchan, React 15.6 makes the onChange event for inputs more reliable and able to handle more edge cases, including: not firing when radio button is clicked but not changed; changing an input of type range with the arrow keys; auto-fill in IE11; and several other issues.

The Facebook React team also included new warnings for upcoming deprecations, which shouldn’t affect most users. After the last release, the React community found that deprecation warnings were causing noise and failing tests, so in this release deprecation warnings have been downgraded to use console.warn instead of console.error.

“Unlike our other warnings, deprecation warnings can be fixed over time and won’t cause problems in your app if shipped,” Marchan wrote. “We believe that downgrading the urgency of deprecation warnings will make your next update easier.”

For installing React, Facebook recommends using Yarn or npm for managing front-end dependencies. Facebook also recommends using a bundler like webpack or Browserify so developers can write modular code and bundle it into small packages to optimize load time, according to Marchan.

 

When getting started with new technologies and languages, it can be a bit daunting having to sift through all of the options for education resources. That’s why one full stack developer under the username bmorelli25 on GitHub wanted to create a free resource list, so others can get a little help while they begin their journey to becoming a web developer.

According to his GitHub page, he focused on JavaScript, React, and Node.js resources, but there is also “a wealth of information” on interview preparation and how to apply to full stack web development jobs.

After perusing this list of over 100 free learning resources, we decided to pull out some of the most interesting links to make the process of learning web development even easier.

Where to begin?
Morelli recommends getting started with Web Developer Roadmap. The Developer Roadmap demonstrates the paths developers can take and the technologies they would want to adopt in order to become a frontend, backend or a DevOps engineer.

Then, he suggests you read this FreeCodeCamp blog about a web developer’s journey to becoming a web developer without a computer science degree. In this blog, Sergei Garcia, a full-time front end developer wrote that he started out with the basics and created his learning path based on what entry-level web developer positions required.

That included skills like: JavaScript, HTML & CSS, CSS Preprocessors, responsive design, AngularJS, design patterns, Git, Node.js, and task runners.

Developers can also get started with this “great discussion of study techniques” from this Reddit post, according to Morelli. The thread talks about the beginners trick for learning to code, which is “repetition, repetition, repetition.”

What are some programs and classes to get me started?

  • The Odin Project: The Odin Project stitches together a curriculum from “the best” resources found online. It gives developers an introduction to web development, Ruby programming, Ruby on Rails, HTML5 and CSS3, and more.
  • FreeCodeCamp: The ever-trending open-source project, FreeCodeCamp, teaches people how to code while helping nonprofits at the same time. It’s free, and it teaches developers for non-developers skills like HTML5, CSS3, and JavaScript.
  • Upskill: Upskill, a course library for web development, hosts an essential web developer course for free. In this course, developers will learn how to build full stack web apps.
  • r/learnprogramming: Head to this Reddit thread and sift through the conversations to find over 530+ free online programming and CS courses to get you started with web development.
  • CS Protips: This GitHub project includes a collection of tips to take your CSS skills pro.
  • 10 principles for smooth web animations: Anand Sharma, founder of Gyroscope, developed a complete guide to getting 60fps animations with CSS.
  • JavaScript 30: Start the 30 day Vanilla JS coding challenge today. Build 30 things in 30 days with 30 tutorials. No frameworks, no compilers, no libraries and no boilerplate.

What about full stack tutorials?

Facebook is loading a slew of new tools into its development arsenal. The company announced new developer services and solutions at its annual F8 developer conference this week.

Adding to its React toolbox, the company announced a reimplementation of the JavaScript library core algorithm. React Fiber is designed to improve React’s suitability in areas such as animation, layout and gestures. According to Andrew Clark, a front-end engineer at Facebook, a key feature in React Fiber is its incremental rendering. The feature allows developers to “split rendering work into chunks and spread it out over multiple frames,” according to Clark. In addition, it features the ability to pause, abort or reuse work; assign priority to different updates; and provides new concurrency primitives.

React is also getting a new library for building virtual reality experiences. React VR provides anyone with a JavaScript understanding the tools they need to build and deploy VR experiences. “Those experiences can then be distributed across the web — React VR leverages APIs like WebGL and WebVR to connect immersive headsets with a scene in a web page. And to maximize your potential audience, sites built in React VR are also accessible on mobile phones and PCs, using accelerometers or the cursor for navigation,” Andrew Imm, software engineer at Facebook, wrote in a post.

With React VR, developers can create 3D scenes, build audio and video capabilities, and provide 360-degree content. “React VR continues to drive the mantra of the React ecosystem: Learn once, write anywhere,” Imm wrote.

In addition, Facebook introduced a new version of its JavaScript framework for building data-driven React apps. Relay Modern is designed to make Relay easier to use, more extensible, and enhance mobile device performance. “Our goal with Relay is to allow developers to move fast by focusing more on building their applications and less on re-implementing these complex and error-prone details,” Lee Byron and Joe Savona, Facebook team members, wrote in a post.

According to Byron and Savona, as Relay started to be used on a variety of different devices the team realized some limitations with the design. For instance, the nature of the API made it difficult to achieve a high level of performance. The API also made it hard for developers to learn and predict things.

“Relay Modern retains the best parts of Relay — colocated data and view definitions, declarative data fetching — while also simplifying the API, adding features, improving performance, and reducing the size of the framework,” the team wrote. Relay Modern features two new concepts: static queries and ahead-of-time optimization, and adds simpler mutations and garbage collection.

The company also released a declarative UI framework for Android into open source. According to the team members, building a smooth UI performance on Android is too difficult. As a result, the company developed Litho to provide UI optimizations under the hood while keeping the code maintainable.

“Building on the success we’ve seen with React, we wanted to deliver a simple API for defining user interfaces from declarative components, with performance as the primary goal. We designed the framework to be fast, even for our complex products such as News Feed,” Pasquale Anatriello and Marco Cova, Facebook team members, wrote in a post.

Litho features asynchronous layout, flatter view hierarchies, and fine-grained recycling to define UI components. More information is available here.