Rust (programming language): Difference between revisions - Wikipedia
Article Images
Content deleted Content added
(10 intermediate revisions by 8 users not shown) | |||
Line 15: }} | released = {{Start date and age|2015|05|15}} | | developer = The Rust Team | latest release version = {{wikidata|property|edit|reference|P548=Q2804309|P348}} | latest release date = {{start date and age|{{wikidata|qualifier|mdy|P548=Q2804309|P348|P577}}}} Line 59 ⟶ 60: }} '''Rust''' is a [[General-purpose programming language|general-purpose]] [[programming language]] emphasizing [[Computer performance|performance]], [[type safety]], and [[Concurrency (computer science)|concurrency]]. It enforces [[memory safety]], meaning that all [[Reference (computer science)|references]] point to valid memory Rust does not enforce a [[programming paradigm]], but was influenced by ideas from [[functional programming]], including [[Immutable object|immutability]], [[higher-order function]]s, Software developer Graydon Hoare created Rust as a personal project while working at [[Mozilla]] Research in 2006. Mozilla officially sponsored the project in 2009. In the years following the first stable release in May 2015, Rust was adopted by companies including [[Amazon (company)|Amazon]], [[Discord]], [[Dropbox]], [[Google]] ([[Alphabet Inc.|Alphabet]]), [[Meta Platforms|Meta]], and [[Microsoft]]. In December 2022, it became the first language other than [[C (programming language)|C]] and [[Assembly language|assembly]] to be supported in the development of the [[Linux kernel]]. Line 184 ⟶ 185: ==== {{code|for}} loops and iterators ==== [[For loop For expressions work over any [[iterator]] type. Line 560 ⟶ 561: </syntaxhighlight> The borrow checker in the Rust compiler uses lifetimes to ensure that the values a reference points to remain valid.{{sfn|Klabnik|Nichols|2019|pp=75,134}}<ref>{{Cite web |last=Shamrell-Harrington |first=Nell |title=The Rust Borrow Checker – a Deep Dive |url=https://www.infoq.com/presentations/rust-borrow-checker/ |access-date=2022-06-25 |website=InfoQ |language=en}}</ref> In the example above, storing a reference to variable {{code|x}} <syntaxhighlight lang="rust"> Line 801 ⟶ 802: In operating systems, the [[Android (operating system)|Android]] developers were using Rust in 2021 to rewrite existing components.<ref>{{Cite web |last=Amadeo |first=Ron |date=2021-04-07 |title=Google is now writing low-level Android code in Rust |url=https://arstechnica.com/gadgets/2021/04/google-is-now-writing-low-level-android-code-in-rust/ |access-date=2022-04-21 |website=Ars Technica |language=en-us |archive-date=April 8, 2021 |archive-url=https://web.archive.org/web/20210408001446/https://arstechnica.com/gadgets/2021/04/google-is-now-writing-low-level-android-code-in-rust/ |url-status=live}}</ref><ref>{{cite web |author1=Darkcrizt |title=Google Develops New Bluetooth Stack for Android, Written in Rust |url=https://blog.desdelinux.net/en/google-develops-a-new-bluetooth-stack-for-android-written-in-rust/ |website=Desde Linux |access-date=31 August 2024 |archive-url=https://web.archive.org/web/20210825165930/https://blog.desdelinux.net/en/google-develops-a-new-bluetooth-stack-for-android-written-in-rust/ |archive-date=25 August 2021}}</ref> The [[Rust for Linux]] project, launched in 2020, added initial Rust support to Linux in late 2022, and the first Linux drivers written in Rust were released in late 2023.<ref>{{Cite web |first=Tim |last=Anderson |date=2021-12-07 |title=Rusty Linux kernel draws closer with new patch |url=https://www.theregister.com/2021/12/07/rusty_linux_kernel_draws_closer/ |access-date=2022-07-14 |website=The Register |language=en}}</ref><ref>{{Cite web |title=A first look at Rust in the 6.1 kernel [LWN.net] |url=https://lwn.net/Articles/910762/ |access-date=2023-11-11 |website=lwn.net [[Microsoft]] is rewriting parts of [[Windows]] in Rust.<ref>{{Cite web |last=Claburn |first=Thomas |title=Microsoft is rewriting core Windows libraries in Rust |url=https://www.theregister.com/2023/04/27/microsoft_windows_rust/ |date=2023-04-27 |access-date=2023-05-13 |website=[[The Register]] |language=en}}</ref> The r9 project aims to re-implement [[Plan 9 from Bell Labs]] in Rust.<ref>{{cite web |last1=Proven |first1=Liam |title=Small but mighty, 9Front's 'Humanbiologics' is here for the truly curious |url=https://www.theregister.com/2023/12/01/9front_humanbiologics/ |website=The Register |access-date=7 March 2024}}</ref> Rust has been used in the development of new operating systems such as [[Redox (operating system)|Redox]], a "Unix-like" operating system and [[microkernel]],<ref>{{cite news |last=Yegulalp |first=Serdar |title=Rust's Redox OS could show Linux a few new tricks |url=http://www.infoworld.com/article/3046100/open-source-tools/rusts-redox-os-could-show-linux-a-few-new-tricks.html |access-date=21 March 2016 |work=InfoWorld |archive-date=21 March 2016 |archive-url=https://web.archive.org/web/20160321192838/http://www.infoworld.com/article/3046100/open-source-tools/rusts-redox-os-could-show-linux-a-few-new-tricks.html |url-status=live}}</ref> Theseus, an experimental operating system with modular state management,<ref>{{Cite web |first=Tim |last=Anderson |date=2021-01-14 |title=Another Rust-y OS: Theseus joins Redox in pursuit of safer, more resilient systems |url=https://www.theregister.com/2021/01/14/rust_os_theseus/ |access-date=2022-07-14 |website=The Register |language=en}}</ref><ref>{{Cite book |last1=Boos |first1=Kevin |last2=Liyanage |first2=Namitha |last3=Ijaz |first3=Ramla |last4=Zhong |first4=Lin |date=2020 |title=Theseus: an Experiment in Operating System Structure and State Management |url=https://www.usenix.org/conference/osdi20/presentation/boos |language=en |pages=1–19 |isbn=978-1-939133-19-9}}</ref> and most of [[Fuchsia (operating system)|Fuchsia]].<ref name="rustmag-1">{{cite web |first1=HanDong (Alex)|last1=Zhang |title=2022 Review {{!}} The adoption of Rust in Business |url=https://rustmagazine.org/issue-1/2022-review-the-adoption-of-rust-in-business/ |date=2023-01-31 |website=Rust Magazine |access-date=February 7, 2023 |language=en}}</ref> Rust is also used for command-line tools and operating system components, including [[Stratis (configuration daemon)|stratisd]], a [[file system]] manager<ref>{{cite web |url=https://www.marksei.com/fedora-29-new-features-startis/ |title=Fedora 29 new features: Startis now officially in Fedora |last=Sei |first=Mark |date=10 October 2018 |website=Marksei, Weekly sysadmin pills |access-date=2019-05-13 |archive-date=2019-04-13 |archive-url=https://web.archive.org/web/20190413075055/https://www.marksei.com/fedora-29-new-features-startis/ |url-status=live}}</ref><ref>{{Cite web |last=Proven |first=Liam |date=2022-07-12 |title=Oracle Linux 9 released, with some interesting additions |url=https://www.theregister.com/2022/07/12/oracle_linux_9/ |access-date=2022-07-14 |website=[[The Register]] |language=en}}</ref> and COSMIC, a [[desktop environment]] by [[System76]].<ref>{{Cite web |last=Proven |first=Liam |date=2023-02-02 |title=System76 teases features coming in homegrown Rust-based desktop COSMIC |url=https://www.theregister.com/2023/02/02/system76_cosmic_xfce_updates/ |access-date=2024-07-17 |website=[[The Register]] |language=en}}</ref> |