This document discusses JavaScript Computation Expressions (Jscex), which allows writing asynchronous JavaScript code in a synchronous-looking style using computation expressions. Key points:
- Jscex uses computation expressions to write asynchronous JavaScript code that looks synchronous using constructs like $await.
- Asynchronous functions can be defined and composed together asynchronously and parallel using $await without callbacks or promises.
- This allows asynchronous code to be written in a way that resembles synchronous code for readability while still maintaining asynchrony under the hood.
This document discusses Mono and how it allows .NET applications to run on non-Windows platforms. Specifically:
- Mono is an open source implementation of the .NET Framework that works on Linux, macOS, iOS, Android and more. It allows developers to write .NET applications that can run anywhere.
- Many games and apps are built with Mono, including Unity games, iOS apps using MonoTouch, and Android apps using Mono for Android.
- Mono aims to be compatible with Microsoft's .NET implementation so that most .NET code will run unchanged on Mono's supported platforms. This allows developers to target multiple platforms with one codebase.
This document summarizes Jeffrey Zhao's background and areas of expertise. It includes:
1. Jeffrey Zhao is a software engineer from China who blogs at http://blog.zhaojie.me/. His areas of expertise include JavaScript, F#, Scala, C#, Python, .NET and Mono.
2. The document provides code examples in different programming languages for common algorithms and data structures like sorting and grouping, demonstrating Jeffrey's proficiency in languages like C#, F#, Ruby, Java, and JavaScript.
3. It introduces Jscex, a JavaScript library created by Jeffrey that allows writing asynchronous code in a synchronous style using JavaScript computation expressions. Jscex compiles asynchronous code into
This document discusses Jscex, which allows writing asynchronous JavaScript code in a synchronous style using the $await operator. It provides examples of rewriting bubble sort to use asynchronous compare and swap functions. It also discusses using Jscex to handle parallelism, I/O, and concurrency in applications. Key benefits mentioned include just-in-time compilation for performance and ahead-of-time compilation for smaller file sizes.
The document introduces Jscex, a JavaScript library that provides computation expressions to help with common programming scenarios in JavaScript. It allows writing asynchronous code in a synchronous-looking way. Key points:
- Jscex is a library, not a language, framework or runtime. It works with any JavaScript engine.
- It keeps the JavaScript language semantics and allows programming asynchronously without breaking code locality.
- Examples show how it can be used to animate bubble sort and handle asynchronous operations like HTTP requests in an easier way compared to promises or callbacks.
This document discusses documentation insight tools and techniques. It describes XML documentation, code modeling that involves lexing and parsing source code, and transformations from XML to HTML using XSLT. It also discusses extending the Delphi IDE with add-ins, such as for documentation insight. Pricing and sales strategies are mentioned, such as hosting on WordPress and using a sales platform. The document provides contact information for the author at the end.
The document discusses distributed version control systems (DVCS) like Mercurial and demonstrates basic Mercurial commands. It shows initializing a repository, making commits, viewing history, cloning, pushing and pulling changes, resolving merge conflicts, and using commands like backout to undo previous commits.
.Net provides several technologies for building distributed applications, including Remoting, WCF, and RPC. These technologies allow communication between applications running on different machines through mechanisms like object serialization, message passing, and remote procedure calls. Developers can define service interfaces and contracts to specify available operations and exchange data between clients and servers across a network.
This document discusses best practices for developing high performance mobile web applications for the iPad. It covers setting up a high performance infrastructure with load balancing and distributed caching. It also discusses following YSlow and mobile web best practices such as minimizing requests, optimizing caching, reducing cookies, and optimizing HTML and CSS. Special considerations for the iPad are also covered, such as touch events, viewport dimensions, lower cache limits, slower CPU and network speeds. The document stresses that performance optimization requires trade-offs and provides references for further reading on high performance web development.
This document contains information about Amos Shi, including his background and areas of expertise. It discusses topics like type ranges, search helps, internationalization (I18N), and use of structures in different programming languages. Code examples are provided for type ranges, search helps, and implementing I18N in ABAP.
The Evolution of Async-Programming on .NET Platform (TUP, Full)jeffz
The document discusses the evolution of asynchronous programming on the .NET platform. It covers:
1. .NET 1.0 introduced basic asynchronous patterns using Begin/End methods and event-based callbacks, but they broke code locality and were difficult to use.
2. .NET 2.0 and C# 2.0 introduced "yield return" which allowed iterating over asynchronous operations in a synchronous style and improved code locality.
3. .NET 3.0 and F# further advanced this by treating asynchronous operations as first-class functions, allowing easier composition and exception handling of multiple asynchronous tasks.
4. Future versions aim to continue improving asynchronous programming models and libraries to better support cloud, web and mobile
The Evolution of Async-Programming on .NET Platform (.Net China, C#)jeffz
This document discusses the evolution of asynchronous programming on the .NET platform. It covers early approaches using Begin/End methods and event-based patterns in .NET 1.0. It then discusses improvements with yield in .NET 2.0/C# 2.0 and async workflows in F# for .NET 3.0. It also covers the Reactive Framework for .NET 4.0 which treats asynchronous computations as push-based collections. Finally, it discusses potential future improvements in C# vNext.
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
This document discusses the evolution of asynchronous programming. It begins by explaining why asynchronous programming is important for cloud, web and mobile applications due to their inherently asynchronous nature. It then covers several approaches to asynchronous programming including callback-based, iterator-based, library-based using reactive frameworks, and language-based features. Specific examples are provided for each approach. The document concludes by discussing some future directions for asynchronous programming support in languages like C#.
The document contains code snippets and notes about programming concepts including loops, variables, strings, data structures, and algorithms. It discusses calculating a running sum using a loop, Donald Knuth's work, comparisons and equality operators, nested quotes, trees and balancing, and hashing techniques. Various programming examples and pseudocode are provided to illustrate core programming principles.
The document discusses object-oriented programming (OOP) concepts and design principles including polymorphism, inheritance, abstraction and encapsulation. It provides examples of applying these concepts when modeling real-world entities like vehicles, animals that can bark and cargo that can be paid for. Design patterns like singleton, factory and observer are also covered with examples shown in C#.
The document discusses Windows kernel technologies including the Windows architecture, system traps, I/O model, device drivers, and Windows subsystems. It provides an overview of the Windows NT timeline from 1989 to 2009 and describes key components of the Windows architecture like the executive, kernel, and hardware abstraction layer. It also covers topics such as Windows APIs, calling into the kernel, the I/O manager, drivers, and I/O processing.
The document discusses reactive programming and frameworks. It introduces reactive programming as a way to think about asynchronous and event-based programming that is fundamental to cloud, web and mobile applications. It shows how asynchronous and event-based computations can be viewed as push-based collections by dualizing enumerable collections to observable collections. This allows applying LINQ-style queries to asynchronous programming. Examples are provided for moving a ball with keyboard input and dragging the mouse to draw, implemented imperatively and declaratively with observables.
12. 冒泡排序
var compare = function (x, y) {
return x - y;
}
var swap = function (a, i, j) {
var t = a[x]; a[x] = a[y]; a[y] = t;
}
var bubbleSort = function (array) {
for (var x = 0; x < array.length; x++) {
for (var y = 0; y < array.length - x; y++) {
if (compare(array[y], array[y + 1]) > 0) {
swap(array, y, y + 1);
}
}
}
}
13. 做成动画
var compare = function (x, y, callback) { var innerLoop = function (array, x, y, callback) {
setTimeout(10, function () { if (y < array.length - x) {
callback(x - y); compare(array[y], array[y + 1], function (r) {
}); if (r > 0) {
} swap(array, y, y + 1, function () {
innerLoop(array, x, y + 1, callback);
var swap = function (a, i, j, callback) { });
var t = a[x]; a[x] = a[y]; a[y] = t; } else {
repaint(a); innerLoop(array, x, y + 1, callback);
}
setTimeout(20, callback); });
} } else {
callback();
var outerLoop = function (array, x, callback) { }
if (x < array) { }
innerLoop(array, x, 0, function () {
outerLoop(array, x + 1, callback); outerLoop(array, 0, function () {
}); console.log("done!");
} else { });
callback();
}
}
14. 做成动画
!
var compare = function (x, y, callback) { var innerLoop = function (array, x, y, callback) {
setTimeout(10, function () { if (y < array.length - x) {
啊
callback(x - y); compare(array[y], array[y + 1], function (r) {
么
}); if (r > 0) {
} swap(array, y, y + 1, function () {
什
innerLoop(array, x, y + 1, callback);
var swap = function (a, i, j, callback) { });
是
var t = a[x]; a[x] = a[y]; a[y] = t; } else {
D
repaint(a); innerLoop(array, x, y + 1, callback);
}
M
setTimeout(20, callback); });
} } else {
T
callback();
var outerLoop = function (array, x, callback) { }
这
if (x < array) { }
innerLoop(array, x, 0, function () {
outerLoop(array, x + 1, callback); outerLoop(array, 0, function () {
}); console.log("done!");
} else { });
callback();
}
}
15. 冒泡排序动画
var compareAsync = eval(Jscex.compile("async", function (x, y) {
$await(Jscex.Async.sleep(10)); // each "compare" takes 10 ms.
return x - y;
}));
var swapAsync = eval(Jscex.compile("async", function (a, x, y) {
var t = a[x]; a[x] = a[y]; a[y] = t; // swap
repaint(a); // repaint after each swap
$await(Jscex.Async.sleep(20)); // each "swap" takes 20 ms.
}));
var bubbleSortAsync = eval(Jscex.compile("async", function (array) {
for (var x = 0; x < array.length; x++) {
for (var y = 0; y < array.length - x; y++) {
var r = $await(compareAsync(array[y], array[y + 1]));
if (r > 0) $await(swapAsync(array, y, y + 1));
}
}
}));
16. 冒泡排序动画
var compareAsync = eval(Jscex.compile("async", function (x, y) {
$await(Jscex.Async.sleep(10)); // each "compare" takes 10 ms.
return x - y;
}));
var swapAsync = eval(Jscex.compile("async", function (a, x, y) {
var t = a[x]; a[x] = a[y]; a[y] = t; // swap
repaint(a); // repaint after each swap
$await(Jscex.Async.sleep(20)); // each "swap" takes 20 ms.
}));
var bubbleSortAsync = eval(Jscex.compile("async", function (array) {
for (var x = 0; x < array.length; x++) {
for (var y = 0; y < array.length - x; y++) {
var r = $await(compareAsync(array[y], array[y + 1]));
if (r > 0) $await(swapAsync(array, y, y + 1));
}
}
}));
37. Show Me the Code
exports.getUserActivity = function (uid, me_uid, count, page, cb) {
var query = models.Activity.find(...).where(...).desc(...);
query.exec(function (err, activities) {
if (err) return cb(err);
for (var i = 0; i < activities.length; i++) {
var activity = activities[i];
var board_id = activity.data.board.board_id;
db.ActivityData.getBoard(board_id, function (err, board) {
// how to execute async operations in a loop?
});
}
});
};
38. Jscex化
exports.getUserActivityAsync = eval(..., function (...) {
var query = models.Activity.find(...).where(...).desc(...);
var activities = $await(query.execAsync());
for (var i = 0; i < activities.length; i++) {
var activity = activities[i];
var board_id = activity.data.board.board_id;
var board = $await(db.ActivityData.getBoardAsync(board_id));
...
}
}));
39. 并行化
exports.getUserActivityAsync = eval(..., function (...) {
var query = models.Activity.find(...).where(...).desc(...);
var activities = $await(query.execAsync());
var boardsTasks = _.map(activities, function (a) {
var board_id = a.data.board.board_id;
// no $await!
return db.ActivityData.getBoardAsync(board_id);
});
// execute in parallel
var boards = $await(Task.whenAll(boardsTasks));
}));