20
10

More than 1 year has passed since last update.

ワイ「Denoってなんぞや?」

Posted at

🦕「やあ」

ワイ「前回はNode.jsについて知見を得たな」
ワイ「どんどん最強ぷよぐらまに近づいてまうで^^」
🦕「やあ」
ワイ「急になんやこの恐竜」
ワイ「某J民か?」
🦕「あんなのと一緒にしないでよ」
🦕「僕はDenoだよ」
ワイ「誰だよ(ピネ」
🦕「Node.jsの親戚みたいなものさ」
ワイ「Node.jsくんにも親戚がおったんか」
ワイ「初耳やわ(ハナホジ」

🦕「Denoについて」

logo.png
🦕「Node.jsのついでに知ってもらおうと思って」
🦕「今ここにいるんだ」
ワイ「ほーん しゃあない聞いたるわ」
🦕「......」
🦕「Deno(ディーノ) はRyan Dahlによって作られた比較的新しいJavascript/Typescriptランタイムだよ」
ワイ「誰やその人」
🦕「Node.js を作った人だよ」
ワイ「なんやおんなじ人か」
ワイ「だから親戚なんやな」
🦕「ちなみにDenoはNodeのアナグラムだよ」
ワイ「でもNode.jsがすでにあるのにわざわざ新しいのを作ったんや?」
🦕「それはRyan DahlがNode.jsの開発において10個の後悔があって」
🦕「その反省を活かして開発されたのがDenoなんだ」
ワイ「完璧主義やったんやろか」

ワイ「とりあえず使ってみるか」

ワイ「とりあえず使ってみるで」
🦕「インストールはここに書いてるよ」
ワイ「ワイはWindowsを使ってるからPowerShellからインスコすればええんやな」
ワイ「楽な時代になったもんやで^^」

PowerShell
iwr https://deno.land/install.ps1 -useb | iex

ワイ「これやな」
ワイ「インスコ完了や」
🦕「まずはサンプルを実行してみよう!」

PowerShell
deno run https://deno.land/std/examples/welcome.ts

🦕「コマンドはこれだよ」
ワイ「オンライン上のファイルをそのまま実行できるんか便利やな」
ワイ「実行してみたで」

PowerShell
Download https://deno.land/std/examples/welcome.ts
Warning Implicitly using latest version (0.126.0) for https://deno.land/std/examples/welcome.ts
Download https://deno.land/std@0.126.0/examples/welcome.ts
Check https://deno.land/std/examples/welcome.ts
Welcome to Deno!

🦕「無事成功だね」

🦕「僕の特徴について」

🦕「ここまでで早速Denoの特徴があったんだけどなにかわかる?」
ワイ「わからん(即答」
🦕「......」
🦕「正解はデフォルトでTypescriptに対応してる点だよ」
ワイ「確かに実行したファイルの拡張子は .tsになってるな」
ワイ「Node.jsでのTypescript開発やったらパッケージ必須やったもんな」
🦕「まだまだあるよ」
🦕「このコードを実行してみて」

test.ts
import { serve } from "https://deno.land/std@0.126.0/http/server.ts";

console.log("http://localhost:8000/");
serve((req) => new Response("Hello World\n"), { port: 8000 });
PowerShell
deno run .\test.ts
PowerShell 結果
Download https://deno.land/std@0.126.0/http/server.ts
Download https://deno.land/std@0.126.0/async/mod.ts
Download https://deno.land/std@0.126.0/async/deadline.ts
Download https://deno.land/std@0.126.0/async/debounce.ts
Download https://deno.land/std@0.126.0/async/deferred.ts
Download https://deno.land/std@0.126.0/async/delay.ts
Download https://deno.land/std@0.126.0/async/mux_async_iterator.ts
Download https://deno.land/std@0.126.0/async/pool.ts
Download https://deno.land/std@0.126.0/async/tee.ts
Check file:///C:/Users/kazum/Desktop/programings/typescript/dist.ts
http://localhost:8000/
⚠️  Deno requests net access to "0.0.0.0:8000". Run again with --allow-net to bypass this prompt.
   Allow? [y/n (y = yes allow, n = no deny)]  y

ワイ「なんか途中で許可を求めてきたな」
🦕「それが特徴デフォルトでファイルやネットワークにアクセス出来ないだよ」
ワイ「まあセキュリティが高なってるって訳やな」
ワイ「ていうかimportもurlからになってるんやな」
🦕「それも大きな特徴の一つnpm・requireの廃止だよ」
🦕「わざわざnpm installをする必要がないんだ」
ワイ「それは便利な気がするなぁ」
実行結果
ワイ「無事Hello Worldしてくれたな」

ワイ「まとめやで」

ワイ「また一つ賢くなってしまったわ^^」
ワイ「今後はDenoがNode.jsを追い越したりするんかいな」
🦕「どうだろうね」
ワイ「いつか開発する機会があればDenoで開発しよかな」
🦕「......(絶対やらないじゃん」

20
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
10