出典(authority):フリー百科事典『ウィキペディア(Wikipedia)』「2013/01/06 20:12:22」(JST)
Rust | |
---|---|
拡張子 | .rs .rc |
パラダイム | 並列計算、関数型、オブジェクト指向、命令型プログラミング、構造化、静的型付け |
登場時期 | 2010 |
設計者 | グレイドン・ホアレ |
開発者 | モジラ |
評価版リリース | 0.3[1] / 2012-07-12 |
型付け | 静的型付け、強い型付け、型推論、構造化データ |
主な処理系 | rustc |
影響を受けた言語 | Alef、C++、Camlp4、Common Lisp、Erlang、Haskell、Hermes、Limbo、Napier、Napier88、Newsqueak、NIL、Sather、Standard ML |
プラットフォーム | FreeBSD、Linux、Mac OS X、Windows |
ライセンス | MIT |
ウェブサイト | rust-lang.org |
テンプレートを表示 |
Rust は実験的な並列かつマルチパラダイムのプログラミング言語である。モジラによって開発中である[2]。純関数型プログラミング、並列アクターモデル、手続き型プログラミング、オブジェクト指向プログラミングをサポートする実用的な言語である。
主任開発者はグレイドン・ホアレ[3]である。彼は2006年にこの言語の開発に着手し、モジラが関わりはじめたのは2009年で[4]、2010年のモジラ・サミットで公に姿を表した[5]。初期のコンパイラーは OCaml 言語で作られていたが、2010年にはコンパイラーをRust言語自身で作る作業が開始された[6]。翌年には最初の完動品が作成された[7]。このコンパイラーはLLVMで構築された。
Rust コンパイラーの第 0.1 版は2012年1月に完成している[8]。モジラはこれを新しいモノ好みの人やプログラミング言語愛好家のためのアルファ版と位置づけている。
2012年7月18日時点での最新版は2012年7月12日に公開された第 0.3 版である[1]。
モジラの理念を守り[9]、Rust 言語は社会に開かれており、開発者たちは利用者からの感想や提言を求めている。
Rust言語のウェブサイトには「このアルファ版のソフトウェアにはたくさんのバグや不完全なところがあるのは分かっており、それらは将来変更されます。しばらくの間は不安定な仕様や廃止される仕様があり、後の版でのソースコードの互換性も保証されていません。ご自身の責任でお使いください。」[10]と述べられている。実験的な取り組みであるという性質上、言語にもコンパイラーにもベータ版が公開される予定日は決められていない。
目次
|
Rust言語はインターネット上で動作する大きなクライアントとサーバープログラムを作成するのに都合が良い言語を目指したものである。結果として、安全性、メモリ管理、並列性が、この言語の目立った特徴となっている。性能はC++言語に匹敵するものになるはずである[11]。
Rust言語の文法はC言語やC++言語に類似しており、ブロックは中括弧で区切られ、制御文にはif
、else
、do
、while
、for
の予約語が使われる。C言語やC++言語にある予約語のすべてが存在するわけではない一方、多方向分岐に使われるalt
文など、C、C++言語のプログラマーには馴染みがない予約語が含まれる。Rust言語はC言語やC++言語と文法的には類似点があるにもかかわらず、意味論(セマンティクス)の点でははとても異なっている。
このシステムの設計はメモリー・セーフであり、ヌルポインターや不正なメモリ域を指すポインターは許容されていない。データの値は決まったフォームのみで初期化され、それらの全ての入力は既に初期化さている必要がある[12]。
この言語の型システムでは Haskell 言語に倣い「型クラス」を用いることができる。これはアドホックな多相性を容易にするものであり、可変型宣言により実現されるものである。高類多相性[13]など、Haskell 言語にある他の特徴はサポートされていない。
Rust言語では予約語「let
」で宣言された変数に対して型推論が行われる。これらの変数は型を決定するための値を必要としない。コード中のどこかでそれらの変数への値の代入[14]が失敗した場合にはコンパイル時エラーが発生する[15]。型が明示された関数の引数に対しては型推論は行われない。
fn fib(n: int) -> int { }
なお、これを
fn fib(n) -> { }
のように、型を省いて記述することはできない。
並列性の機構は軽量タスクとして提供される。これと類似の仕組みは Erlang言語などのアクターモデルの言語にも見られるものである。それらのシステムにおいて、複数のタスク同士は直接にデータを共有するのではなく、メッセージ・パッシングによってデータのやり取りを行う。性能上の理由から、データのやり取りには固有の箱[16]を使って行われ、データの複製はされない。それらの箱は所有者が一人であることが保証されたもので、送信タスクから受信タスクに向けて開放することができる。
Rust言語が備えるオブジェクトシステムはクラス、インターフェース、トレイトにより構成される。継承と多相性はそれぞれトレイトとインターフェースによって提供され、クラスは他のクラスから継承することはできない。トレイトの仕組みは複数のクラスに混入させることのできる再利用可能なメソッド実装を提供する。それらのメソッドは実行に必要なフィールド群を規定するものの、それ自身はそれらのフィールドを定義することは出来ない。この特徴によって C++ 言語でおきる菱形継承問題を回避されている。(クラスとトレイトの仕組みは実験的なものであり、現時点の予定として、インターフェースは Rust 第 0.4 版でトレイトと統合されて削除されることになっている。)
以下のコードは Rust 第 0.4 版において正しいプログラムである。文法や意味論は後の版で改変される可能性がある。
fn main() { io::println("hello, world"); }
階乗を求めるプログラム。再帰呼び出しによるものと、繰り返し処理によるもの。
/*return
文なしに暗黙に値を返す Rust言語の機能を示す例である。 関数型様式のプログラムを作成する際に、この特徴は便利である。 C言語やC++言語とは異なり、Rust言語のif
は文ではなく式である。 そのため、返し値を伴わなければならない。 */ fn fac_recur(n: int) -> int { if n <= 1 { 1 } else { n * fac_recur(n-1) } }
fn fac_iter(n: int) -> int { // 変数は予約語「mut
[17]」で宣言することで可変になる。 let mut i = 1, result = 1; while i <= n { result *= i; i += 1; } return result; // 明示的なreturn
文。関数型の例と対照的。 }
この言語の開発の初期の頃、変数名や関数名など識別子としてASCII文字以外の文字を使うことは禁じられていた。言語についてのある質疑応答の中で、現場の非英語圏のプログラマーのほとんどが識別子にはASCII文字を使っていると述べられていた。しかしその制限は反論を引き出すことになった[18]。それで、2011年2月に言語に変更が行われ、この制限は削除された[19]。
auto_ptr
or the C++0x unique_ptr
), and reference counting via shared_ptr
or COM. One of the goals of Rust’s type system is to support these patterns exactly as C++ does, but to enforce their safe usage. In this way, the goal is to be competitive with the vast majority of idiomatic C++ in performance, while remaining memory-safe…”
This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (June 2012) |
Iron-carbon alloy phases |
---|
|
Microstructures |
|
Steel classes |
|
Other iron-based materials |
|
|
Rust is composed of iron oxides. In colloquial usage, the term is applied to red oxides, formed by the reaction of iron and oxygen in the presence of water or air moisture. Other forms of rust exist, like the result of reactions between iron and chloride in an environment deprived of oxygen – rebar used in underwater concrete pillars is an example – which generates green rust. Several forms of rust are distinguishable visually and by spectroscopy, and form under different circumstances.[1] Rust consists of hydrated iron(III) oxides Fe2O3·nH2O and iron(III) oxide-hydroxide FeO(OH)·Fe(OH)3.
Given sufficient time, oxygen, and water, any iron mass will eventually convert entirely to rust and disintegrate. Surface rust is flaky and friable, and provides no protection to the underlying iron, unlike the formation of patina on copper surfaces. Rusting is the common term for corrosion of iron and its alloys, such as steel. Many other metals undergo equivalent corrosion, but the resulting oxides are not commonly called rust.
Contents
|
When impure (cast) iron is in contact with water, oxygen, or other strong oxidants, or acids, it rusts. If salt is present, for example in seawater or salt spray, the iron tends to rust more quickly, as a result of electrochemical reactions. Iron metal is relatively unaffected by pure water or by dry oxygen. As with other metals, like aluminium, a tightly adhering oxide coating, a passivation layer, protects the bulk iron from further oxidation. The conversion of the passivating iron oxide layer to rust results from the combined action of two agents, usually oxygen and water.
Other degrading solutions are sulfur dioxide in water and carbon dioxide in water. Under these corrosive conditions, iron hydroxide species are formed. Unlike iron oxides, the hydroxides do not adhere to the bulk metal. As they form and flake off from the surface, fresh iron is exposed, and the corrosion process continues until either all of the iron is consumed or all of the oxygen, water, carbon dioxide, or sulfur dioxide in the system are removed or consumed.[2]
The rusting of iron is an electrochemical process that begins with the transfer of electrons from iron to oxygen.[3] The rate of corrosion is affected by water and accelerated by electrolytes, as illustrated by the effects of road salt on the corrosion of automobiles. The key reaction is the reduction of oxygen:
Because it forms hydroxide ions, this process is strongly affected by the presence of acid. Indeed, the corrosion of most metals by oxygen is accelerated at low pH. Providing the electrons for the above reaction is the oxidation of iron that may be described as follows:
The following redox reaction also occurs in the presence of water and is crucial to the formation of rust:
In addition, the following multistep acid-base reactions affect the course of rust formation:
as do the following dehydration equilibria:
From the above equations, it is also seen that the corrosion products are dictated by the availability of water and oxygen. With limited dissolved oxygen, iron(II)-containing materials are favoured, including FeO and black lodestone (Fe3O4). High oxygen concentrations favour ferric materials with the nominal formulae Fe(OH)3-xOx/2. The nature of rust changes with time, reflecting the slow rates of the reactions of solids.
Furthermore, these complex processes are affected by the presence of other ions, such as Ca2+, both of which serve as an electrolyte, and thus accelerate rust formation, or combine with the hydroxides and oxides of iron to precipitate a variety of Ca-Fe-O-OH species.
Onset of rusting can also be detected in laboratory with the use of Ferroxyl indicator solution. The solution detects both Fe2+ ions and hydroxyl ions. Formation of Fe2+ ions and hydroxyl ions are indicated by blue and pink patches respectively.
Because of the widespread use and importance of iron and steel products, the prevention or slowing of rust is the basis of major economic activities in a number of specialized technologies. A brief overview of methods is presented here; for detailed coverage, see the cross-referenced articles.
Rust is permeable to air and water, therefore the interior metallic iron beneath a rust layer continues to corrode. Rust prevention thus requires coatings that preclude rust formation.
Stainless steel forms a passivation layer of chromium(III) oxide. Similar passivation behavior occurs with magnesium, titanium, zinc, zinc oxides, aluminium, polyaniline, and other electroactive conductive polymers.[citation needed]
Special "weathering steel" alloys such as Cor-Ten rust at a much slower rate than normal, because the rust adheres to the surface of the metal in a protective layer. Designs using this material must include measures that avoid worst-case exposures, since the material still continues to rust slowly even under near-ideal conditions.[citation needed]
Galvanization consists of an application on the object to be protected of a layer of metallic zinc by either hot-dip galvanizing or electroplating. Zinc is traditionally used because it is cheap, adheres well to steel, and provides cathodic protection to the steel surface in case of damage of the zinc layer. In more corrosive environments (such as salt water), cadmium plating is preferred. Galvanization often fails at seams, holes, and joints where there are gaps in the coating. In these cases, the coating still provides some partial cathodic protection to iron, by acting as a galvanic anode and corroding itself instead of the underlying protected metal. The protective zinc layer is consumed by this action, and thus galvanization provides protection only for a limited period of time.
More modern coatings add aluminium to the coating as zinc-alume; aluminium will migrate to cover scratches and thus provide protection for a longer period. These approaches rely on the aluminium and zinc oxides re-protecting a once-scratched surface, rather than oxidizing as a sacrificial anode as in traditional galvanized coatings. In some cases, such as very aggressive environments or long design life, both zinc and a coating are applied to provide enhanced corrosion protection.
Cathodic protection is a technique used to inhibit corrosion on buried or immersed structures by supplying an electrical charge that suppresses the electro-chemical reaction. If correctly applied, corrosion can be stopped completely. In its simplest form, it is achieved by attaching a sacrificial anode, thereby making the iron or steel the cathode in the cell formed. The sacrificial anode must be made from something with a more negative electrode potential than the iron or steel, commonly zinc, aluminium, or magnesium. The sacrificial anode will eventually corrode away, ceasing its protective action unless it is replaced in a timely manner. Cathodic protection can also be provided by using a special-purpose electrical device to appropriately induce an electric charge
Rust formation can be controlled with coatings, such as paint, lacquer, or varnish that isolate the iron from the environment. Large structures with enclosed box sections, such as ships and modern automobiles, often have a wax-based product (technically a "slushing oil") injected into these sections. Such treatments usually also contain rust inhibitors. Covering steel with concrete can provide some protection to steel because of the alkaline pH environment at the steel-concrete interface. However rusting of steel in concrete can still be a problem, since expanding rust can fracture or slowly "explode" concrete from within.
As a closely related example, iron bars were used to reinforce stonework of the Parthenon in Athens, Greece, but caused extensive damage by rusting, swelling, and shattering the marble components of the building.
When only temporary protection is needed for storage or transport, a thin layer of oil, grease, or a special mixture such as Cosmoline can be applied to an iron surface. Such treatments are extensively used when "mothballing" a steel ship, automobile, or other equipment for long-term storage.
Special anti-seize lubricant mixtures are available, and are applied to metallic threads and other precision machined surfaces to protect them from rust. These compounds usually contain grease mixed with copper, zinc, or aluminum powder, and other proprietary ingredients.[citation needed]
Bluing is a technique that can provide limited resistance to rusting for small steel items, such as firearms; for it to be successful, a water-displacing oil is rubbed onto the blued steel.
Corrosion inhibitors, like gas-phase or volatile inhibitors, can be used to prevent corrosion inside sealed systems. They are not effective when air circulation disperses them, and brings in fresh oxygen and moisture.
Rust can be avoided by controlling the moisture in the atmosphere. An example of this is the use of silica gel packets to control humidity in equipment shipped by sea.
Rust is associated with degradation of iron-based tools and structures. As rust has a much higher volume than the originating mass of iron, its build-up can also cause failure by forcing apart adjacent parts — a phenomenon sometimes known as "rust smacking". It was the cause of the collapse of the Mianus river bridge in 1983, when the bearings rusted internally and pushed one corner of the road slab off its support. Rust was also an important factor in the Silver Bridge disaster of 1967 in West Virginia, when a steel suspension bridge collapsed in less than a minute, killing 46 drivers and passengers on the bridge at the time.
The Kinzua Bridge in Pennsylvania was blown down by a tornado in 2003, largely because the central base bolts holding the structure to the ground had rusted away, leaving the bridge anchored by gravity alone.
Like exposed steel, reinforced concrete is also vulnerable to rust damage. Internal pressure caused by expanding corrosion of concrete-covered steel and iron can cause the concrete to spall, creating severe structural problems. It is one of the most common failure modes of reinforced concrete bridges and buildings.
Rust is a commonly used metaphor for slow decay, since it gradually converts robust iron and steel metal into a soft crumbling powder. A wide section of the industrialized American Midwest and American Northeast, once dominated by steel foundries, the automotive industry, and other manufacturers, has experienced harsh economic cutbacks that have caused the region to be dubbed the "Rust Belt".
In music, literature, and art, rust is associated with images of faded glory, neglect, decay, and ruin.
Wikimedia Commons has media related to: Rust |
Look up rust in Wiktionary, the free dictionary. |
全文を閲覧するには購読必要です。 To read the full text you will need to subscribe.
リンク元 | 「錆」 |
拡張検索 | 「entrust」「incrustation」「crustal」 |
.