Rust (programming language): Difference between revisions

Content deleted Content added
Raync (talk | contribs)
History: consolidated history of name and logo into new section
link style
 
(7 intermediate revisions by the same user not shown)
Line 68:
}}
 
'''Rust''' is a [[General-purpose programming language|general-purpose]] [[programming language]]. It is noted emphasizingfor its emphasis on [[Computer performance|performance]], [[type safety]], and [[Concurrency (computer science)|concurrency]]. It enforces [[memory safety]], meaning that alland [[Reference (computer science)|references]] point to valid memory. It does so without a conventional [[Garbage collection (computer science)|garbage collector]]; instead, memory safety errors and [[data race]]s are prevented by the "borrow checker", which tracks the [[object lifetime]] of references [[Compiler|at compile time]].
 
Rust supports multiple [[programming paradigm]]s. It was influenced by ideas from [[functional programming]], including [[Immutable object|immutability]], [[higher-order function]]s, [[algebraic data type]]s, and [[pattern matching]]. It also supports [[object-oriented programming]] via structs, [[Union type|enums]], traits, and methods. Rust is noted for enforcing memory safety (i.e., that all [[Reference (computer science)|references]] point to valid memory) without a conventional [[Garbage collection (computer science)|garbage collector]]; instead, memory safety errors and [[data race]]s are prevented by the "borrow checker", which tracks the [[object lifetime]] of references [[Compiler|at compile time]].
 
