Rust: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
added zinc to projects list
updating the rust article with a new description, more projects, and some descriptions.
Line 1:
'''Rust''' is a new systems language under developmentsponsored by Mozilla, designedfocused toon offerthree betterthings: safety, speed, and concurrency. thanIt other,accomplishes moremany traditionalof systemsthese programminggoals languages.through strong Thecompile-time syntaxchecks, isallowing afor Cvery dialectlittle withoverhead theat familiar braces and semi-colonsruntime. ItPerformance featuresis constructscomparable fromto imperativeC programmingor (suchC++, as <tt>if</tt> and <tt>while</tt>), functionalbeing programmingfree (suchof asmany lambda's,of multi-directionalthe patternproblems matchingcaused andby immutablethings variables)like anddangling objectpointers, orientedbuffer languages (traitsoverflows, and objects)iterator invalidation.
 
While Rust is very much a "curly-brace" language, it also takes many cues from ML. Almost everything is an expression, there is a very strong type system,
Rust has a strong focus on memory safety and control. Object allocation happens on the stack by default, but they can explicitly be stored on the heap. Objects are automatically deallocated as soon as they are no longer needed. Rust's references prevent dangling pointers, null references, and out of bounds memory access.
 
Rust provides a mechanism to subvert its safety checks when necessary, by adding an 'unsafe' annotation to portions of your code. This allows you full access to raw pointers, while controlling exactly how they are used. Often, Rust code that uses unsafe will do so as an implementation detail, allowing for them to expose a safe interface.
 
== Operating System Development ==
While Rust has its own runtime (that uses libc), Rust can easily be configured to compile programs without it. This gives developers the freedom to implement their own memory allocation and other low-level services. This makes Rust ideal for operating system development.
 
Rust has a comparable amount of runtime to C and C++, and has set up its standard library to be amenable towards OS development. Specifically, the standard library is split into two parts: core and std. Core is the lowest-level aspects only, and doesn't include things like allocation, threading, and other higher-level features. Std builds on top of core to add them. Using only core is as easy as adding an annotation in your main source file.
== Projects ==
 
Every Rust compiler is a cross-compiler, which makes setup easier.
 
There are still some rough edges when doing OSDev, and they require using nightly-only features. These are currently being worked on.
 
== Active Projects ==
 
* [https://github.com/thepowersgang/rust-barebones-kernel Meaty Bare-Bones]
* [https://github.com/thepowersgang/rust_os "Tifflin"]
** Multiboot image for x86_64
** Actively developed, has VFS and userland
* [https://github.com/charliesome/rustboot RustBoot]
** x86 bootsector, doesn't use libcore
** Out-of-date, written in pre 1.0 code
* [https://github.com/ryanra/RustOS Ryanra's RustOS]
** Uses libcore/collections/alloc
** Actively developed
* [http://www.redox-os.org Redox]
** One of the largest and most active Rust OS projects
** Actively developed
* [https://github.com/hackndev/zinc Zinc]
** uses libcore
** targets embedded MCUs, ARM only so far
* [http://intermezzos.github.io/ intermezzOS]
** Small kernel + book, specifically for learning OSDev through Rust
* [https://github.com/ryanra/RustOS Ryanra's RustOS]
** Uses libcore/collections/alloc
 
== Past Projects ==
 
Rust went through a long and public development process, and used to have a significantly larger runtime. There were lots of experiments pre-1.0, and so these projects are of historical interest but may not build.
 
* [https://github.com/charliesome/rustboot RustBoot]
* [https://github.com/LeoTestard/Quasar Quasar]
* [https://github.com/miselin/rustic Rustic]
* [https://github.com/wbthomason/ironkernel IronKernel]
* [https://github.com/thiagopnts/rustico Rustico]
* [https://github.com/Arcterus/kRnel kRnl]
* [https://github.com/mahrz/rv6 rv6]
 
 
== Libraries ==
 
* [https://github.com/alexcrichton/green-rs green-rs]: Original green threads in early rust. No longer maintainted.
* [https://github.com/nathan7/libfringe libfringe]: Lightweight threading/task library based on libgreen.
* [https://github.com/gz/rust-x86 libx86]: Library to program x86 hardware.
* [https://github.com/Tobba/libcpu libcpu]: Library to program CPUs.
Line 32 ⟶ 50:
 
== See Also ==
 
* [http://www.rust-lang.org/ Rust Website]
* [https://github.com/rust-lang/rust-wiki-backup/blob/master/Operating-system-development.md Operating Systems Development in Rust]
Line 38 ⟶ 57:
* [[Rust Bare Bones]]
* [http://os.phil-opp.com/ Blog Series: Writing an OS in Rust]
* [http://www.randomhacks.net/2015/11/11/bare-metal-rust-custom-target-kernel-space/ Retarget your compiler so interrupts are not evil]
 
[[Category:Languages]]

Revision as of 16:53, 7 January 2016

Rust is a systems language sponsored by Mozilla, focused on three things: safety, speed, and concurrency. It accomplishes many of these goals through strong compile-time checks, allowing for very little overhead at runtime. Performance is comparable to C or C++, while being free of many of the problems caused by things like dangling pointers, buffer overflows, and iterator invalidation.

While Rust is very much a "curly-brace" language, it also takes many cues from ML. Almost everything is an expression, there is a very strong type system,

Rust provides a mechanism to subvert its safety checks when necessary, by adding an 'unsafe' annotation to portions of your code. This allows you full access to raw pointers, while controlling exactly how they are used. Often, Rust code that uses unsafe will do so as an implementation detail, allowing for them to expose a safe interface.

Operating System Development

Rust has a comparable amount of runtime to C and C++, and has set up its standard library to be amenable towards OS development. Specifically, the standard library is split into two parts: core and std. Core is the lowest-level aspects only, and doesn't include things like allocation, threading, and other higher-level features. Std builds on top of core to add them. Using only core is as easy as adding an annotation in your main source file.

Every Rust compiler is a cross-compiler, which makes setup easier.

There are still some rough edges when doing OSDev, and they require using nightly-only features. These are currently being worked on.

Active Projects

  • Meaty Bare-Bones
  • "Tifflin"
    • Multiboot image for x86_64
    • has VFS and userland
  • Redox
    • One of the largest and most active Rust OS projects
  • Zinc
    • uses libcore
    • targets embedded MCUs, ARM only so far
  • intermezzOS
    • Small kernel + book, specifically for learning OSDev through Rust
  • Ryanra's RustOS
    • Uses libcore/collections/alloc

Past Projects

Rust went through a long and public development process, and used to have a significantly larger runtime. There were lots of experiments pre-1.0, and so these projects are of historical interest but may not build.


Libraries

  • libx86: Library to program x86 hardware.
  • libcpu: Library to program CPUs.
  • slabmalloc: Low-level memory allocator for liballoc.
  • multiboot: Library to read multiboot layout.

See Also