Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions locale/ja/about/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
layout: about.hbs
title: Node.js とは
trademark: Trademark
---
# <!-- About Node.js&reg; -->Node.js&reg; とは

<!--
As an asynchronous event driven JavaScript runtime, Node is designed to build
scalable network applications. In the following "hello world" example, many
connections can be handled concurrently. Upon each connection the callback is
fired, but if there is no work to be done Node is sleeping.
-->

Node はスケーラブルなネットワークアプリケーションを構築するために設計された非同期型のイベント駆動の JavaScript 環境です。
以下の「Hello World」の例では、たくさんの接続を同時に処理することができます。
各接続ごとにコールバックは発火され、何もすることがない場合、Node はスリープします。

```javascript
const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});

server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
```

<!--
This is in contrast to today's more common concurrency model where OS threads
are employed. Thread-based networking is relatively inefficient and very
difficult to use. Furthermore, users of Node are free from worries of
dead-locking the process, since there are no locks. Almost no function in Node
directly performs I/O, so the process never blocks. Because nothing blocks,
scalable systems are very reasonable to develop in Node.
-->

これは OS のスレッドが採用されている一般的な同時実行モデルとは対象的です。
スレッドベースのネットワーキングは比較的非効率であり、使うのはとても困難です。
さらに Node にはロックがないので Node ユーザーはプロセスのデッドロックの悩みから開放されます。
ほとんどの Node の関数は I/O を直接実行しないため、プロセスをブロックしません。
ブロックしないのでスケーラブルなシステムを開発するのに Node はとても最適です。

<!--
If some of this language is unfamiliar, there is a full article on
[Blocking vs Non-Blocking][].
-->

この言葉だけでは不慣れな部分がいくつかあるかもしれません。
[Blocking vs Non-Blocking][] にもう少し詳しい記事があります。

---

<!--
Node is similar in design to, and influenced by, systems like Ruby's
[Event Machine][] or Python's [Twisted][]. Node takes the event model a bit
further, it presents an [event loop][] as a runtime construct instead of as a library. In other systems there is always a blocking call to start the
event-loop.
Typically behavior is defined through callbacks at the beginning of a script
and at the end starts a server through a blocking call like
`EventMachine::run()`. In Node there is no such start-the-event-loop call. Node
simply enters the event loop after executing the input script. Node exits the
event loop when there are no more callbacks to perform. This behavior is like
browser JavaScript — the event loop is hidden from the user.
-->

Node は Ruby の [Event Machine][] や Python の [Twisted][] のシステムに影響を受けていて、同様の設計です。
Node はランタイムコンストラクタの替わりにライブラリとして[イベントループ][]を提供し、さらに小さなイベントモデルを持ちます。
ほかのシステムではイベントループの開始時にブロッキングコールが常にあります。
典型的な例ではスクリプトの先頭で動作をコールバックを用いて定義し、
最後に `EventMachine::run()` のようなブロッキングコールでサーバを起動します。
Node ではそのようなイベントループを開始する呼び出しはありません。
Node は単純にスクリプトを実行した直後にイベントループが開始されます。
実行するコールバックがこれ以上ない場合に Node はイベントループから抜けます。
この動作はブラウザ上の JavaScript と似ています — イベントループはユーザからは隠されます。

<!--
HTTP is a first class citizen in Node, designed with streaming and low latency
in mind. This makes Node well suited for the foundation of a web library or
framework.
-->

HTTP はストリーミングと低遅延を念頭に置いて設計された Node の第一級オブジェクトです。
これは Node で Web ライブラリやフレームワークの基礎を作るために適しています。

<!--
Just because Node is designed without threads, doesn't mean you cannot take
advantage of multiple cores in your environment. Child processes can be spawned
by using our [`child_process.fork()`][] API, and are designed to be easy to
communicate with. Built upon that same interface is the [`cluster`][] module,
which allows you to share sockets between processes to enable load balancing
over your cores.
-->

Node はスレッドがない設計をしているという理由だけで、複数コアの利点が得られないわけではありません。
通信しやすく設計された子プロセスは [`child_process.fork()`][] API を使って生成できます。
コア上でロードバランシングを有効にするためにプロセス間でソケットを共有することを可能にする [`cluster`][] モジュールが同じインターフェース上に内蔵されています。

[Blocking vs Non-Blocking]: https://github.com/nodejs/node/blob/master/doc/topics/blocking-vs-non-blocking.md
[`child_process.fork()`]: https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
[`cluster`]: https://nodejs.org/api/cluster.html
[イベントループ]: https://github.com/nodejs/node/blob/master/doc/topics/the-event-loop-timers-and-nexttick.md
[Event Machine]: http://rubyeventmachine.com/
[Twisted]: http://twistedmatrix.com/
2 changes: 1 addition & 1 deletion locale/ja/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"home": { "text": "ホーム" },
"about": {
"link": "about",
"text": "アバウト",
"text": "Node.js とは",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Catch!

"governance": {
"link": "about/governance",
"text": "委員会"
Expand Down