{"id":394772,"date":"2024-06-29T11:49:14","date_gmt":"2024-06-29T11:49:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=394772"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=394772","title":{"rendered":"<span>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Golang \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Node.js \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (Node.js: In Go We Trust)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<blockquote>\n<p><strong>Harmonica : <\/strong><em>[\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043c\u0443\u0436\u0447\u0438\u043d] <\/em>\u0422\u044b \u0424\u0440\u044d\u043d\u043a?<br \/><strong>Snaky : <\/strong>\u0424\u0440\u044d\u043d\u043a \u043f\u043e\u0441\u043b\u0430\u043b \u043d\u0430\u0441.<br \/><strong>Harmonica : <\/strong>\u0412\u044b \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043a\u043e\u043d\u044f?<br \/><strong>Snaky : <\/strong>\u041a\u0430\u0436\u0435\u0442\u0441\u044f\u2026<em> <\/em>\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u044f.<br \/><strong>Harmonica : <\/strong>\u0412\u044b \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043d\u0430 \u0434\u0432\u0443\u0445 \u043a\u043e\u043d\u0435\u0439 \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n<p>(Once Upon a Time in the West, 1968)<\/p>\n<\/blockquote>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0435\u0439 \u041d\u043e\u0432\u043e\u0445\u0430\u0446\u043a\u0438\u0439, \u044f \u2013 Software Engineer. \u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043d\u0430\u0434 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043e\u043f\u043b\u043e\u0449\u0430\u044e \u0432 \u0436\u0438\u0437\u043d\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b.<\/p>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, Node.js \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 I\/O intensive \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438. \u0410 \u0432\u043e\u0442 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f CPU bound \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u2013 child processes\/cluster, worker threads. \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (C, C++, Rust, Golang) \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430\/\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 WebAssembly \u0441\u043a\u0440\u0438\u043f\u0442\u044b.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u0437\u043e\u0440\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e Golang \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 Node.js \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 CPU intensive \u0437\u0430\u0434\u0430\u0447 (\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0443\u043c\u043c\u044b \u0447\u0438\u0441\u0435\u043b, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u0430\u043a md5 \u0438 sha256).<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4bc\/d6d\/a24\/4bcd6da24a4b88a88e79a61aef09e55f.png\" width=\"1023\" height=\"731\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4bc\/d6d\/a24\/4bcd6da24a4b88a88e79a61aef09e55f.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u041a\u0430\u043a\u0438\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b?<\/h2>\n<p>1. \u041f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c CPU bound \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/nodejs.org\/\" rel=\"noopener noreferrer nofollow\"><strong><u>Node.js<\/u><\/strong><\/a><\/p>\n<p>2. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 <a href=\"https:\/\/go.dev\/\" rel=\"noopener noreferrer nofollow\"><strong><u>Golang<\/u><\/strong><\/a> \u0438 &#171;\u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f&#187; \u0441 \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\/\u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u0442.\u0434. (\u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043e\u0431\u044b\u0447\u043d\u044b\u0435 http \u0437\u0430\u043f\u0440\u043e\u0441\u044b)<\/p>\n<p>3. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Golang \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <a href=\"https:\/\/webassembly.org\/\" rel=\"noopener noreferrer nofollow\"><strong><u>wasm<\/u><\/strong><\/a> \u0444\u0430\u0439\u043b\u0430, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 Node.js<\/p>\n<h2>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0434\u0435\u043d\u044c\u0433\u0438<\/h2>\n<p>\u042f \u0444\u0430\u043d \u0441\u0442\u0430\u0440\u044b\u0445 \u0434\u043e\u0431\u0440\u044b\u0445 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Spaghetti_Western\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u043f\u0430\u0433\u0435\u0442\u0442\u0438 \u0432\u0435\u0441\u0442\u0435\u0440\u043d\u043e\u0432<\/u><\/a>, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Good,_the_Bad_and_the_Ugly\" rel=\"noopener noreferrer nofollow\"><u>\u0425\u043e\u0440\u043e\u0448\u0438\u0439, \u043f\u043b\u043e\u0445\u043e\u0439, \u0437\u043b\u043e\u0439.<\/u><\/a> \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 3 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447, \u0430 \u0432 \u044d\u0442\u043e\u043c \u0444\u0438\u043b\u044c\u043c\u0435 3 \u0441\u043e\u0432\u0441\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0435\u0440\u043e\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u044e\u0442 \u044d\u0442\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b.<\/p>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e\u2026 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u043c\u0441\u044f \u0432 \u0430\u0442\u043c\u043e\u0441\u0444\u0435\u0440\u0443 \u0442\u0435\u0445 \u0432\u0440\u0435\u043c\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0434\u0435\u043d\u044c\u0433\u0438 \u0440\u0435\u0448\u0430\u043b\u0438 \u0432\u0441\u0435\u2026 <strong>\u0414\u0438\u043a\u0438\u0439 \u0417\u0430\u043f\u0430\u0434<\/strong><\/p>\n<h3>Node.js (The Good)<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/567\/02f\/fb8\/56702ffb88b01a03c8c35ace3971173a.gif\" width=\"702\" height=\"382\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/567\/02f\/fb8\/56702ffb88b01a03c8c35ace3971173a.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:<\/p>\n<p>1. \u041e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u044f\u0437\u044b\u043a (JavaScript) \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0435 \u0438 \u0431\u044d\u043a\u0435\u043d\u0434\u0435<\/p>\n<p>2. \u041c\u0430\u0441\u0442\u0435\u0440 I\/O \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 &#8212; \u0438\u043c\u0435\u0435\u0442 \u0441\u0443\u043f\u0435\u0440\u0431\u044b\u0441\u0442\u0440\u044b\u0439 event loop<\/p>\n<p>3. \u0421\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0430\u0440\u0441\u0435\u043d\u0430\u043b \u043e\u0440\u0443\u0436\u0438\u044f &#8212; <a href=\"https:\/\/www.npmjs.com\/\" rel=\"noopener noreferrer nofollow\"><u>npm<\/u><\/a><\/p>\n<h3>Golang (The Bad)<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2a0\/0a6\/f1e\/2a00a6f1ef5e5e2e081b0b2ec1c4972c.gif\" width=\"702\" height=\"382\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2a0\/0a6\/f1e\/2a00a6f1ef5e5e2e081b0b2ec1c4972c.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:<\/p>\n<p>1. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0432 Google<\/p>\n<p>2. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 OS<\/p>\n<p>3. \u0413\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u2013 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Golang, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 (\u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441 CPU bound \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438)<\/p>\n<p>4. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438 \u2013 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 25 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432<\/p>\n<h3>nodejs-golang\/WebAssembly (The Ugly)<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ee\/73c\/e1d\/2ee73ce1dbbc5c134a166f2b591abeb6.gif\" width=\"702\" height=\"382\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ee\/73c\/e1d\/2ee73ce1dbbc5c134a166f2b591abeb6.gif\"\/><figcaption><\/figcaption><\/figure>\n<h4>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:<\/h4>\n<p>1. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432\u0435\u0437\u0434\u0435<\/p>\n<p>2. \u0414\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442 JavaScript<\/p>\n<p>3. \u0414\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c .wasm \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 JavaScript<\/p>\n<p><strong>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435.<\/strong><\/p>\n<p>\u041a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Golang \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 .wasm \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <strong>Operating System<\/strong> \u043a\u0430\u043a \u201cjs\u201d \u0438 <strong>Architecture<\/strong> \u043a\u0430\u043a \u201cwasm\u201d (\u0441\u043f\u0438\u0441\u043e\u043a \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 GOOS \u0438 GOARCH \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/go.dev\/doc\/install\/source#environment\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>):<\/p>\n<pre><code class=\"bash\">GOOS=js GOARCH=wasm go build -o main.wasm<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 Go \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>wasm_exec.js<\/strong>. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u043e <a href=\"https:\/\/github.com\/golang\/go\/blob\/master\/misc\/wasm\/wasm_exec.js\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u0441\u044b\u043b\u043a\u0435<\/u><\/a>:<\/p>\n<pre><code class=\"bash\">${GOROOT}\/misc\/wasm\/wasm_exec.js<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f WebAssembly \u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b <a href=\"https:\/\/www.npmjs.com\/package\/@assemblyscript\/loader\" rel=\"noopener noreferrer nofollow\"><u>@assemblyscript\/loader<\/u><\/a> \u0438 \u0441\u043e\u0437\u0434\u0430\u043b \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/www.npmjs.com\/package\/nodejs-golang\" rel=\"noopener noreferrer nofollow\"><u>nodejs-golang<\/u><\/a> (\u043a\u0441\u0442\u0430\u0442\u0438, @assemblyscript\/loader &#8212; \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f). \u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0431\u0438\u043b\u0434\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 wasm \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 JavaScript \u043a\u043e\u0434\u0435<\/p>\n<pre><code class=\"javascript\">require('.\/go\/misc\/wasm\/wasm_exec'); const go = new Go(); ... const wasm = fs.readFileSync(wasmPath); const wasmModule = await loader.instantiateStreaming(wasm, go.importObject); go.run(wasmModule.instance);<\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f .wasm \u0444\u0430\u0439\u043b\u0430.<\/p>\n<pre><code class=\"bash\">C: emcc hello.c -s WASM=1 -o hello.html  C++: em++ hello.cpp -s WASM=1 -o hello.html  Rust: cargo build --target wasm --release<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ac\/9ad\/090\/2ac9ad090c2cbe76c7adfc63e2318e01.gif\" width=\"702\" height=\"382\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ac\/9ad\/090\/2ac9ad090c2cbe76c7adfc63e2318e01.gif\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043a\u0442\u043e \u0443 \u043d\u0430\u0441 \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043d\u0430 \u0414\u0438\u043a\u043e\u043c \u0417\u0430\u043f\u0430\u0434\u0435<\/h3>\n<blockquote>\n<p>&#171;\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448<\/p>\n<p>\u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438\u043b\u0438 \u0430\u0440\u0431\u0443\u0437, \u043f\u043e\u043a\u0430 \u043f\u043e \u043d\u0435\u043c\u0443 \u043d\u0435 \u043f\u043e\u0441\u0442\u0443\u0447\u0438\u0442\u0435.&#187;<\/p>\n<p>&#8212; Roy Bean<\/p>\n<\/blockquote>\n<p><strong>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c 2 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/strong><\/p>\n<p><strong>1. Golang \u0441\u0435\u0440\u0432\u0435\u0440<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/241\/ab9\/502\/241ab9502c016c8248383205eee98802.gif\" width=\"702\" height=\"382\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/241\/ab9\/502\/241ab9502c016c8248383205eee98802.gif\"\/><figcaption><\/figcaption><\/figure>\n<pre><code class=\"go\">package main import ( \u00a0\u00a0\u00a0\u00a0... \u00a0\u00a0\u00a0\u00a0\"fmt\" \u00a0\u00a0\u00a0\u00a0... \u00a0\u00a0\u00a0\u00a0\"net\/http\" \u00a0\u00a0\u00a0\u00a0... )  func main() { \u00a0\u00a0\u00a0\u00a0... \u00a0\u00a0\u00a0\u00a0fmt.Print(\"Golang: Server is running at http:\/\/localhost:8090\/\") \u00a0\u00a0\u00a0\u00a0http.ListenAndServe(\":8090\", nil) }<\/code><\/pre>\n<p><strong>2. Node.js \u0441\u0435\u0440\u0432\u0435\u0440<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/35b\/3ba\/77f\/35b3ba77f86faa3e8dca5e0fe327b797.gif\" width=\"702\" height=\"382\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/35b\/3ba\/77f\/35b3ba77f86faa3e8dca5e0fe327b797.gif\"\/><figcaption><\/figcaption><\/figure>\n<pre><code class=\"javascript\">const http = require('http'); ... (async () => {   ...   http.createServer((req, res) => {     ...   })   .listen(8080, () => {     console.log('Nodejs: Server is running at http:\/\/localhost:8080\/');   }); })(); <\/code><\/pre>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u2013 \u0434\u043b\u044f Golang \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 + \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0434\u043b\u044f Node.js \u0438 WebAssembly &#8212; \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<h2>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u0443\u044d\u043b\u044c<\/h2>\n<h3>1. \u201cping\u201d (\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443\u0439\u0434\u0435\u0442 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430)<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const nodejsPingHandler = (req, res) => {   console.time('Nodejs: ping');    const result = 'Pong';    console.timeEnd('Nodejs: ping');    res.statusCode = 200;   res.setHeader('Content-Type', 'application\/json');   res.write(JSON.stringify({ result }));   res.end(); };<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"javascript\">\/\/ golang\/ping.js  const http = require('http');  const golangPingHandler = (req, res) => {   const options = {     hostname: 'localhost',     port: 8090,     path: '\/ping',     method: 'GET',   };    let result = '';    console.time('Golang: ping');    const request = http.request(options, (response) => {     response.on('data', (data) => {       result += data;     });     response.on('end', () => {       console.timeEnd('Golang: ping');        res.statusCode = 200;       res.setHeader('Content-Type', 'application\/json');       res.write(JSON.stringify({ result }));       res.end();     });   });    request.on('error', (error) => {     console.error(error);   });    request.end(); };<\/code><\/pre>\n<pre><code class=\"go\">\/\/ main.go  func ping(w http.ResponseWriter, req *http.Request) {     fmt.Fprintf(w, \"Pong\") }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"javascript\">\/\/ nodejs-golang\/ping.js  const nodejsGolangPingHandler = async (req, res) => {   console.time('Nodejs-Golang: ping');    const result = global.GolangPing();    console.timeEnd('Nodejs-Golang: ping');    res.statusCode = 200;   res.setHeader('Content-Type', 'application\/json');   res.write(JSON.stringify({ result }));   res.end(); };<\/code><\/pre>\n<pre><code class=\"go\">\/\/ main.go  package main  import (     \"syscall\/js\" )  func GolangPing(this js.Value, p []js.Value) interface{} {     return js.ValueOf(\"Pong\") }  func main() {     c := make(chan struct{}, 0)      js.Global().Set(\"GolangPing\", js.FuncOf(GolangPing))      &lt;-c }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d60\/b03\/919\/d60b03919abfd71e405687a67f970dd5.png\" width=\"800\" height=\"416\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d60\/b03\/919\/d60b03919abfd71e405687a67f970dd5.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>2. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0443\u043c\u043c\u0430 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const result = p1 + p2;<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"go\">func sum(w http.ResponseWriter, req *http.Request) {     p1, _ := strconv.Atoi(req.URL.Query().Get(\"p1\"))     p2, _ := strconv.Atoi(req.URL.Query().Get(\"p2\"))      sum := p1 + p2      fmt.Fprint(w, sum) }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"go\">func GolangSum(this js.Value, p []js.Value) interface{} {     sum := p[0].Int() + p[1].Int()     return js.ValueOf(sum) }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ded\/5d3\/4d2\/ded5d34d2ec3deaeceaac6824a8e6e71.png\" width=\"800\" height=\"414\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ded\/5d3\/4d2\/ded5d34d2ec3deaeceaac6824a8e6e71.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>3. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 (\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 100000-\u0435 \u0447\u0438\u0441\u043b\u043e)<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const fibonacci = (num) => {   let a = BigInt(1),     b = BigInt(0),     temp;    while (num > 0) {     temp = a;     a = a + b;     b = temp;     num--;   }    return b; };<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"go\">func fibonacci(w http.ResponseWriter, req *http.Request) {     nValue, _ := strconv.Atoi(req.URL.Query().Get(\"n\"))      var n = uint(nValue)      if n &lt;= 1 {         fmt.Fprint(w, big.NewInt(int64(n)))     }      var n2, n1 = big.NewInt(0), big.NewInt(1)      for i := uint(1); i &lt; n; i++ {         n2.Add(n2, n1)         n1, n2 = n2, n1     }      fmt.Fprint(w, n1) }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"go\">func GolangFibonacci(this js.Value, p []js.Value) interface{} {     var n = uint(p[0].Int())      if n &lt;= 1 {         return big.NewInt(int64(n))     }      var n2, n1 = big.NewInt(0), big.NewInt(1)      for i := uint(1); i &lt; n; i++ {         n2.Add(n2, n1)         n1, n2 = n2, n1     }      return js.ValueOf(n1.String()) }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/627\/52d\/e30\/62752de302a9e6cfaa903e5da9f5a6ad.png\" width=\"800\" height=\"412\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/627\/52d\/e30\/62752de302a9e6cfaa903e5da9f5a6ad.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0442\u0430\u0440\u044b\u043c \u0434\u043e\u0431\u0440\u044b\u043c \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u2013 md5 (10k \u0441\u0442\u0440\u043e\u043a)<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const crypto = require('crypto');  const md5 = (num) => {   for (let i = 0; i &lt; num; i++) {     crypto.createHash('md5').update('nodejs-golang').digest('hex');   }   return num; };<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"go\">func md5Worker(c chan string, wg *sync.WaitGroup) {     hash := md5.Sum([]byte(\"nodejs-golang\"))      c &lt;- hex.EncodeToString(hash[:])      wg.Done() }  func md5Array(w http.ResponseWriter, req *http.Request) {     n, _ := strconv.Atoi(req.URL.Query().Get(\"n\"))      c := make(chan string, n)     var wg sync.WaitGroup      for i := 0; i &lt; n; i++ {         wg.Add(1)         go md5Worker(c, &amp;wg)     }      wg.Wait()      fmt.Fprint(w, n) }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"go\">func md5Worker(c chan string, wg *sync.WaitGroup) {     hash := md5.Sum([]byte(\"nodejs-golang\"))      c &lt;- hex.EncodeToString(hash[:])      wg.Done() }  func GolangMd5(this js.Value, p []js.Value) interface{} {     n := p[0].Int()      c := make(chan string, n)     var wg sync.WaitGroup      for i := 0; i &lt; n; i++ {         wg.Add(1)         go md5Worker(c, &amp;wg)     }      wg.Wait()      return js.ValueOf(n) }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d3c\/41c\/f76\/d3c41cf76e140064fef63301bbcd458d.png\" width=\"800\" height=\"424\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d3c\/41c\/f76\/d3c41cf76e140064fef63301bbcd458d.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>5. \u2026 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 sha256 (10k \u0441\u0442\u0440\u043e\u043a)<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const crypto = require('crypto');  const sha256 = (num) => {   for (let i = 0; i &lt; num; i++) {     crypto.createHash('sha256').update('nodejs-golang').digest('hex');   }   return num; };<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"go\">func sha256Worker(c chan string, wg *sync.WaitGroup) {     h := sha256.New()     h.Write([]byte(\"nodejs-golang\"))     sha256_hash := hex.EncodeToString(h.Sum(nil))      c &lt;- sha256_hash      wg.Done() }  func sha256Array(w http.ResponseWriter, req *http.Request) {     n, _ := strconv.Atoi(req.URL.Query().Get(\"n\"))      c := make(chan string, n)     var wg sync.WaitGroup      for i := 0; i &lt; n; i++ {         wg.Add(1)         go sha256Worker(c, &amp;wg)     }      wg.Wait()      fmt.Fprint(w, n) }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"go\">func sha256Worker(c chan string, wg *sync.WaitGroup) {     h := sha256.New()     h.Write([]byte(\"nodejs-golang\"))     sha256_hash := hex.EncodeToString(h.Sum(nil))      c &lt;- sha256_hash      wg.Done() }  func GolangSha256(this js.Value, p []js.Value) interface{} {     n := p[0].Int()      c := make(chan string, n)     var wg sync.WaitGroup      for i := 0; i &lt; n; i++ {         wg.Add(1)         go sha256Worker(c, &amp;wg)     }      wg.Wait()      return js.ValueOf(n) }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e5d\/ad8\/72d\/e5dad872d243262338bb2287d262eb7b.png\" width=\"800\" height=\"414\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e5d\/ad8\/72d\/e5dad872d243262338bb2287d262eb7b.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a5f\/340\/9f7\/a5f3409f7ac4db4ddc0c1af43fb542d0.png\" width=\"800\" height=\"313\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a5f\/340\/9f7\/a5f3409f7ac4db4ddc0c1af43fb542d0.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0427\u0442\u043e \u043c\u044b \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0443\u0437\u043d\u0430\u043b\u0438:<\/h2>\n<p>1. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 Node.js, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443<\/p>\n<p>2. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 Golang, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443<\/p>\n<p>3. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 WebAssembly (\u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0438 \u043c\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/www.npmjs.com\/package\/nodejs-golang\" rel=\"noopener noreferrer nofollow\"><u>nodejs-golang<\/u><\/a>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443<\/p>\n<p>4. Golang \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a: \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441\u0435\u0440\u0432\u0438\u0441\/\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441, \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u043b\u044f wasm \u0441\u043a\u0440\u0438\u043f\u0442\u0430 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 JavaScript)<\/p>\n<p>5. Node.js \u0438 Golang \u0438\u043c\u0435\u044e\u0442 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f WebAssembly \u0432 JavaScript<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434\u044b:<\/h2>\n<blockquote>\n<p>\u201c\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u2013 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u2013 \u044d\u0442\u043e \u0432\u0441\u0435.\u201d &#8212; Wyatt Earp<\/p>\n<\/blockquote>\n<p>1. \u041d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c CPU-bound \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 Node.js (\u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c)<\/p>\n<p>2. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e<\/p>\n<p>3. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c CPU-bound \u0437\u0430\u0434\u0430\u0447\u0443, \u0432 Node.js \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u2013 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Node.js. (\u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a \u043f\u043b\u043e\u0445\u043e)<\/p>\n<p>4. \u041c\u0435\u0436\u0434\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e (\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432) \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e\u043c \u0447\u0442\u0435\u043d\u0438\u044f (\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434 JavaScript \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u043b\u044c\u043a\u043e JavaScript), \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/p>\n<p>5. &#171;\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440 \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u043e, \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435 \u0435\u0449\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u044b \u0438\u043b\u0438 \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u044b \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u043b\u044c\u0448\u0435. \u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u043e\u0440 \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439&#187; &#8212; Clean Architecture by Robert C. Martin<\/p>\n<p>6. \u041b\u0443\u0447\u0448\u0435 &#171;\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e&#187;. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\/\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u2013 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/p>\n<p>7. WebAssembly \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u043b\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u043e\u0432. \u0411\u0438\u043d\u0430\u0440\u043d\u0438\u043a Wasm \u043c\u0435\u043d\u044c\u0448\u0435 \u0438 \u043f\u0440\u043e\u0449\u0435 \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430, \u0447\u0435\u043c \u043a\u043e\u0434 JS \u0438 \u0442.\u0434.<\/p>\n<hr\/>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435 \u043c\u043e\u0439 <a href=\"https:\/\/github.com\/novokhatskyioleksii\" rel=\"noopener noreferrer nofollow\"><u>github<\/u><\/a>.<\/p>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; <a href=\"https:\/\/www.npmjs.com\/package\/nodejs-golang\" rel=\"noopener noreferrer nofollow\"><strong><u>nodejs-golang<\/u><\/strong><\/a><\/p>\n<p>\u0414\u043e \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439!<\/p>\n<p>*\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435:<br \/>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0431\u044b\u043b\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0435\u0439. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0432\u044b\u0437\u043e\u0432 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (md5\/sha256) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e async\/await (Node.js). \u041f\u0440\u043e\u0448\u0443 \u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0437\u0430 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u0430\u043c\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b &#8212; \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0446\u0435\u043b\u043e\u043c \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u00b15-10% \u0434\u043b\u044f \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u041f\u043e\u043b\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0446\u0435\u043d\u043a\u0430 \u043d\u0435 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u043b\u043e \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0446\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Golang \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f wasm \u0444\u0430\u0439\u043b\u0430.<br \/>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0441\u0435\u043c \u0437\u0430 \u043f\u043b\u043e\u0434\u043e\u0442\u0432\u043e\u0440\u043d\u043e\u0435 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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:\/\/habr.com\/ru\/articles\/593537\/\"> https:\/\/habr.com\/ru\/articles\/593537\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<blockquote>\n<p><strong>Harmonica : <\/strong><em>[\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 \u0442\u0440\u0435\u0445 \u043c\u0443\u0436\u0447\u0438\u043d] <\/em>\u0422\u044b \u0424\u0440\u044d\u043d\u043a?<br \/><strong>Snaky : <\/strong>\u0424\u0440\u044d\u043d\u043a \u043f\u043e\u0441\u043b\u0430\u043b \u043d\u0430\u0441.<br \/><strong>Harmonica : <\/strong>\u0412\u044b \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043a\u043e\u043d\u044f?<br \/><strong>Snaky : <\/strong>\u041a\u0430\u0436\u0435\u0442\u0441\u044f\u2026<em> <\/em>\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u044f.<br \/><strong>Harmonica : <\/strong>\u0412\u044b \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u043d\u0430 \u0434\u0432\u0443\u0445 \u043a\u043e\u043d\u0435\u0439 \u0431\u043e\u043b\u044c\u0448\u0435.<\/p>\n<p>(Once Upon a Time in the West, 1968)<\/p>\n<\/blockquote>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0435\u0439 \u041d\u043e\u0432\u043e\u0445\u0430\u0446\u043a\u0438\u0439, \u044f \u2013 Software Engineer. \u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043d\u0430\u0434 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043e\u043f\u043b\u043e\u0449\u0430\u044e \u0432 \u0436\u0438\u0437\u043d\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b.<\/p>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, Node.js \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 I\/O intensive \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438. \u0410 \u0432\u043e\u0442 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f CPU bound \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u2013 child processes\/cluster, worker threads. \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (C, C++, Rust, Golang) \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430\/\u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 WebAssembly \u0441\u043a\u0440\u0438\u043f\u0442\u044b.<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u043e\u0431\u0437\u043e\u0440\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e Golang \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 Node.js \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 CPU intensive \u0437\u0430\u0434\u0430\u0447 (\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0443\u043c\u043c\u044b \u0447\u0438\u0441\u0435\u043b, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u0430\u043a md5 \u0438 sha256).<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u041a\u0430\u043a\u0438\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b?<\/h2>\n<p>1. \u041f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c CPU bound \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/nodejs.org\/\" rel=\"noopener noreferrer nofollow\"><strong><u>Node.js<\/u><\/strong><\/a><\/p>\n<p>2. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 <a href=\"https:\/\/go.dev\/\" rel=\"noopener noreferrer nofollow\"><strong><u>Golang<\/u><\/strong><\/a> \u0438 &#171;\u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f&#187; \u0441 \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\/\u0431\u0440\u043e\u043a\u0435\u0440\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 \u0442.\u0434. (\u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043e\u0431\u044b\u0447\u043d\u044b\u0435 http \u0437\u0430\u043f\u0440\u043e\u0441\u044b)<\/p>\n<p>3. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Golang \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <a href=\"https:\/\/webassembly.org\/\" rel=\"noopener noreferrer nofollow\"><strong><u>wasm<\/u><\/strong><\/a> \u0444\u0430\u0439\u043b\u0430, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 Node.js<\/p>\n<h2>\u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0434\u0435\u043d\u044c\u0433\u0438<\/h2>\n<p>\u042f \u0444\u0430\u043d \u0441\u0442\u0430\u0440\u044b\u0445 \u0434\u043e\u0431\u0440\u044b\u0445 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Spaghetti_Western\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u043f\u0430\u0433\u0435\u0442\u0442\u0438 \u0432\u0435\u0441\u0442\u0435\u0440\u043d\u043e\u0432<\/u><\/a>, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Good,_the_Bad_and_the_Ugly\" rel=\"noopener noreferrer nofollow\"><u>\u0425\u043e\u0440\u043e\u0448\u0438\u0439, \u043f\u043b\u043e\u0445\u043e\u0439, \u0437\u043b\u043e\u0439.<\/u><\/a> \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 3 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447, \u0430 \u0432 \u044d\u0442\u043e\u043c \u0444\u0438\u043b\u044c\u043c\u0435 3 \u0441\u043e\u0432\u0441\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0445 \u0433\u0435\u0440\u043e\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u044e\u0442 \u044d\u0442\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b.<\/p>\n<p>\u0422\u0430\u043a \u0447\u0442\u043e\u2026 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u043c\u0441\u044f \u0432 \u0430\u0442\u043c\u043e\u0441\u0444\u0435\u0440\u0443 \u0442\u0435\u0445 \u0432\u0440\u0435\u043c\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0438 \u0434\u0435\u043d\u044c\u0433\u0438 \u0440\u0435\u0448\u0430\u043b\u0438 \u0432\u0441\u0435\u2026 <strong>\u0414\u0438\u043a\u0438\u0439 \u0417\u0430\u043f\u0430\u0434<\/strong><\/p>\n<h3>Node.js (The Good)<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:<\/p>\n<p>1. \u041e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u044f\u0437\u044b\u043a (JavaScript) \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0435 \u0438 \u0431\u044d\u043a\u0435\u043d\u0434\u0435<\/p>\n<p>2. \u041c\u0430\u0441\u0442\u0435\u0440 I\/O \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 &#8212; \u0438\u043c\u0435\u0435\u0442 \u0441\u0443\u043f\u0435\u0440\u0431\u044b\u0441\u0442\u0440\u044b\u0439 event loop<\/p>\n<p>3. \u0421\u0430\u043c\u044b\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0430\u0440\u0441\u0435\u043d\u0430\u043b \u043e\u0440\u0443\u0436\u0438\u044f &#8212; <a href=\"https:\/\/www.npmjs.com\/\" rel=\"noopener noreferrer nofollow\"><u>npm<\/u><\/a><\/p>\n<h3>Golang (The Bad)<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:<\/p>\n<p>1. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0432 Google<\/p>\n<p>2. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0447\u0442\u0438 \u043d\u0430 \u0432\u0441\u0435\u0445 OS<\/p>\n<p>3. \u0413\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u2013 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Golang, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 (\u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441 CPU bound \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438)<\/p>\n<p>4. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438 \u2013 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 25 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432<\/p>\n<h3>nodejs-golang\/WebAssembly (The Ugly)<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h4>\u0414\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430:<\/h4>\n<p>1. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u0432\u0435\u0437\u0434\u0435<\/p>\n<p>2. \u0414\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442 JavaScript<\/p>\n<p>3. \u0414\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c .wasm \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0432 JavaScript<\/p>\n<p><strong>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435.<\/strong><\/p>\n<p>\u041a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 Golang \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 .wasm \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <strong>Operating System<\/strong> \u043a\u0430\u043a \u201cjs\u201d \u0438 <strong>Architecture<\/strong> \u043a\u0430\u043a \u201cwasm\u201d (\u0441\u043f\u0438\u0441\u043e\u043a \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 GOOS \u0438 GOARCH \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/go.dev\/doc\/install\/source#environment\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>):<\/p>\n<pre><code class=\"bash\">GOOS=js GOARCH=wasm go build -o main.wasm<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 Go \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <strong>wasm_exec.js<\/strong>. \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u043e <a href=\"https:\/\/github.com\/golang\/go\/blob\/master\/misc\/wasm\/wasm_exec.js\" rel=\"noopener noreferrer nofollow\"><u>\u0441\u0441\u044b\u043b\u043a\u0435<\/u><\/a>:<\/p>\n<pre><code class=\"bash\">${GOROOT}\/misc\/wasm\/wasm_exec.js<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f WebAssembly \u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b <a href=\"https:\/\/www.npmjs.com\/package\/@assemblyscript\/loader\" rel=\"noopener noreferrer nofollow\"><u>@assemblyscript\/loader<\/u><\/a> \u0438 \u0441\u043e\u0437\u0434\u0430\u043b \u043c\u043e\u0434\u0443\u043b\u044c <a href=\"https:\/\/www.npmjs.com\/package\/nodejs-golang\" rel=\"noopener noreferrer nofollow\"><u>nodejs-golang<\/u><\/a> (\u043a\u0441\u0442\u0430\u0442\u0438, @assemblyscript\/loader &#8212; \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f). \u042d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0431\u0438\u043b\u0434\u0438\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 wasm \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 JavaScript \u043a\u043e\u0434\u0435<\/p>\n<pre><code class=\"javascript\">require('.\/go\/misc\/wasm\/wasm_exec'); const go = new Go(); ... const wasm = fs.readFileSync(wasmPath); const wasmModule = await loader.instantiateStreaming(wasm, go.importObject); go.run(wasmModule.instance);<\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f .wasm \u0444\u0430\u0439\u043b\u0430.<\/p>\n<pre><code class=\"bash\">C: emcc hello.c -s WASM=1 -o hello.html  C++: em++ hello.cpp -s WASM=1 -o hello.html  Rust: cargo build --target wasm --release<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043a\u0442\u043e \u0443 \u043d\u0430\u0441 \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043d\u0430 \u0414\u0438\u043a\u043e\u043c \u0417\u0430\u043f\u0430\u0434\u0435<\/h3>\n<blockquote>\n<p>&#171;\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0445\u043e\u0440\u043e\u0448<\/p>\n<p>\u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438\u043b\u0438 \u0430\u0440\u0431\u0443\u0437, \u043f\u043e\u043a\u0430 \u043f\u043e \u043d\u0435\u043c\u0443 \u043d\u0435 \u043f\u043e\u0441\u0442\u0443\u0447\u0438\u0442\u0435.&#187;<\/p>\n<p>&#8212; Roy Bean<\/p>\n<\/blockquote>\n<p><strong>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c 2 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/strong><\/p>\n<p><strong>1. Golang \u0441\u0435\u0440\u0432\u0435\u0440<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<pre><code class=\"go\">package main import ( \u00a0\u00a0\u00a0\u00a0... \u00a0\u00a0\u00a0\u00a0\"fmt\" \u00a0\u00a0\u00a0\u00a0... \u00a0\u00a0\u00a0\u00a0\"net\/http\" \u00a0\u00a0\u00a0\u00a0... )  func main() { \u00a0\u00a0\u00a0\u00a0... \u00a0\u00a0\u00a0\u00a0fmt.Print(\"Golang: Server is running at http:\/\/localhost:8090\/\") \u00a0\u00a0\u00a0\u00a0http.ListenAndServe(\":8090\", nil) }<\/code><\/pre>\n<p><strong>2. Node.js \u0441\u0435\u0440\u0432\u0435\u0440<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<pre><code class=\"javascript\">const http = require('http'); ... (async () => {   ...   http.createServer((req, res) => {     ...   })   .listen(8080, () => {     console.log('Nodejs: Server is running at http:\/\/localhost:8080\/');   }); })(); <\/code><\/pre>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u2013 \u0434\u043b\u044f Golang \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 + \u0441\u0435\u0442\u0435\u0432\u0430\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0434\u043b\u044f Node.js \u0438 WebAssembly &#8212; \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<h2>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u0443\u044d\u043b\u044c<\/h2>\n<h3>1. \u201cping\u201d (\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0443\u0439\u0434\u0435\u0442 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430)<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const nodejsPingHandler = (req, res) => {   console.time('Nodejs: ping');    const result = 'Pong';    console.timeEnd('Nodejs: ping');    res.statusCode = 200;   res.setHeader('Content-Type', 'application\/json');   res.write(JSON.stringify({ result }));   res.end(); };<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"javascript\">\/\/ golang\/ping.js  const http = require('http');  const golangPingHandler = (req, res) => {   const options = {     hostname: 'localhost',     port: 8090,     path: '\/ping',     method: 'GET',   };    let result = '';    console.time('Golang: ping');    const request = http.request(options, (response) => {     response.on('data', (data) => {       result += data;     });     response.on('end', () => {       console.timeEnd('Golang: ping');        res.statusCode = 200;       res.setHeader('Content-Type', 'application\/json');       res.write(JSON.stringify({ result }));       res.end();     });   });    request.on('error', (error) => {     console.error(error);   });    request.end(); };<\/code><\/pre>\n<pre><code class=\"go\">\/\/ main.go  func ping(w http.ResponseWriter, req *http.Request) {     fmt.Fprintf(w, \"Pong\") }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"javascript\">\/\/ nodejs-golang\/ping.js  const nodejsGolangPingHandler = async (req, res) => {   console.time('Nodejs-Golang: ping');    const result = global.GolangPing();    console.timeEnd('Nodejs-Golang: ping');    res.statusCode = 200;   res.setHeader('Content-Type', 'application\/json');   res.write(JSON.stringify({ result }));   res.end(); };<\/code><\/pre>\n<pre><code class=\"go\">\/\/ main.go  package main  import (     \"syscall\/js\" )  func GolangPing(this js.Value, p []js.Value) interface{} {     return js.ValueOf(\"Pong\") }  func main() {     c := make(chan struct{}, 0)      js.Global().Set(\"GolangPing\", js.FuncOf(GolangPing))      &lt;-c }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>2. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0443\u043c\u043c\u0430 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const result = p1 + p2;<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"go\">func sum(w http.ResponseWriter, req *http.Request) {     p1, _ := strconv.Atoi(req.URL.Query().Get(\"p1\"))     p2, _ := strconv.Atoi(req.URL.Query().Get(\"p2\"))      sum := p1 + p2      fmt.Fprint(w, sum) }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"go\">func GolangSum(this js.Value, p []js.Value) interface{} {     sum := p[0].Int() + p[1].Int()     return js.ValueOf(sum) }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>3. \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0424\u0438\u0431\u043e\u043d\u0430\u0447\u0447\u0438 (\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 100000-\u0435 \u0447\u0438\u0441\u043b\u043e)<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const fibonacci = (num) => {   let a = BigInt(1),     b = BigInt(0),     temp;    while (num > 0) {     temp = a;     a = a + b;     b = temp;     num--;   }    return b; };<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"go\">func fibonacci(w http.ResponseWriter, req *http.Request) {     nValue, _ := strconv.Atoi(req.URL.Query().Get(\"n\"))      var n = uint(nValue)      if n &lt;= 1 {         fmt.Fprint(w, big.NewInt(int64(n)))     }      var n2, n1 = big.NewInt(0), big.NewInt(1)      for i := uint(1); i &lt; n; i++ {         n2.Add(n2, n1)         n1, n2 = n2, n1     }      fmt.Fprint(w, n1) }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"go\">func GolangFibonacci(this js.Value, p []js.Value) interface{} {     var n = uint(p[0].Int())      if n &lt;= 1 {         return big.NewInt(int64(n))     }      var n2, n1 = big.NewInt(0), big.NewInt(1)      for i := uint(1); i &lt; n; i++ {         n2.Add(n2, n1)         n1, n2 = n2, n1     }      return js.ValueOf(n1.String()) }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u0442\u0430\u0440\u044b\u043c \u0434\u043e\u0431\u0440\u044b\u043c \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u2013 md5 (10k \u0441\u0442\u0440\u043e\u043a)<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const crypto = require('crypto');  const md5 = (num) => {   for (let i = 0; i &lt; num; i++) {     crypto.createHash('md5').update('nodejs-golang').digest('hex');   }   return num; };<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"go\">func md5Worker(c chan string, wg *sync.WaitGroup) {     hash := md5.Sum([]byte(\"nodejs-golang\"))      c &lt;- hex.EncodeToString(hash[:])      wg.Done() }  func md5Array(w http.ResponseWriter, req *http.Request) {     n, _ := strconv.Atoi(req.URL.Query().Get(\"n\"))      c := make(chan string, n)     var wg sync.WaitGroup      for i := 0; i &lt; n; i++ {         wg.Add(1)         go md5Worker(c, &amp;wg)     }      wg.Wait()      fmt.Fprint(w, n) }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"go\">func md5Worker(c chan string, wg *sync.WaitGroup) {     hash := md5.Sum([]byte(\"nodejs-golang\"))      c &lt;- hex.EncodeToString(hash[:])      wg.Done() }  func GolangMd5(this js.Value, p []js.Value) interface{} {     n := p[0].Int()      c := make(chan string, n)     var wg sync.WaitGroup      for i := 0; i &lt; n; i++ {         wg.Add(1)         go md5Worker(c, &amp;wg)     }      wg.Wait()      return js.ValueOf(n) }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>5. \u2026 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 sha256 (10k \u0441\u0442\u0440\u043e\u043a)<\/h3>\n<p><strong>Node.js<\/strong><\/p>\n<pre><code class=\"javascript\">const crypto = require('crypto');  const sha256 = (num) => {   for (let i = 0; i &lt; num; i++) {     crypto.createHash('sha256').update('nodejs-golang').digest('hex');   }   return num; };<\/code><\/pre>\n<p><strong>Golang<\/strong><\/p>\n<pre><code class=\"go\">func sha256Worker(c chan string, wg *sync.WaitGroup) {     h := sha256.New()     h.Write([]byte(\"nodejs-golang\"))     sha256_hash := hex.EncodeToString(h.Sum(nil))      c &lt;- sha256_hash      wg.Done() }  func sha256Array(w http.ResponseWriter, req *http.Request) {     n, _ := strconv.Atoi(req.URL.Query().Get(\"n\"))      c := make(chan string, n)     var wg sync.WaitGroup      for i := 0; i &lt; n; i++ {         wg.Add(1)         go sha256Worker(c, &amp;wg)     }      wg.Wait()      fmt.Fprint(w, n) }<\/code><\/pre>\n<p><strong>nodejs-golang<\/strong><\/p>\n<pre><code class=\"go\">func sha256Worker(c chan string, wg *sync.WaitGroup) {     h := sha256.New()     h.Write([]byte(\"nodejs-golang\"))     sha256_hash := hex.EncodeToString(h.Sum(nil))      c &lt;- sha256_hash      wg.Done() }  func GolangSha256(this js.Value, p []js.Value) interface{} {     n := p[0].Int()      c := make(chan string, n)     var wg sync.WaitGroup      for i := 0; i &lt; n; i++ {         wg.Add(1)         go sha256Worker(c, &amp;wg)     }      wg.Wait()      return js.ValueOf(n) }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/strong><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0427\u0442\u043e \u043c\u044b \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0443\u0437\u043d\u0430\u043b\u0438:<\/h2>\n<p>1.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-394772","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/394772","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=394772"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/394772\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=394772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=394772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=394772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}