Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit 5a5c65c

Browse files
committed
Wrap lines
1 parent 3d4968a commit 5a5c65c

File tree

13 files changed

+449
-209
lines changed

13 files changed

+449
-209
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Flags declarations
22

3-
BASE_DOC_OPTS := --from=markdown+hard_line_breaks --smart
3+
BASE_DOC_OPTS := --from=markdown --smart
44
HTML_OPTS = $(BASE_DOC_OPTS) --to=html5 --css=../css/rust.css --section-divs --template=template/template.html
55
TEX_OPTS = $(BASE_DOC_OPTS) --to=latex --standalone --number-sections --latex-engine=lualatex --template=template/template.tex
66
EPUB_OPTS = $(BASE_DOC_OPTS) --to=epub

source/ch-01.md

Lines changed: 115 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,72 +6,151 @@ Tell me more about Rust!
66
A bit of history
77
----------------
88

9-
Initially, [Rust] started out in 2006 as a personal project from Graydon Hoare—a language designer "by trade" to quote his own words. Developed in his free time during the first three years, Rust was then presented to his employers at Mozilla, which went on and started to actively support it. Indeed, Mozilla Research caught interest in it as something which could do away in the future with various recurrent bugs found in Gecko, Firefox's rendering engine written in C++.
10-
11-
An original compiler has been written in [OCaml] until a bootstrapped compiler written in Rust itself could take over, in 2010. Right now the compilation process uses an [LLVM] backend (which you might have seen in action inside [Clang]).
9+
Initially, [Rust] started out in 2006 as a personal project from Graydon
10+
Hoare—a language designer "by trade" to quote his own words. Developed in
11+
his free time during the first three years, Rust was then presented to his
12+
employers at Mozilla, which went on and started to actively support it. Indeed,
13+
Mozilla Research caught interest in it as something which could do away in the
14+
future with various recurrent bugs found in Gecko, Firefox's rendering engine
15+
written in C++.
16+
17+
An original compiler has been written in [OCaml] until a bootstrapped compiler
18+
written in Rust itself could take over, in 2010. Right now the compilation
19+
process uses an [LLVM] backend (which you might have seen in action inside
20+
[Clang]).
1221

1322
The Goodness
1423
------------
1524

16-
So what is so good about Rust? We talked about C++ right at the beginning and you might think that since Mozilla is actively leading its development, it should actually have some significant advantages compared to it.
25+
So what is so good about Rust? We talked about C++ right at the beginning and
26+
you might think that since Mozilla is actively leading its development, it
27+
should actually have some significant advantages compared to it.
1728

1829
First, what are people looking for when they want to use C++?
1930

20-
- A [System programming language], which means it does not compromise on performance and allows for low-level access to the available resources (pointers, manual memory management, etc.)
21-
- A language with a fairly high-level of abstraction and a large feature-set ([OO programming] is one of them) that stays fast and has broad compatibility
31+
- A [System programming language], which means it does not compromise on
32+
performance and allows for low-level access to the available resources
33+
(pointers, manual memory management, etc.)
34+
- A language with a fairly high-level of abstraction and a large feature-set
35+
([OO programming] is one of them) that stays fast and has broad compatibility
2236

2337
Now, what are the main features that Rust brings on top of that?
2438

