{"id":191609,"date":"2020-05-29T09:00:52","date_gmt":"2020-05-29T01:00:52","guid":{"rendered":"https:\/\/gulass.cn\/?p=191609"},"modified":"2020-05-18T22:20:14","modified_gmt":"2020-05-18T14:20:14","slug":"deno","status":"publish","type":"post","link":"https:\/\/gulass.cn\/deno.html","title":{"rendered":"Deno 1.0 \u53d1\u5e03\u6709\u4f55\u529f\u80fd\uff1f"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | Deno 1.0 \u53d1\u5e03\u4e86\u3002Deno \u662f\u4f5c\u8005 Ryan Dahl \u5728 Node \u4e4b\u540e\u7684\u53c8\u4e00\u5927\u4f5c\uff0c\u5b83\u662f\u4e00\u4e2a\u65b0\u7684\u8fd0\u884c\u65f6\uff0c\u7528\u4e8e\u5728 Web \u6d4f\u89c8\u5668\u4e4b\u5916\u6267\u884c JavaScript \u548c TypeScript\uff0c\u5176\u91c7\u7528 Rust \u7f16\u5199\u800c\u6210\uff08\u6700\u521d\u7528\u7684\u662f Golang\uff09\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n Deno \u8bd5\u56fe\u63d0\u4f9b\u4e00\u4e2a\u72ec\u7acb\u7684\u5de5\u5177\u6765\u5feb\u901f\u7f16\u5199\u590d\u6742\u529f\u80fd\u7684\u811a\u672c\uff0c\u5b83\u5c06\u59cb\u7ec8\u662f\u5355\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5c31\u50cf Web \u6d4f\u89c8\u5668\u4e00\u6837\uff0c\u5b83\u77e5\u9053\u5982\u4f55\u83b7\u53d6\u5916\u90e8\u4ee3\u7801\u3002\u5728 Deno \u4e2d\uff0c\u5355\u4e2a\u6587\u4ef6\u53ef\u4ee5\u5b9a\u4e49\u4efb\u610f\u590d\u6742\u7684\u884c\u4e3a\uff0c\u800c\u65e0\u9700\u4efb\u4f55\u5176\u5b83\u5de5\u5177\u3002<\/p>\n Ryan Dahl \u8ba4\u4e3a\u8fc7\u53bb\u4ed6\u5728\u8bbe\u8ba1 Node \u65f6\u72af\u4e86\u4e00\u4e9b\u9519\u8bef\uff0c\u5305\u62ec\u5b89\u5168\u6027\u3001\u6784\u5efa\u7cfb\u7edf\u3001package.json\u3001node_modules\u3001index.js \u7b49\u7b49\uff0c\u5e76\u8868\u793a Node \u5b58\u5728\u7684\u79cd\u79cd\u4e0d\u8db3\u5bfc\u81f4\u6709\u8bb8\u591a\u4e25\u91cd bug \u95ee\u9898\u4e14\u4e0d\u53ef\u56de\u907f\uff0c\u5f53\u524d JavaScript \u548c\u5468\u56f4\u7684\u8f6f\u4ef6\u57fa\u7840\u67b6\u6784\u5df2\u7ecf\u53d1\u751f\u4e86\u5de8\u5927\u7684\u53d8\u5316\uff0c\u503c\u5f97\u8fdb\u884c\u7b80\u5316\uff0c\u4e8e\u662f\u4ed6\u91cd\u65b0\u8bbe\u8ba1\u4e86 Deno \u8fd9\u95e8\u811a\u672c\u8bed\u8a00\u3002<\/p>\n Rust API<\/strong><\/span><\/div>\n \u4eca\u5929\u6b63\u5f0f\u53d1\u5e03\u7684 1.0 \u7248\u672c\u5e26\u6765\u4e86\u547d\u4ee4\u884c\u754c\u9762 CLI 1.0\u3002Deno \u672c\u8eab\u5e76\u4e0d\u662f\u4e00\u4e2a\u5355\u4f53\u7684\u7a0b\u5e8f\uff0c\u800c\u662f\u8bbe\u8ba1\u4e3a Rust crate \u7684\u96c6\u5408\uff0c\u4ee5\u5141\u8bb8\u5728\u4e0d\u540c\u7684\u5c42\u8fdb\u884c\u96c6\u6210\u3002Deno \u4e2d\u7684 Rust crate deno_core \u4e0d\u4f9d\u8d56\u4e8e TypeScript \u6216 Tokio\uff0c\u5b83\u53ea\u662f\u63d0\u4f9b\u4e86\u64cd\u4f5c\u548c\u8d44\u6e90\u57fa\u7840\u67b6\u6784\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u5c06 Rust \u7279\u6027\u7ed1\u5b9a\u5230 JavaScript promise \u7684\u6709\u7ec4\u7ec7\u65b9\u5f0f\u3002CLI \u5219\u5b8c\u5168\u5efa\u7acb\u5728 deno_core \u4e4b\u4e0a\u3002<\/p>\n rusty_v8 crate \u63d0\u4f9b\u9ad8\u8d28\u91cf\u7684 V8 C++ API \u7684 Rust \u7ed1\u5b9a\u3002\u8be5 API \u5c1d\u8bd5\u5c3d\u53ef\u80fd\u4e0e\u539f\u59cb C++ API \u5339\u914d\uff0c\u5b83\u662f\u96f6\u6210\u672c\u7684\u7ed1\u5b9a\uff0c\u56e0\u4e3a Rust \u4e2d\u66b4\u9732\u7684\u5bf9\u8c61\u4e0e\u5728 C++ \u4e2d\u64cd\u4f5c\u7684\u5bf9\u8c61\u5b8c\u5168\u76f8\u540c\u3002<\/p>\n HTTP \u670d\u52a1\u5668\u6027\u80fd<\/strong><\/span><\/div>\n Deno \u7684 HTTP \u670d\u52a1\u5668\u662f\u91c7\u7528 TypeScript \u5728\u539f\u751f TCP socket \u7684\u9876\u5c42\u5b9e\u73b0\u7684\uff0cNode \u7684 HTTP \u670d\u52a1\u5668\u4f7f\u7528 C \u8bed\u8a00\u7f16\u5199\uff0c\u5e76\u4f5c\u4e3a\u5bf9 JavaScript \u7684\u9ad8\u7ea7\u7ed1\u5b9a\u66b4\u9732\u3002\u4e00\u76f4\u4ee5\u6765 Deno \u62d2\u7edd\u5c06\u539f\u751f HTTP \u670d\u52a1\u5668\u7ed1\u5b9a\u6dfb\u52a0\u8fdb\u6765\uff0c\u56e0\u4e3a\u8fd9\u8fd8\u9700\u8981\u4f18\u5316 TCP socket \u5c42\uff0c\u66f4\u5e38\u89c1\u7684\u662f\u4f18\u5316 op \u63a5\u53e3\u3002<\/p>\n Deno \u662f\u4e00\u4e2a\u5408\u9002\u7684\u5f02\u6b65\u670d\u52a1\u5668\uff0c\u6bcf\u79d2 25k \u8bf7\u6c42\u8db3\u4ee5\u6ee1\u8db3\u5927\u591a\u6570\u76ee\u7684\uff0c\u6b64\u5916\uff0c\u7531\u4e8e\u666e\u904d\u4f7f\u7528 Promise\uff0cDeno \u9700\u8981\u6709\u66f4\u597d\u7684\u5c3e\u90e8\u5ef6\u8fdf\u3002\u76ee\u524d Deno HTTP \u670d\u52a1\u5668\u6bcf\u79d2\u5904\u7406\u7ea6 25 000 \u4e2a\u8bf7\u6c42\uff0c\u6700\u5927\u5ef6\u8fdf\u4e3a 1.3 \u6beb\u79d2\uff0c\u4e0e\u4e4b\u76f8\u6bd4\uff0cNode \u7a0b\u5e8f\u6bcf\u79d2\u5904\u7406 34 000 \u4e2a\u8bf7\u6c42\uff0c\u6700\u5927\u5ef6\u8fdf\u4ecb\u4e8e 2 \u5230 300 \u6beb\u79d2\u4e4b\u95f4\u3002<\/p>\n \u8fd9\u6837\u770b\u6765\uff0c\u4f5c\u8005\u8ba4\u4e3a Deno \u7684 HTTP \u670d\u52a1\u5668\u8fd8\u6709\u66f4\u591a\u7684\u6027\u80fd\u4f18\u52bf\uff0c\u5e76\u8868\u793a\u5e0c\u671b\u5728\u5c06\u6765\u7684\u7248\u672c\u4e2d\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u3002<\/p>\n \u5177\u4f53\u5173\u4e8e HTTP \u670d\u52a1\u5668\u6027\u80fd\uff0c\u53ef\u4ee5\u67e5\u770b\uff1a<\/p>\n |