--
-
file size --
-
not PWA-friendly --
-
too many efforts!
- the web service itself
- chunks uploading
var data = [ 56, 32, 0, 9, 12 ]; // one item per byte
--
-
Waste of memory (JavaScript Numbers are Always 64-bit Floating Point) --
-
Waste of computational resource (you can't predict data's structure)
regular js Array is dynamic, and either dense or sparse
// create a dense array
var data = [1, 2, 3, 4, 5];
// create a sparse array
var data = [];
data[666] = 'pretty good';
From MDN:
The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer
And there's two ways to read/manipulate the data
--
-
TypedArray --
-
DataView
--
Square-Surface-Stiff-Gang
--
正面硬刚
-
hard --
-
slow
--
--
There's many existing codec encoders, written in C
an extraordinarily optimizable, low-level subset of JavaScript
function f(i) {
i = i|0;
return (i + 1)|0;
}
A LLVM backend, compiles LLVM to ASJ.js
--
Code --(LLVM frontend)--> IR --(LLVM backend)--> Bytecode
--
in theory
ActionScript, Ada, C#, Common Lisp, Crystal, D, Delphi, Fortran, OpenGL Shading Language, Halide, Haskell, Java bytecode, Julia, Lua, Objective-C, Pony, Python, R, Ruby, Rust, CUDA, Scala, Swift, and Xojo.
--
-
binary version of asm.js --
-
W3C open standard --
-
supported by browsers natively
a compiler for LLVM-WebAssembly compilation
asm-to-wasm
C/C++ => LLVM => ASM.JS => WASM
var Module = WebAssembly.instantiate(codeBuffer);
// now we can use those methods
Module.exposedMethodA();
Module.exposedMethodB();
// ...
var worker = new Worker('myWorker.js');
- There's only one way to communicate with workers
- the variable transfering
worker.postMessage({ name: 'jcppman' });
onmessage = function(a, b, c) {
// do things
};
- There's only one way to communicate with workers
- the variable transfering
DEMO
DEMO