読み書きプログラミング

日常のプログラミングで気づいたことを綴っています

Meteor

先日、MeteorというJavaScriptベースのウェブプラットフォームが発表されました。(meteorは流星)
そのコンセプトを見て、ビビッと来ましたので、ドキュメンテーションのコンセプト部分の訳をしてみました。

コンセプト

今まで私たちは単ページのJavaScriptアプリケーションのかなりの部分を手で書いてきました。アプリケーション全体を一つのデータフォーマット(JSON)を使って一つの言語(JavaScript)で書くことは本当に幸せです。そんなアプリを書く時欲しかったもの、それがMeteorです。

We've written our fair share of single-page JavaScript applications by hand. Writing an entire application in one language (JavaScript) with one data format (JSON) is a real joy. Meteor is everything we wanted when writing those apps.

アプリケーションを構造化する

Meteorアプリケーションは、クライアントウェブブラウザ内で走るJavaScriptと、Meteorサーバー上のNode.jsコンテナ内で走るJavaScriptと、それらを支えるHTML断片、CSSルール、静的アセットすべてをミックスしたものです。Meteorはこれらの異なる構成要素のパッケージ化と送信を自動化します。そして、非常に高い自由度でこれらの構成要素をファイルツリーの中で構造化することができます。

A Meteor application is a mix of JavaScript that runs inside a client web browser, JavaScript that runs on the Meteor server inside a Node.js container, and all the supporting HTML fragments, CSS rules, and static assets. Meteor automates the packaging and transmission of these different components. And, it is quite flexible about how you choose to structure those components in your file tree.


サーバの唯一のアセットはJavaScriptです。Meteorは、クライアントとパブリックのサブディレクトリ以下を除いたJavaScriptファイルすべてを集めて、それらをファイバの中のNode.jsサーバーインスタンスにロードします。Meteorでは、サーバーコードはリクエスト毎に単一スレッド内で走ります。Nodeで典型的な非同期コールバックスタイルではありません。Meteorアプリケーションでは線形実行モデルが典型的なサーバーコードにより適していることを私たちは知りました。

The only server asset is JavaScript. Meteor gathers all your JavaScript files, excluding anything under the client and public subdirectories, and loads them into a Node.js server instance inside a fiber. In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.


クライアントサイド上では考えられるアセットがもっとあります。Meteorはクライアントのために、サーバーサブディレクトリとクライアント用パブリックサブディレクトリを除いたファイルツリーのJavaScriptファイルをすべてを集めます。この束を最小化して新しいクライアントそれぞれに配ります。アプリケーション全体用に1つのJavaScriptファイルを使ってもいいですし、分割ファイルの入れ子のツリーを作ってもいいですし、好きにできます。

There are more assets to consider on the client side. Meteor gathers all JavaScript files in your tree with the exception of the server and public subdirectories for the client. It minifies this bundle and serves it to each new client. You're free to use a single JavaScript file for your entire application, or create a nested tree of separate files, or anything in between.


クライアントサブディレクトリとサーバーサブディレクトリの外にあるファイルはクライアントとサーバー両方上にロードされます! そこがモデル定義や他の関数用の置き場所です。また、異なるディレクトリ内にクライアントとサーバーの関数を置く代わりに、is_clientとis_server変数を使ってJavaScriptを一方もしくは他方に分離することができます。

Files outside the client and server subdirectories are loaded on both the client and the server! That's the place for model definitions and other functions. Also, instead of putting client and server functions in different directories, you can use the is_client and is_server variables to isolate JavaScript to one or the other side.


CSSファイルもちょうど同じように扱われます: クライアントは(サーバーとパブリックのサブディレクトリを除いた)ツリー内のCSSすべてを集めた束を受け取ります。

CSS files work just the same: the client will get a bundle with all the CSS in your tree (excluding the server and public subdirectories).


開発モードではJavaScriptファイルとCSSファイルを束にせずに送ることでデバッグを容易にします。

In development mode, JavaScript and CSS files are sent individually to make debugging easier.


MeteorアプリケーションのHTMLファイルはサーバーサイドフレームワークとは相当違う方法で扱われます。Meteorは、, ,