Software developer Graydon Hoare created Rust asin a personal project2006 while working at [[Mozilla]] Research, in 2006. Mozillawhich officially sponsored the project in 2009. The first stable release of Rust, Rust 1.0, was published in May 2015. Following a large layoff of Mozilla employees in August 2020, multiplefour other companies joined Mozilla in sponsoring Rust through the creation of the [[#Rust Foundation|Rust Foundation]] in February 2021. In December 2022, Rust became the first language other than [[C (programming language)|C]] and [[Assembly language|assembly]] to be supported in the development of the [[Linux kernel]].
 
Rust has been noted for its adoption in many software projects, especially [[web servicesservice]]s and [[system software]], and is the first language other than [[C (programming language)|C]] and [[Assembly language|assembly]] to be supported in the development of the [[Linux kernel]]. It has been studied academically and has a growing community of developers.
 
==Etymology==
Line 84:
Rust began as a personal project by [[Mozilla]] employee Graydon Hoare in 2006.<ref name="MITTechReview">{{cite web |url=https://www.technologyreview.com/2023/02/14/1067869/rust-worlds-fastest-growing-programming-language/ |title=How Rust went from a side project to the world's most-loved programming language |last=Thompson |first=Clive |date=2023-02-14 |website=MIT Technology Review |language=en |access-date=2023-02-23 |archive-date=2024-09-19 |archive-url=https://web.archive.org/web/20240919102849/https://www.technologyreview.com/2023/02/14/1067869/rust-worlds-fastest-growing-programming-language/ |url-status=live }}</ref> Hoare started the project due to his frustration with a broken elevator in his apartment building.<ref name="MITTechReview"/> During the time period between 2006 and 2009, Rust was not publicized to others at Mozilla and was written in Hoare's free time;<ref name=Klabnik2016ACMHistory>{{Cite book |last=Klabnik |first=Steve |chapter=The History of Rust |date=2016-06-02 |title=Applicative 2016 |chapter-url=https://dl.acm.org/doi/10.1145/2959689.2960081 |page=80 |___location=New York, NY, USA |publisher=Association for Computing Machinery |doi=10.1145/2959689.2960081 |isbn=978-1-4503-4464-7}}</ref>{{rp|at=7:50}} Hoare began speaking about the language around 2009 after a small group at Mozilla became interested in the project.<ref name=Hoare2010>{{Cite conference |url=http://venge.net/graydon/talks/intro-talk-2.pdf |archive-url=https://archive.today/20211226213836/http://venge.net/graydon/talks/intro-talk-2.pdf |archive-date=2021-12-26 |last=Hoare |first=Graydon |title=Project Servo: Technology from the past come to save the future from itself |publisher=Mozilla Annual Summit |date=July 2010 |access-date=2024-10-29 }}</ref> Hoare emphasized prioritizing good ideas from old languages over new development, citing languages including [[CLU (programming language)|CLU]] (1974), [[BETA (programming language)|BETA]] (1975), [[Mesa (programming language)|Mesa]] (1977), [[NIL (programming language)|NIL]] (1981), [[Erlang (programming language)|Erlang]] (1987), [[Newsqueak]] (1988), [[Napier88|Napier]] (1988), [[Hermes (programming language)|Hermes]] (1990), [[Sather]] (1990), [[Alef (programming language)|Alef]] (1992), and [[Limbo (programming language)|Limbo]] (1996) as influences, stating "many older languages [are] better than new ones", and describing the language as "technology from the past come to save the future from itself."<ref name=Klabnik2016ACMHistory/>{{rp|at=8:17}}<ref name=Hoare2010/> Early Rust developer Manish Goregaokar similarly described Rust as being based on "mostly decades-old research."<ref name="MITTechReview"/>
 
During the early years, the Rust [[compiler]] was written in about 38,000 lines of [[OCaml]].<ref name=Klabnik2016ACMHistory/>{{rp|at=15:34}}<ref name=OCamlCompiler>{{Cite web |last=Hoare |first=Graydon |title=Rust Prehistory (Archive of the original Rust OCaml compiler source code) |website=[[GitHub]] |date=November 2016 |url=https://github.com/graydon/rust-prehistory/tree/master |access-date=2024-10-29 }}</ref> Early Rust contained features such as explicit [[object-oriented programming]] via an {{code|obj}} keyword (later removed),<ref name=Klabnik2016ACMHistory/>{{rp|at=10:08}} and a [[typestate analysis|typestates]] system that would allow variables of a type to be tracked along with state changes (such as going from uninitialized to initialized, also removed).<ref name=Klabnik2016ACMHistory/>{{rp|at=13:12}}
 
=== 2009–2012: Mozilla sponsorship ===
Line 91:
During this time period, work had shifted from the initial OCaml compiler to a [[Self-hosting (compilers)|self-hosting compiler]], ''i.e.'', written in Rust, based on [[LLVM]].<ref name=Rust0.1>{{Cite web |title=0.1 first supported public release Milestone · rust-lang/rust |url=https://github.com/rust-lang/rust/milestone/3?closed=1 |access-date=2024-10-29 |website=[[GitHub]] |language=en}}</ref>{{refn|group=note|The list of Rust compiler versions (referred to as a bootstrapping chain) has history going back to 2012.<ref name=Nelson2022RustConf>{{Cite AV media |url=https://www.youtube.com/watch?v=oUIjG-y4zaA |last=Nelson |first=Jynn |title=RustConf 2022 - Bootstrapping: The once and future compiler |publisher=Rust Team |date=2022-08-05 |access-date=2024-10-29 |___location=Portland, Oregon |via=YouTube}}</ref>}} The Rust ownership system was also in place by 2010.<ref name="MITTechReview"/>
 
The first public release, Rust 0.1, was released on January 20, 2012<ref name=Rust0.1a>{{Cite mailing list |last=Anderson |first=Brian |date=2012-01-24 |title=[rust-dev] The Rust compiler 0.1 is unleashed |url=https://mail.mozilla.org/pipermail/rust-dev/2012-January/001256.html |mailing-list=rust-dev |access-date=2025-01-07 |archive-url=https://web.archive.org/web/20120124160628/https://mail.mozilla.org/pipermail/rust-dev/2012-January/001256.html |archive-date=January 24, 2012 }}</ref> for Windows, Linux, and MacOS.<ref name=ExtremeTechRust0.1>{{Cite web |last=Anthony |first=Sebastian |date=2012-01-24 |title=Mozilla releases Rust 0.1, the language that will eventually usurp Firefox's C++ |url=https://www.extremetech.com/internet/115207-mozilla-releases-rust-0-1-the-language-that-will-eventually-usurp-firefoxs-c |access-date=2025-01-07 |website=ExtremeTech |language=en}}</ref> The early 2010s saw increasing involvement from open source volunteers outside of Mozilla and outside of the United States. At Mozilla, executives would eventually employ over a dozen engineers to work on Rust full time over the next decade.<ref name="MITTechReview"/>
 
=== 2012–2015: Evolution ===
 
The years from 2012 to 2015 were marked by substantial changes to the Rust [[type system]], especially,including the removal of the typestate system, consolidation of other language features, and the removal of the [[Garbage collection (computer science)|garbage collector]].<ref name=Klabnik2016ACMHistory/>{{rp|at=18:36}}<ref name="MITTechReview"/> Memory management through the ownership system was gradually consolidated and expanded to prevent memory-related bugs. By 2013, the garbage collector feature was rarely used, and was removed by the team in favor of the ownership system.<ref name="MITTechReview"/> Other changes during this time included the removal of [[pure function]]s, which were declared by an explicit {{code|pure}} annotation, in March 2013.<ref>{{Cite web |title=Purity by pcwalton · Pull Request #5412 · rust-lang/rust |url=https://github.com/rust-lang/rust/pull/5412 |access-date=2024-10-29 |website=[[GitHub]] |language=en}}</ref> Specialized syntax support for [[channel (programming)|channels]] and various pointer types were removed to simplify the language.<ref name=Klabnik2016ACMHistory/>{{rp|at=22:32}}
 
According to Rust's expansiondeveloper andSteve consolidationKlabnik, Rust was influenced during this period by developers coming from [[C++]] (e.g., low-level performance of features), [[scripting language]]s (e.g., Cargo and package management), and [[functional programming]] (e.g., type systems development).<ref name=Klabnik2016ACMHistory/>{{rp|at=30:50}}
 
Graydon Hoare stepped down from Rust in 2013.<ref name="MITTechReview"/> ThisAfter allowedHoare's departure, it to evolveevolved organically under a more federated governance structure, with a "core team" of initially six people,<ref name=Klabnik2016ACMHistory/>{{rp|at=21:45}} around 30-40 developers total across various other teams,<ref name=Klabnik2016ACMHistory/>{{rp|at=22:22}} and a Request for Comments (RFC) process for new language features added in March 2014.<ref name=Klabnik2016ACMHistory/>{{rp|at=33:47}} The core team would grow to nine people by 2016<ref name=Klabnik2016ACMHistory/>{{rp|at=21:45}} with over 1600 proposed RFCs.<ref name=Klabnik2016ACMHistory/>{{rp|at=34:08}}
 
According to Andrew Binstock writing for ''[[Dr. Dobb's Journal]]'' in January 2014, while Rust was "widely viewed as a remarkably elegant language", adoption slowed because it radically changed from version to version.<ref>{{cite news |last=Binstock |first=Andrew |date=January 7, 2014 |title=The Rise And Fall of Languages in 2013 |website=[[Dr. Dobb's Journal]] |url=https://www.drdobbs.com/jvm/the-rise-and-fall-of-languages-in-2013/240165192 |url-status=dead |archive-url=https://web.archive.org/web/20160807075745/http://www.drdobbs.com/jvm/the-rise-and-fall-of-languages-in-2013/240165192 |archive-date=2016-08-07 |access-date=2022-11-20}}</ref> Rust development at this time was focused on finalizing the language features and moving towards 1.0 so it could begin promising [[backward compatibility]].<ref name=Klabnik2016ACMHistory/>{{rp|at=41:26}}
Line 111:
The development of the [[Servo (software)|Servo browser engine]] continued in parallel with Rust, jointly funded by Mozilla and [[Samsung]].<ref>{{cite news|last=Lardinois|first=Frederic|date=2015-04-03|title=Mozilla And Samsung Team Up To Develop Servo, Mozilla's Next-Gen Browser Engine For Multicore Processors|work=[[TechCrunch]]|url=https://techcrunch.com/2013/04/03/mozilla-and-samsung-collaborate-on-servo-mozillas-next-gen-browser-engine-for-tomorrows-multicore-processors/|access-date=2017-06-25|archive-date=2016-09-10|archive-url=https://web.archive.org/web/20160910211537/https://techcrunch.com/2013/04/03/mozilla-and-samsung-collaborate-on-servo-mozillas-next-gen-browser-engine-for-tomorrows-multicore-processors/|url-status=live}}</ref> The teams behind the two projects worked in close collaboration; new features in Rust were tested out by the Servo team, and new features in Servo were used to give feedback back to the Rust team.<ref name=Klabnik2016ACMHistory/>{{rp|at=5:41}} The first version of Servo was released in 2016.<ref name="MITTechReview"/> The [[Firefox]] web browser shipped with Rust code as of 2016 (version 45),<ref name=Klabnik2016ACMHistory/>{{rp|at=53:30}}<ref>{{Cite web |title=Firefox 45.0, See All New Features, Updates and Fixes |url=https://www.mozilla.org/en-US/firefox/45.0/releasenotes/ |access-date=2024-10-31 |website=Mozilla |language=en |archive-date=2016-03-17 |archive-url=https://web.archive.org/web/20160317215950/https://www.mozilla.org/en-US/firefox/45.0/releasenotes/ |url-status=live }}</ref> but components of Servo did not appear in Firefox until September 2017 (version 57) as part of the [[Gecko (software)|Gecko]] and [[Gecko (software)#Quantum|Quantum]] projects.<ref>{{Cite web |last=Lardinois |first=Frederic |date=2017-09-29 |title=It's time to give Firefox another chance |url=https://techcrunch.com/2017/09/29/its-time-to-give-firefox-another-chance/ |access-date=2023-08-15 |website=[[TechCrunch]] |language=en-US |archive-date=2023-08-15 |archive-url=https://web.archive.org/web/20230815025149/https://techcrunch.com/2017/09/29/its-time-to-give-firefox-another-chance/ |url-status=live }}</ref>
 
Improvements were made to the Rust toolchain ecosystem during the years following 1.0 including [[#Rustfmt|Rustfmt]], [[integrated development environment]] integration,<ref name=Klabnik2016ACMHistory/>{{rp|at=44:56}} and a regular compiler testing and release cycle,.<ref name=Klabnik2016ACMHistory/>{{rp|at=46:48}} Rust also gained a community [[code of conduct]], and community discussion organized through an [[IRC]] chat for community discussion.<ref name=Klabnik2016ACMHistory/>{{rp|at=50:36}}
 
The earliest known adoption outside of Mozilla was by individual projects at Samsung, [[Facebook]] (now [[Meta Platforms]]), [[Dropbox]], and others including Tilde, Inc. (the company behind [[ember.js]]).<ref name=Klabnik2016ACMHistory/>{{rp|at=55:44}}<ref name="MITTechReview"/> [[Amazon Web Services]] followed in 2020.<ref name="MITTechReview"/> Engineers acknowledged the risks of adopting a new technology; they cited performance, lack of a garbage collector, safety, and pleasantness of working in the language as reasons for the adoption, while acknowledging that it was a risky bet as Rust was new technology. Amazon developers cited a finding by Portuguese researchers that Rust code used [[Energy efficiency in computing|uses less energy]] compared to similar code written in [[Java (programming language)|Java]] and [[C++]], (behind only [[C (programming language)|C]]).<ref name="MITTechReview"/><ref name=2017PortugalEnergyStudy>{{Cite book |last1=Pereira |first1=Rui |last2=Couto |first2=Marco |last3=Ribeiro |first3=Francisco |last4=Rua |first4=Rui |last5=Cunha |first5=Jácome |last6=Fernandes |first6=João Paulo |last7=Saraiva |first7=João |chapter=Energy efficiency across programming languages: How do energy, time, and memory relate? |date=2017-10-23 |title=Proceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering |chapter-url=https://dl.acm.org/doi/10.1145/3136014.3136031 |series=SLE 2017 |___location=New York, NY, USA |publisher=Association for Computing Machinery |pages=256–267 |doi=10.1145/3136014.3136031 |hdl=1822/65359 |isbn=978-1-4503-5525-4}}</ref>{{refn|group=note|Energy compared to C was 3% more for Rust and 34% more for C++; time was 4% more and 56% more, respectively.}}
 
=== 2020–present: Mozilla layoffs and Rust Foundation ===
 
In August 2020, Mozilla laid off 250 of its 1,000 employees worldwide, as part of a corporate restructuring caused by the [[COVID-19 pandemic]].<ref>{{cite web |url=https://www.zdnet.com/article/mozilla-lays-off-250-employees-while-it-refocuses-on-commercial-products/ |title=Mozilla lays off 250 employees while it refocuses on commercial products |last=Cimpanu |first=Catalin |website=[[ZDNET]] |access-date=2020-12-02 |date=2020-08-11 |archive-date=March 18, 2022 |archive-url=https://web.archive.org/web/20220318025804/https://www.zdnet.com/article/mozilla-lays-off-250-employees-while-it-refocuses-on-commercial-products/ |url-status=live}}</ref><ref>{{cite web |url=https://www.engadget.com/mozilla-firefox-250-employees-layoffs-151324924.html |title=Mozilla lays off 250 employees due to the pandemic |website=[[Engadget]] |last=Cooper |first=Daniel |access-date=2020-12-02 |date=2020-08-11 |archive-date=2020-12-13 |archive-url=https://web.archive.org/web/20201213020220/https://www.engadget.com/mozilla-firefox-250-employees-layoffs-151324924.html |url-status=live}}</ref> The team behind Servo was disbanded. The event raised concerns about the future of Rust, due to the overlap between the two projects.<ref>{{Cite web |last=Tung |first=Liam |date=2020-08-21 |title=Programming language Rust: Mozilla job cuts have hit us badly but here's how we'll survive |url=https://www.zdnet.com/article/programming-language-rust-mozilla-job-cuts-have-hit-us-badly-but-heres-how-well-survive/ |access-date=2022-04-21 |website=[[ZDNET]] |language=en |archive-date=April 21, 2022 |archive-url=https://web.archive.org/web/20220421083509/https://www.zdnet.com/article/programming-language-rust-mozilla-job-cuts-have-hit-us-badly-but-heres-how-well-survive/ |url-status=live}}</ref> In the following week, the Rust Core Team acknowledged the severe impact of the layoffs and announced that plans for a Rust foundation were underway. The first goal of the foundation would be to take ownership of all [[trademark]]s and [[___domain name]]s, and to take financial responsibility for their costs.<ref>{{cite web |url=https://blog.rust-lang.org/2020/08/18/laying-the-foundation-for-rusts-future.html |title=Laying the foundation for Rust's future |website=Rust Blog |access-date=2020-12-02 |date=2020-08-18 |archive-date=2020-12-02 |archive-url=https://web.archive.org/web/20201202022933/https://blog.rust-lang.org/2020/08/18/laying-the-foundation-for-rusts-future.html |url-status=live}}</ref>
 
On February 8, 2021, the formation of the [[#Rust Foundation|Rust Foundation]] was announced by five founding companies: [[Amazon Web Services]], [[Google]], [[Huawei]], [[Microsoft]], and [[Mozilla]].<ref>{{Cite web |date=2020-02-08 |title=Hello World! |url=https://foundation.rust-lang.org/news/2021-02-08-hello-world/ |access-date=2022-06-04 |website=Rust Foundation |language=en |archive-date=April 19, 2022 |archive-url=https://web.archive.org/web/20220419124635/https://foundation.rust-lang.org/news/2021-02-08-hello-world/ |url-status=live}}</ref><ref>{{Cite web|date=2021-02-09|title=Mozilla Welcomes the Rust Foundation |website=Mozilla Blog |url=https://blog.mozilla.org/blog/2021/02/08/mozilla-welcomes-the-rust-foundation |archive-url=https://web.archive.org/web/20210208212031/https://blog.mozilla.org/blog/2021/02/08/mozilla-welcomes-the-rust-foundation/|archive-date=2021-02-08|access-date=2021-02-09|url-status=live}}</ref> The foundation, led by Shane Miller for its first two years, offered $20,000 grants and other support for programmers working on major Rust features.<ref name="MITTechReview"/> In a [[blog]] post published on April 6, 2021, Google announced support for Rust within the [[Android Open Source Project]] as an alternative to C/C++.<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=2021-04-08|website=Ars Technica|language=en-us|archive-date=2021-04-08|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>
 
On November 22, 2021, the Moderation Team, which was responsible for enforcing the community code of conduct, announced their resignation "in protest of the Core Team placing themselves unaccountable to anyone but themselves".<ref name="moderation">{{Cite news |first=Tim |last=Anderson |title=Entire Rust moderation team resigns |url=https://www.theregister.com/2021/11/23/rust_moderation_team_quits/ |date=2021-11-23 |access-date=2022-08-04 |website=[[The Register]] |language=en |archive-date=2022-07-14 |archive-url=https://web.archive.org/web/20220714093245/https://www.theregister.com/2021/11/23/rust_moderation_team_quits/ |url-status=live }}</ref> In May 2022, the Rust Core Team, other lead programmers, and certain members of the Rust Foundation board implemented governance reforms in response to the incident.<ref>{{Cite web |title=Governance Update |first1=Ryan |last1=Levick |first2=Mara |last2=Bos |url=https://blog.rust-lang.org/inside-rust/2022/05/19/governance-update.html |access-date=2022-10-27 |website=Inside Rust Blog |language=en |archive-date=2022-10-27 |archive-url=https://web.archive.org/web/20221027030926/https://blog.rust-lang.org/inside-rust/2022/05/19/governance-update.html |url-status=live }}</ref>
 
The Rust Foundation posted a draft for a new trademark policy on April 6, 2023, including rules for how the Rust logo and name can be used, which resulted in widespread negative reactions from Rust users and contributors.<ref name=ApologizesTrademarkPolicy>{{Cite news |last=Claburn |first=Thomas |title=Rust Foundation apologizes for trademark policy confusion |date=2023-04-17 |url=https://www.theregister.com/2023/04/17/rust_foundation_apologizes_trademark_policy/ |access-date=2023-05-07 |website=[[The Register]] |language=en |archive-date=2023-05-07 |archive-url=https://web.archive.org/web/20230507053637/https://www.theregister.com/2023/04/17/rust_foundation_apologizes_trademark_policy/ |url-status=live }}</ref> The trademark policy included rules for how the Rust logo and name could be used.<ref name=ApologizesTrademarkPolicy/>
 
On February 26, 2024, the U.S. [[White House]] through the [[Office of the National Cyber Director]] released a 19-page press report urging software development to move away from C and C++ and encouraging the use ofto memory-safe languages like C#, Go, Java, Ruby, Swift, and Rust.<ref name=WhiteHouse1>{{Cite web |last=Gross |first=Grant |title=White House urges developers to dump C and C++ |url=https://www.infoworld.com/article/2336216/white-house-urges-developers-to-dump-c-and-c.html |date=2024-02-27 |access-date=2025-01-26 |website=[[InfoWorld]] |language=en}}</ref><ref name=WhiteHouse2>{{Cite web |last=Warminsky |first=Joe |date=2024-02-27 |title=After decades of memory-related software bugs, White House calls on industry to act |url=https://therecord.media/memory-related-software-bugs-white-house-code-report-oncd |access-date=2025-01-26 |website=The Record |language=en}}</ref><ref name=WhiteHouseFullReport>{{Cite web |date=2024-02-26 |title=Press Release: Future Software Should Be Memory Safe |url=https://www.whitehouse.gov/oncd/briefing-room/2024/02/26/press-release-technical-report/ |archive-url=https://web.archive.org/web/20250118013136/https://www.whitehouse.gov/oncd/briefing-room/2024/02/26/press-release-technical-report/ |publisher=[[White House|The White House]] |url-status=dead |archive-date=2025-01-18 |access-date=2025-01-26 }}</ref> TheNews reportcoverage hasof beenRust interpretedincreased asin increasinglight interestof inthe Rustreport.<ref name=WhiteHouse3>{{Cite web |last=Jack |first=Bobby |date=2024-02-29 |title=The White House Wants Memory-Safe Programming, but What Is That? |url=https://www.makeuseof.com/memory-safe-programming-white-house-wants/ |access-date=2025-01-26 |website=MakeUseOf |language=en}}</ref><ref name=WhiteHouse4>{{Cite web |last=Donovan |first=Ryan |date=2024-12-30 |title=In Rust we trust? White House Office urges memory safety |url=https://stackoverflow.blog/2024/12/30/in-rust-we-trust-white-house-office-urges-memory-safety/ |access-date=2025-01-26 |website=[[Stack Overflow|The Stack Overflow Blog]] |language=en}}</ref>
 
== Syntax and features ==