25-
- Safety (and mostly: safe pointer types thanks to a [very efficient memory model], no void* heresy[<sup>&loz;</sup>](#appendix-elaborating-on-c-and-safety), no use-after-free, mem leaks,...)
26-
- Native actor-based concurrency inspired from [Erlang]. This is a big deal for today's programming languages with the rise of multicore processors; in fact, some sort of multithreading is already there on C++11 (2011) and will probably get extended in C++14. Actually, the actor implementation of multithreading consists of explicitly sending message from a lightweight thread (`chan`) and receiving it from another (`port`); it is a great safety/efficiency compromise. Rust allows the use of either green (M:N) or native (1:1) threads.
27-
- Inspirations from [Haskell] and [OCaml], not only for the functional programming paradigm but also for the type classes (`trait`, `impl`)
28-
- Some programmers friendly features from Python&mdash;that being said, Rust does not compromise on performance: it has static typing (with type inference!)
29-
- Optional tracing-GC (WIP)&mdash;the `std::gc::Gc` type recently landed on mainline
30-
31-
As you can see, Rust does not try to be a new fancy thing; rather, it builds up on top of proven useful technology and merges features from some existings languages, noticeably: Erlang's green threads, Haskell trait system and overall functional programming elements of a few languages (it has pattern matching!), some syntax sugar from Python (the `range` iterator is one of them) and it also resurrects a few features from some American research languages developed in the 80s, amongst others.
32-
As you can see, along with some features that definitely set it in today's rollup of programming languages, Rust is also the result of a true willingness to reuse concepts from the rich history of programming languages, rather than building up the wheel over again. ;) ~ as you might have seen, that's partly where the name "Rust" comes from!
33-
34-
>I was fiddling with a number of names. Primarily it's named after the [pathogenic fungi] which are just amazing multi-lifecycle, multi-host parasites, fascinating creatures.
39+
- Safety (and mostly: safe pointer types thanks to a [very efficient memory
40+
model], no void* heresy, no use-after-free, mem leaks,...)
41+
- Native actor-based concurrency inspired from [Erlang]. This is a big deal for
42+
today's programming languages with the rise of multicore processors; in fact,
43+
some sort of multithreading is already there on C++11 (2011) and will probably
44+
get extended in C++14. Actually, the actor implementation of multithreading
45+
consists of explicitly sending message from a lightweight thread (`chan`) and
46+
receiving it from another (`port`); it is a great safety/efficiency
47+
compromise. Rust allows the use of either green (M:N) or native (1:1) threads.
48+
- Inspirations from [Haskell] and [OCaml], not only for the functional
49+
programming paradigm but also for the type classes (`trait`, `impl`)
50+
- Some programmers friendly features from Python&mdash;that being said, Rust
51+
does not compromise on performance: it has static typing (with type
52+
inference!)
53+
- Optional tracing-GC (WIP)&mdash;the `std::gc::Gc` type recently landed on
54+
mainline
55+
56+
As you can see, Rust does not try to be a new fancy thing; rather, it builds up
57+
on top of proven useful technology and merges features from some existings
58+
languages, noticeably: Erlang's green threads, Haskell trait system and overall
59+
functional programming elements of a few languages (it has pattern matching!),
60+
some syntax sugar from Python (the `range` iterator is one of them) and it also
61+
resurrects a few features from some American research languages developed in the
62+
80s, amongst others.
63+
As you can see, along with some features that definitely set it in today's
64+
rollup of programming languages, Rust is also the result of a true willingness
65+
to reuse concepts from the rich history of programming languages, rather than
66+
building up the wheel over again. ;) ~ as you might have seen, that's partly
67+
where the name "Rust" comes from!
68+
69+
> I was fiddling with a number of names. Primarily it's named after the
70+
> [pathogenic fungi] which are just amazing multi-lifecycle, multi-host
71+
> parasites, fascinating creatures.
3572
>
36-
>But the name "rust" has other nice features. It fits with our theme of being "close to the metal" and "using old well-worn language technology". It's also a substring of "trust" and "robust". What's not to like?
73+
> But the name "rust" has other nice features. It fits with our theme of being
74+
> "close to the metal" and "using old well-worn language technology". It's also
75+
> a substring of "trust" and "robust". What's not to like?
3776
>
3877
> &mdash; Graydon Hoare
3978
40-
Actually, Mozilla is already using it in an experimental browser rendering engine that is being developed simultaneously to Rust and is at the core of the team's pragmatic development approach, just like [D]'s&mdash;that is, the developers implement features and sometimes change them based on their experience with it; besides, they also take feedback (and contributions!) from the community.
41-
Remember, C&mdash;today's most successful language&mdash;has been built in concert with the UNIX OS, allowing adaptations from what happened during the OS development process. Right now, Rust is still in alpha state which means that developers can still make breaking changes to the API (but not to worry, it is converging towards a stable state which will ultimately happen in 1.0).
42-
43-
There have been other attempts at providing such a new System programming language (e.g. [D], [Nimrod])&mdash;Go also gets mentioned sometimes but it has been developed for apps/webapps and is more oriented towards simplicity and fast compilation-speed.
44-
Right now, it looks like Rust has a big chance to set itself apart because:
45-
46-
- It focuses on safety without compromising performance (D requires GC for safety, and Nimrod does not ensure thread safety), it has low-level features but also lots of sugar for the developer (the syntax is modern and not overly verbose)
47-
- It is pretty innovative, seeing how it reuses a lot of features that have been developed independently, but make sense together
79+
Actually, Mozilla is already using it in an experimental browser rendering
80+
engine that is being developed simultaneously to Rust and is at the core of the
81+
team's pragmatic development approach, just like [D]'s&mdash;that is, the
82+
developers implement features and sometimes change them based on their
83+
experience with it; besides, they also take feedback (and contributions!) from
84+
the community.
85+
Remember, C&mdash;today's most successful language&mdash;has been built in
86+
concert with the UNIX OS, allowing adaptations from what happened during the OS
87+
development process. Right now, Rust is still in alpha state which means that
88+
developers can still make breaking changes to the API (but not to worry, it is
89+
converging towards a stable state which will ultimately happen in 1.0).
90+
91+
There have been other attempts at providing such a new System programming
92+
language (e.g. [D], [Nimrod])&mdash;Go also gets mentioned sometimes but it has
93+
been developed for apps/webapps and is more oriented towards simplicity and fast
94+
compilation-speed. Right now, it looks like Rust has a big chance to set itself
95+
apart because:
96+
97+
- It focuses on safety without compromising performance (D requires GC for
98+
safety, and Nimrod does not ensure thread safety), it has low-level features
99+
but also lots of sugar for the developer (the syntax is modern and not overly
100+
verbose)
101+
- It is pretty innovative, seeing how it reuses a lot of features that have been
102+
developed independently, but make sense together
48103
- It is backed by Mozilla, not bad if you are trying to set a standard!
49104

50105
Appendix: Elaborating on C++ and safety
51106
---------------------------------------
52107

53-
You might think: why were these even allowed in the first place? To quote Tony Hoare, the `null_ptr` precursor:
108+
You might think: why were these even allowed in the first place? To quote Tony
109+
Hoare, the `null_ptr` precursor:
54110

55-
> I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.
111+
> I couldn't resist the temptation to put in a null reference, simply because it
112+
> was so easy to implement. This has led to innumerable errors, vulnerabilities,
113+
> and system crashes, which have probably caused a billion dollars of pain and
114+
> damage in the last forty years.
56115
>
57116
> &mdash; Tony Hoare
58117
59-
C++ is a mixed breed: it has been developed from the beginning to build up on top of C with new features that were emerging in the field of programming. Today, it is one of the [Top Five languages] because it has been fast at a higher level of abstraction (also complexity!) than the others.
60-
Looking back, we realized that the time spared by relaxed programming APIs was often creating much bigger problems down the road&mdash;because it is always less time consuming and more convenient to just avoid these programming derps than debugging your program afterwards.
61-
62-
Rust tries to ensure safety with some additional syntax markup (which actually makes you to think unambiguously about your desired behavior) that allows for a way more fine-grained static analysis by the compiler and can lead to additional compiler optimizations&mdash;indeed, some unsafe code that would pass as valid in most of today's most-used languages would get caught at compile-time in Rust. Instructions that are not safe or cannot be statically checked will have to be located inside an `unsafe` code block (that is mostly for the FFI, which allows you to link your programs to C).
118+
C++ is a mixed breed: it has been developed from the beginning to build up on
119+
top of C with new features that were emerging in the field of programming.
120+
Today, it is one of the [Top Five languages] because it has been fast at a
121+
higher level of abstraction (also complexity!) than the others.
122+
Looking back, we realized that the time spared by relaxed programming APIs was
123+
often creating much bigger problems down the road&mdash;because it is always
124+
less time consuming and more convenient to just avoid these programming derps
125+
than debugging your program afterwards.
126+
127+
Rust tries to ensure safety with some additional syntax markup (which actually
128+
makes you to think unambiguously about your desired behavior) that allows for a
129+
way more fine-grained static analysis by the compiler and can lead to additional
130+
compiler optimizations&mdash;indeed, some unsafe code that would pass as valid
131+
in most of today's most-used languages would get caught at compile-time in Rust.
132+
Instructions that are not safe or cannot be statically checked will have to be
133+
located inside an `unsafe` code block (that is mostly for the FFI, which allows
134+
you to link your programs to C).
63135

64136
Appendix: Elaborating on Servo
65137
------------------------------
66138

67-
What is [Servo]? Well&mdash;nothing to do with mechanics: it is Mozilla's experimental browser rendering engine.
139+
What is [Servo]? Well&mdash;nothing to do with mechanics: it is Mozilla's
140+
experimental browser rendering engine.
68141

69-
So, in a way, you could say that it's their biggest [hope][servo-hope] and biggest motivation for supporting Rust's development. Safety. Parallelism. (And Performance.)
70-
Its development started in early-2012 (they like contributions too!) and it is evolving along with Rust.
142+
So, in a way, you could say that it's their biggest [hope][servo-hope] and
143+
biggest motivation for supporting Rust's development. Safety. Parallelism. (And
144+
Performance.) Its development started in early-2012 (they like contributions
145+
too!) and it is evolving along with Rust.
71146

