We talk about JavaScript. Each month in Warsaw, Poland.
codequest
Bialystok
// Android
var time = new android.text.format.Time();
time.set(1, 0, 2015);
console.log(time.format("%D"));
// iOS
var alert = new UIAlertView();
alert.message = "Hello world!";
alert.addButtonWithTitle("OK");
alert.show();
var file = new java.io.File(path);
UI Thread
source: https://github.com/NativeScript/sample-iOS-Profiling
Blank app with a single button.
Platform | Run 1 | Run 2 | Run 3 |
---|---|---|---|
Native | 111ms | 105ms | 108ms |
React Native | 358ms | 361ms | 353ms |
Xamarin Forms | 484ms | 471ms | 469ms |
Cordova | 613ms | 612ms | 609ms |
NativeScript | 674ms | 672ms | 670ms |
Marshaling of numbers between JavaScript and native. 1 000 000 calls to native code.
Platform | Run 1 | Run 2 | Run 3 |
---|---|---|---|
Native | 5ms | 4ms | 4ms |
Xamarin | 27ms | 27ms | 28ms |
NativeScript | 989ms | 998ms | 980ms |
Appcelerator | 34444ms | 33969ms | 35916ms |
React Native | 130600ms | 125140ms | 127220ms |
Cordova | 351420ms | 357940ms | 356740ms |
Marshaling of strings between JavaScript and native. 100 000 calls to native code.
Platform | Run 1 | Run 2 | Run 3 |
---|---|---|---|
Native | 42ms | 42ms | 42ms |
Xamarin | 248ms | 234ms | 244ms |
NativeScript | 415ms | 444ms | 418ms |
Appcelerator | 3215ms | 3198ms | 3180ms |
React Native | 12358ms | 12464ms | 12547ms |
Cordova | 36864ms | 36063ms | 35861ms |
Marshaling of an array with 65 536 elements between JavaScript and native. 200 calls to native code.
Platform | Run 1 | Run 2 | Run 3 |
---|---|---|---|
Native | 768ms | 774ms | 759ms |
NativeScript | 1135ms | 1129ms | 1138ms |
Xamarin | 3763ms | 3906ms | 3789ms |
Cordova | 9655ms | 9714ms | 9730ms |
React Native | 47873ms | 47695ms | 47859ms |
Appcelerator | 50091ms | 45149ms | 47927ms |
var fs = require("file-system");
var documents = fs.knownFolders.documents();
documents.getFile("Test.txt").readText()
.then(function (content) {
// Successfully read the file's content.
});
var http = require("http");
http.getJSON("https://httpbin.org/get")
.then(function (r) {
// Argument (r) is JSON!
});
// file.ios.js
exports.getFile = function(path) {
var fileManager = NSFileManager.defaultManager();
return fileManager.createFileAtPathContentsAttributes(path);
}
// file.android.js
exports.getFile = function(path) {
return new java.io.File(path);
}
// main.js
var File = require("./file");
var file = File.getFile("path");
AbsoluteLayout
DockLayout
GridLayout
StackLayout
WrapLayout
import {Component} from "@angular/core";
@Component({
selector: "my-app",
template: "<Label text=‘Hello!’></Label>"
})
export class AppComponent {}
kondraciukpawel@gmail.com