{"id":284013,"date":"2017-03-28T12:15:02","date_gmt":"2017-03-28T08:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=284013"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=284013","title":{"rendered":"\u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c web-frontend \u043d\u0430 Rust (WebAssembly)"},"content":{"rendered":"<h1>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 Rust \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/h1>\n<p>  <\/p>\n<p><img decoding=\"async\" align=\"left\" src=\"https:\/\/habrastorage.org\/files\/195\/e22\/746\/195e227465ed4554b4dc6c27ce940055.gif\"\/> \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0432\u044b\u0448\u043b\u0430 \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e webassembly \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 firefox 52 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0410 \u043f\u043e\u0442\u043e\u043c \u0435\u0449\u0435 \u0438 chrome 57 \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u043b\u0441\u044f (\u043f\u0440\u0430\u0432\u0434\u0430, \u0442\u0430\u043c \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0431\u044b\u043b\u0438 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0431\u0430\u0433\u0438 \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c). \u042f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 webassembly \u043a\u0440\u0430\u0442\u043a\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f: webassembly (\u0438\u043b\u0438 wasm) \u2014 \u044d\u0442\u043e \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u044f\u0437\u044b\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u044b, \u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445. \u042d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0433\u043e\u0434\u043d\u043e \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0447\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u044f\u0437\u044b\u043a\u0438 \u0432 \u0447\u0438\u0441\u0442\u044b\u0439 javascript \u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c asm.js. <\/p>\n<p>  <\/p>\n<p>Wasm \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0434\u043b\u044f c\/c++, \u043d\u043e, \u043d\u0430 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0436\u0435 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 rust. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0412\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 Ubuntu. \u0411\u0435\u0437 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0435\u0442\u0430\u043b\u0435\u0439, \u043f\u0440\u043e\u0441\u0442\u043e &quot;\u043f\u043e\u0449\u0443\u043f\u0430\u0435\u043c&quot;. <\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c Rust \u0438 emscripten SDK<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f rustup. \u042d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u0430\u043a \u0441\u0430\u043c\u043e\u0433\u043e rust \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430, \u0442\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u0438\u0437 rust \u043c\u0438\u0440\u0430. <\/p>\n<p>  <\/p>\n<pre><code>curl https:\/\/sh.rustup.rs -sSf | sh<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0432 \u0432\u0430\u0448 <code>~.profile<\/code> \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0443\u0442\u044c \u0434\u043e \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a\u043e\u0432 cargo, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u043b\u043e\u0433\u0438\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>source $HOME\/.cargo\/env<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 target<\/p>\n<p>  <\/p>\n<pre><code>rustup install stable rustup default stable rustup target add wasm32-unknown-emscripten<\/code><\/pre>\n<p>  <\/p>\n<p>emscripten \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0439 LLVM-to-javascript \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440. \u0422\u0430\u043a\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u0438 wasm. (\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, Rust \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 llvm).<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0434\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c sdk \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430. \u041a\u0430\u0447\u0430\u0435\u043c \u0444\u0430\u0439\u043b <code>emsdk-portable.tar.gz<\/code> \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b <a href=\"http:\/\/kripken.github.io\/emscripten-site\/docs\/getting_started\/downloads.html#sdk-downloads\">http:\/\/kripken.github.io\/emscripten-site\/docs\/getting_started\/downloads.html#sdk-downloads<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code>mkdir emsdk cd emsdk wget &quot;https:\/\/s3.amazonaws.com\/mozilla-games\/emscripten\/releases\/emsdk-portable.tar.gz&quot; tar -xzf emsdk-portable.tar.gz cd emsdk_portable source emsdk_env.sh<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0434\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u043f\u0430\u0440\u0443 \u0447\u0430\u0441\u043e\u0432, \u043f\u0440\u0438\u0447\u0435\u043c \u0441 \u0434\u0438\u043a\u0438\u043c \u0432\u044b\u0436\u0438\u0440\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  <\/p>\n<pre><code>emsdk update emsdk install sdk-incoming-64bit emsdk activate sdk-incoming-64bit<\/code><\/pre>\n<p>  <\/p>\n<p>emsdk \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c<br \/>  <code>source .\/emsdk_env.sh<\/code><\/p>\n<p>  <\/p>\n<h2>Hello, world<\/h2>\n<p>  <\/p>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0439 \u0445\u0435\u043b\u043b\u043e\u0432\u043e\u0440\u043b\u0434 \u043d\u0430 \u0440\u0430\u0441\u0442\u0435<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     println!(&quot;============\\nHello, world\\n===============&quot;); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c<\/p>\n<p>  <\/p>\n<pre><code>rustc --target=wasm32-unknown-emscripten wasmtest.rs<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0444\u0430\u0439\u043b wasmtest.wasm, \u0430 \u0442\u0430\u043a\u0436\u0435 js-\u043e\u0431\u0432\u044f\u0437\u043a\u0443 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 (wasmtest.js), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>&lt;script src=&quot;wasmtest.wasm&quot;&gt;<\/code><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e html-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u043b\u0430. <\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt; &lt;html lang=&quot;ru&quot;&gt; &lt;head&gt;     &lt;meta charset=&quot;utf-8&quot; \/&gt;     &lt;title&gt;Rust Wasm&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;script type='text\/javascript'&gt;     var Module = {};     fetch('wasmtest.wasm').then(response =&gt;         response.arrayBuffer()     ).then(buffer =&gt; {         Module.wasmBinary = buffer;         const script = document.createElement('script');         script.src = &quot;wasmtest.js&quot;;         document.body.appendChild(script);     }); &lt;\/script&gt; &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c http-\u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 python, \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438<\/p>\n<p>  <\/p>\n<p><code>python -m SimpleHTTPServer<\/code><\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 (\u043b\u0443\u0447\u0448\u0435 \u0432 firefox) <code>http:\/\/localhost:8000\/hello.html<\/code> \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043d\u0430\u0434\u043f\u0438\u0441\u044c &quot;Hello, world!&quot;.<\/p>\n<p>  <\/p>\n<h2>\u0414\u043e\u0441\u0442\u0443\u043f \u043a DOM<\/h2>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0441\u043e\u043b\u044c \u2014 \u044d\u0442\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u043d\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0447\u0442\u043e-\u0442\u043e \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u044b \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 DOM. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0437\u0430\u0440\u044b\u043b\u0441\u044f \u0432 \u043c\u043e\u0437\u0433\u043e\u0434\u0440\u043e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0432\u0441\u0451 \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0434\u043e \u043d\u0430\u0441. \u0415\u0441\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/github.com\/tcr\/rust-webplatform\">webplatform<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0432\u0435\u0449\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 DOM. <\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">extern crate webplatform;  fn main() {     println!(&quot;============\\nHello, world\\n===============&quot;);     let document = webplatform::init();     let body = document.element_query(&quot;body&quot;).unwrap();     body.html_set(&quot;&lt;h1&gt;\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440, \u044f web assembly!&lt;\/h1&gt; &lt;button&gt;\u041d\u0430\u0436\u043c\u0438 \u043c\u0435\u043d\u044f&lt;\/button&gt;&quot;);     let button = document.element_query(&quot;button&quot;).unwrap();     button.on(&quot;click&quot;, |_| webplatform::alert(&quot;\u041a\u043d\u043e\u043f\u043a\u0430 \u043d\u0430\u0436\u0430\u0442\u0430!&quot;)); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/anton-okolelov\/wasm-rust-dom\">github<\/a><\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0431\u0440\u0430\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code>cargo build --target=wasm32-unknown-emscripten rustc --target=wasm32-unknown-emscripten src\/wasmtest.rs -L target\/wasm32-unknown-emscripten\/debug\/deps\/ <\/code><\/pre>\n<p>  <\/p>\n<p>(\u042f \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0437\u043d\u0430\u0442\u043e\u043a \u0440\u0430\u0441\u0442\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043e\u0434\u043d\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 cargo, \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0438\u0442\u0435 \u043f\u043b\u0438\u0437).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0442\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u043f\u0438\u0442\u043e\u043d-\u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<p>  <\/p>\n<pre><code>python -m SimpleHTTPServer<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 firefox <code>http:\/\/localhost:8000\/hello.html<\/code>. \u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0430 \u041a\u0414\u041f\u0412.<\/p>\n<p>  <\/p>\n<p>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 hello.html \u0442\u043e\u0436\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0449\u0443\u043f\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443 \u0441\u0435\u0431\u044f, \u043d\u0435 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044f\u0441\u044c \u0441 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0435\u0439.<\/p>\n<p>  <\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b \u0438 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u044b<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0441\u0451 \u0441\u044b\u0440\u043e\u0435, \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u0438 \u0441 \u0431\u0430\u0433\u0430\u043c\u0438, \u043d\u043e \u0443 webassembly \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0431\u0443\u0434\u0443\u0449\u0435\u0435. \u0412\u0441\u0451, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439, \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0438\u0437 javascript \u043d\u0430 wasm. \u041f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0442\u044f\u0436\u0435\u043b\u044b\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0432 \u0432\u0435\u0431\u0435, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0438 \u043c\u0435\u0447\u0442\u0430\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u043c. \u041d\u0430\u0432\u043e\u0440\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0433\u0440\u044b? \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0432\u0438\u0434\u0435\u043e \u0438 \u0437\u0432\u0443\u043a\u0430? \u041a\u0442\u043e \u0437\u043d\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<p>\u041a\u0443\u0447\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043d\u0430 c, c++, rust \u0438 \u0442.\u0434. \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043d\u0430 \u043d\u0430 \u0432\u0435\u0431 \u0432 \u0432\u0438\u0434\u0435 wasm-\u043c\u043e\u0434\u0443\u043b\u0435\u0439. <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0442\u044f\u0442 \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c reactjs \u0437\u0430\u0441\u0447\u0435\u0442 rust \u0438 wasm (<a href=\"https:\/\/users.rust-lang.org\/t\/rust-wasm-project-idea-accelerate-react\/9944\">\u0441\u0441\u044b\u043b\u043a\u0430<\/a>). <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043f\u0440\u043e\u043f\u0440\u0438\u0435\u0442\u0430\u0440\u043d\u044b\u0439 \u043a\u043e\u0434. \u0415\u0441\u043b\u0438 js, \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 uglifyjs \u0435\u0449\u0435 \u043a\u0430\u043a-\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c, \u0442\u043e c wasm \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u044b. \u0427\u0442\u043e \u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u0432\u044b?<\/p>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/325008\/\"> https:\/\/habrahabr.ru\/post\/325008\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<h1>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 Rust \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/h1>\n<p>  <\/p>\n<p><img decoding=\"async\" align=\"left\" src=\"https:\/\/habrastorage.org\/files\/195\/e22\/746\/195e227465ed4554b4dc6c27ce940055.gif\"\/> \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0432\u044b\u0448\u043b\u0430 \u043d\u043e\u0432\u043e\u0441\u0442\u044c \u043f\u0440\u043e \u0442\u043e, \u0447\u0442\u043e webassembly \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 firefox 52 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438. \u0410 \u043f\u043e\u0442\u043e\u043c \u0435\u0449\u0435 \u0438 chrome 57 \u043f\u043e\u0434\u0442\u044f\u043d\u0443\u043b\u0441\u044f (\u043f\u0440\u0430\u0432\u0434\u0430, \u0442\u0430\u043c \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0431\u044b\u043b\u0438 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0431\u0430\u0433\u0438 \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c). \u042f \u0440\u0435\u0448\u0438\u043b, \u0447\u0442\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 webassembly \u043a\u0440\u0430\u0442\u043a\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f: webassembly (\u0438\u043b\u0438 wasm) \u2014 \u044d\u0442\u043e \u043d\u0438\u0437\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 \u044f\u0437\u044b\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u044b, \u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445. \u042d\u0442\u043e \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0433\u043e\u0434\u043d\u043e \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0447\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u044f\u0437\u044b\u043a\u0438 \u0432 \u0447\u0438\u0441\u0442\u044b\u0439 javascript \u0438\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c asm.js. <\/p>\n<p>  <\/p>\n<p>Wasm \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0434\u043b\u044f c\/c++, \u043d\u043e, \u043d\u0430 \u0443\u0434\u0438\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0436\u0435 \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 rust. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u0412\u0441\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 Ubuntu. \u0411\u0435\u0437 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0435\u0442\u0430\u043b\u0435\u0439, \u043f\u0440\u043e\u0441\u0442\u043e &quot;\u043f\u043e\u0449\u0443\u043f\u0430\u0435\u043c&quot;. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-284013","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/284013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=284013"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/284013\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=284013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=284013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=284013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}