72-
Servo is built on a modular architecture and each engine component is separated from the other in an effort to have parallelized and easy-to-maintain code. Since April 2013, Mozilla and Samsung [are collaborating][moz-samsung] in the project development.
147+
Servo is built on a modular architecture and each engine component is separated
148+
from the other in an effort to have parallelized and easy-to-maintain code.
149+
Since April 2013, Mozilla and Samsung [are collaborating][moz-samsung] in the
150+
project development.
73151

74-
Note that right now, Mozilla has no plans to integrate Servo onto Firefox, i.e., it is as of now a research project and is still in early stages of development.
152+
Note that right now, Mozilla has no plans to integrate Servo onto Firefox, i.e.,
153+
it is as of now a research project and is still in early stages of development.
75154
BTW, Servo [passed Acid1][servo-acid1] recently!
76155

77156
[Rust]: http://www.rust-lang.org/

source/ch-02.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
Few things you should know
44
==========================
55

6-
The Rust API is frequently evolving (read: improving), so this tutorial will be aimed at current master which has the latest language contents.
7-
Note that most of the "standard" features are pretty much stabilized and should not change much. You can choose to use the latest release, but as it gets older, there will probably be numerous changes onto the latest trunk. If you have any concern related to the language or its syntax, just [jump on IRC][IRC] and ask the others!
6+
The Rust API is frequently evolving (read: improving), so this tutorial will be
7+
aimed at current master which has the latest language contents.
8+
Note that most of the "standard" features are pretty much stabilized and should
9+
not change much. You can choose to use the latest release, but as it gets older,
10+
there will probably be numerous changes onto the latest trunk. If you have any
11+
concern related to the language or its syntax, just [jump on IRC][IRC] and ask
12+
the others!
813

914
The latest release is Rust 0.9, released on January 9th 2014.
1015

@@ -13,20 +18,25 @@ Installing Rust
1318

1419
### Windows
1520

16-
You can get [snapshot builds][snapshots-windows] for Windows through the NuGet [Package Manager console]:
21+
You can get [snapshot builds][snapshots-windows] for Windows through the NuGet
22+
[Package Manager console]:
1723

1824
~~~~bash
1925
Install-Package Rust
2026
~~~~
2127

22-
Or have a look at the [build instructions][build-windows] if you want to build it yourself.
23-
**Note:** `mingw-w64` should fix a few things compared to the regular `mingw` (it works on both 32- and 64-bit systems, despite the name).
28+
Or have a look at the [build instructions][build-windows] if you want to build
29+
it yourself.
30+
**Note: `mingw-w64` should fix a few things compared to the regular `mingw` (it
31+
**works on both 32- and 64-bit systems, despite the name).
2432

25-
If you are not willing to go through these steps, just download the [0.9 release][win-release].
33+
If you are not willing to go through these steps, just download the [0.9 release
34+
][win-release].
2635

2736
### Mac OS X
2837

29-
The installation process on Mac OS is fairly easy using the [Homebrew package manager][Homebrew]; for the latest trunk, run:
38+
The installation process on Mac OS is fairly easy using the [Homebrew package
39+
manager][Homebrew]; for the latest trunk, run:
3040

3141
~~~~bash
3242
brew install --HEAD rust
@@ -61,12 +71,14 @@ make
6171
sudo make install
6272
~~~~
6373

64-
Note that there are repositories with nightly packages for [Arch], [Fedora] and [Ubuntu].
74+
Note that there are repositories with nightly packages for [Arch], [Fedora] and
75+
[Ubuntu].
6576

6677
Get your code editor ready
6778
--------------------------
6879

69-
You are about to write your first Rust program; just create a `.rs` file with your favorite text editor. It gets built with `rustc`, the Rust compiler.
80+
You are about to write your first Rust program; just create a `.rs` file with
81+
your favorite text editor. It gets built with `rustc`, the Rust compiler.
7082

7183
~~~~bash
7284
# create a new file
@@ -79,7 +91,8 @@ rustc hello.rs
7991

8092
Using the `-O` switch will add the default optimization level to the code.
8193

82-
BTW, you can get syntax highlighting for [vim], [gedit] or [other highlighting solutions] on the main repo.
94+
BTW, you can get syntax highlighting for [vim], [gedit] or [other highlighting
95+
solutions] on the main repo.
8396

8497
[IRC]: http://client01.chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
8598
[snapshots-windows]: https://www.nuget.org/packages/Rust/

0 commit comments

Comments
 (0)