rust 編程入門_面向初學者的Rust –最受歡迎的編程語言入門

rust 編程入門

Rust has been voted Stack Overflow’s most loved programming language for five years in a row. This article will tell you why Rust is awesome.

Rust已連續五年被評為Stack Overflow最受歡迎的編程語言。 本文將告訴您為什么Rust很棒。

Rust is a systems programming language that you can use to write applications with high performance. Rust is used by some of the top tech companies like Dropbox and Cloudflare to deliver speed and concurrency to their customers.

Rust是一種系統編程語言 ,可用于編寫高性能的應用程序。 一些頂級高科技公司(例如Dropbox和Cloudflare)使用Rust來為其客戶提供速度和并發性。

For the last five years in a row, Rust has been voted as the most loved programming language.

在過去的五年中,Rust被評選為最受歡迎的編程語言。

But chances are, you might not have worked with Rust. Or worse, you might not have heard of it before. So let's learn more about it.

但是有可能,您可能沒有使用Rust。 或更糟糕的是,您可能以前從未聽說過它。 因此,讓我們進一步了解它。

為什么生銹? (Why Rust?)

Let’s look at why a developer would choose Rust.

讓我們看看為什么開發人員會選擇Rust。

Typical programming languages like Python and C++ abstract a lot of details away from developers.

諸如Python和C ++之類的典型編程語言從開發人員那里提取了許多細節。

If you are a junior developer working on a simple web application, this might not an issue. You just want to find a solution to a problem.

如果您是從事簡單Web應用程序的初級開發人員,那么這可能不是問題。 您只想找到問題的解決方案。

For large scale applications that millions of users will use on a daily basis, the ‘problem-solving’ approach will not work. More users consume more system resources. And more resources mean bigger bills for your company.

對于每天將有數百萬用戶使用的大規模應用程序,“問題解決”方法將行不通。 更多的用戶消耗更多的系統資源。 更多的資源意味著您公司的賬單更大。

This is where Rust shines. Rust combines ease of programming with access to core system configurations. Rust is built with memory-safety, concurrency, and security from the ground up.

這是Rust發光的地方。 Rust將易于編程與對核心系統配置的訪問結合在一起。 Rust從一開始就具有內存安全性,并發性和安全性。

Rust is a “systems programming language that focuses on speed, memory safety, and parallelism”.
Rust是一種“專注于速度,內存安全和并行性的系統編程語言”。

Rust is also considered to be a great alternative for C++. Rust offers high performance in addition to helping you eliminate common bugs caused by languages like C++.

Rust也被認為是C ++的絕佳替代品。 除幫助您消除由C ++之類的語言引起的常見錯誤外,Rust還提供了高性能。

Now that you know what Rust can do for you, let's look at Rust in detail.

既然您知道Rust可以為您做什么,那么讓我們詳細了解Rust。

起源 (?Origins)

Rust is an open-source programming language. It was first introduced to the world in 2010 by Graydon Hoare, while he was working at Mozilla. Shortly after, Mozilla began sponsoring this project and is still a core contributor to Rust.

Rust是一種開源編程語言。 Graydon Hoare在Mozilla工作時于2010年首次將其引入世界。 此后不久,Mozilla開始贊助該項目,并且仍然是Rust的核心貢獻者。

Rust started gaining popularity over the years. Even Microsoft uses Rust to build secure and safety-critical software components.

多年來,Rust開始流行。 甚至Microsoft都使用Rust來構建安全且對安全性至關重要的軟件組件。

核心功能 (?Core Features)

Let's look at some core features that make Rust stand out from other programming languages.

讓我們看一些使Rust在其他編程語言中脫穎而出的核心功能。

性能 (Performance)

Rust was built to be high performance form the ground up. Rust offers fine-grained control of memory management and has a minimal standard library.

Rust被構建為具有高性能的基礎。 Rust提供了對內存管理的細粒度控制,并且具有最小的標準庫。

If you look at some of the metrics shared by Figma, they had incredible improvements in performance once they switched to Rust.

如果您看一下Figma共享的一些指標 ,當他們切換到Rust時,它們在性能上有了驚人的提高。

Rust’s low memory footprint also makes it an ideal choice for embedded systems programming. You can use Rust to write software for IoT devices like home automation hubs, smart security systems, and so on.

Rust的低內存占用空間也使其成為嵌入式系統編程的理想選擇。 您可以使用Rust來為IoT設備(例如家庭自動化集線器,智能安全系統等)編寫軟件。

安全 (Security)

One of the major reasons Microsoft decided to root for Rust is its security.

微軟決定支持Rust的主要原因之一是其安全性。

The majority of vulnerabilities in Microsoft software were due to poor memory management in C & C++. This lead to simple yet powerful exploits like the Buffer Overflow exploit that had crippled Windows for years.

Microsoft軟件中的大多數漏洞是由于C&C ++中的內存管理不良所致。 這導致了簡單而強大的漏洞利用 ,例如使Windows癱瘓多年的“ 緩沖區溢出”漏洞 。

So Microsoft decided to look for the best alternative to C++. And they found Rust.

因此,Microsoft決定尋找C ++的最佳替代品。 他們發現了Rust。

Using Rust eliminates an entire class of security vulnerabilities from software applications. This helps companies build applications with better performance and higher security.

使用Rust消除了軟件應用程序中的一整類安全漏洞。 這有助于公司構建具有更好性能和更高安全性的應用程序。

并發 (Concurrency)

Concurrency is when two or more tasks start, run, and complete in overlapping time. Database operations are a great example to explain concurrency.

并發是指兩個或多個任務在重疊時間內啟動,運行和完成。 數據庫操作是解釋并發性的一個很好的例子。

When thousands of users are using your application at the same time to perform different actions, your database handles them concurrently. Concurrency is a key concept when it comes to scaling applications.

當成千上萬的用戶同時使用您的應用程序執行不同的操作時,數據庫將同時處理它們。 當擴展應用程序時,并發是一個關鍵概念。

Concurrency and parallelism are also built into Rust. Rust solves most of the concurrency problems during compile time by using the concept of Ownerships. Learn how Rust handles concurrency here.

并發和并行性也內置在Rust中。 Rust使用所有權概念解決了編譯期間的大多數并發問題。 在此處了解Rust如何處理并發 。

使用Rust (Working With Rust)

Now that you understand the core features of Rust, let's write a few lines of code. You can find installation instructions here if you want to try out Rust on your computer.

現在您了解了Rust的核心功能,讓我們寫幾行代碼。 如果要在計算機上試用Rust,可以在這里找到安裝說明 。

Let's start with a simple “Hello World!” function.

讓我們從一個簡單的“ Hello World!”開始。 功能。

// Main function
fn main() {println!("Hello World!");
}

Yep. That's pretty much it. Let's try to add two numbers.

是的 就是這樣。 讓我們嘗試將兩個數字相加。

// Main function
fn main() {let a = 100;let b = 200;println!("Result is {}",a+b);
}

Again, pretty standard. Now let's look at an array operation.

再次,相當標準。 現在讓我們看一下數組操作。

// Main function
fn main(){let arr:[i32;4] = [1,2,3,4];println!("array size is {}",arr.len());
}

If you look at line 3, we use “:[i32;4]”. Here we tell Rust that we are declaring an array of length 4 with 32-bit integers.

如果您看一下第3行,我們使用“:[i32; 4]”。 在這里,我們告訴Rust,我們正在聲明一個長度為4的數組,其中包含32位整數。

Declaring data types in detail is a key factor in improving the performance of a program. You are helping the compiler save time by explicitly declaring what type of data you are about to assign to a variable.

詳細聲明數據類型是提高程序性能的關鍵因素。 您通過明確聲明將要分配給變量的數據類型來幫助編譯器節省時間。

Letting the compiler figure out the data type is one of the main reasons you run into performance issues while scaling your application.

讓編譯器弄清楚數據類型是在擴展應用程序時遇到性能問題的主要原因之一。

Also, Rust is a statically typed language, which means it must know the types of all variables at compile time.

同樣, Rust是一種靜態類型的語言 ,這意味著它必須在編譯時知道所有變量的類型。

Though Rust is syntactically similar to C and C++, don't let its simplicity fool you. Rust does come with a steep learning curve. But it is totally worth it once you get a good grasp of the basics.

盡管Rust在語法上類似于C和C ++,但不要讓其簡單性欺騙您。 Rust確實具有陡峭的學習曲線。 但是,一旦您掌握了基本知識,就完全值得。

誰使用Rust? (Who Uses Rust?)

Now that you have a good grasp of what Rust is, let's look at who uses Rust.

既然您已經了解了Rust是什么,那么讓我們看看誰使用Rust。

微軟 (Microsoft)

Once a fierce adversary of open source, Microsoft is now an avid contributor to a number of open-source projects. Their .net core project is one of the most popular open-source frameworks used by developers today.

曾經是開源的激烈對手,Microsoft現在是許多開源項目的熱心貢獻者。 他們的.net核心項目是當今開發人員使用的最受歡迎的開源框架之一。

Microsoft has chosen Rust for security and performance-critical applications. Rust is also used extensively in Azure, especially in its IoT Edge platform to run AI applications on IoT devices.

Microsoft已選擇Rust用于安全性和對性能至關重要的應用程序。 Rust在Azure中也被廣泛使用,尤其是在其IoT Edge平臺中,以在IoT設備上運行AI應用程序。

投寄箱 (Dropbox)

Dropbox uses Rust to improve its data center efficiency. Rust is now powering core services of Dropbox serving more than 500 million users.

Dropbox使用Rust來提高其數據中心效率。 Rust現在為Dropbox的核心服務提供支持,為超過5億用戶提供服務。

Dropbox recently wrote a detailed article on how they re-wrote their core engine.

Dropbox 最近寫了一篇有關如何重新編寫其核心引擎的詳細文章 。

In Dropbox’s own words,

用Dropbox自己的話說,

Rust has been a force multiplier for our team, and betting on Rust was one of the best decisions we made.
Rust一直是我們團隊的力量倍增器,對Rust的押注是我們做出的最佳決定之一。

Rust was also a contributing factor that helped Dropbox move its infrastructure from AWS to its own data centers.

Rust也是幫助Dropbox將其基礎架構從AWS遷移到其自己的數據中心的一個促成因素。

菲格瑪 (Figma)



Figma is a cloud-based designing and prototyping tool that you can use in your browser. It is an excellent tool for designing, prototyping, and exporting your designs into code. Learn more about Figma here.

Figma是一種基于云的設計和原型制作工具,可以在瀏覽器中使用。 它是用于設計,制作原型并將設計導出到代碼中的出色工具。 在此處了解有關Figma的更多信息 。

Concurrency is crucial for a collaborative tool where many users will be working on a single design at a time. Figma used Rust to write a high-performance server that helped them scale their product and achieve the performance they were looking for.

并發對于一個協作工具至關重要,在協作工具中,許多用戶將同時處理一個設計。 Figma使用Rust編寫了一個高性能服務器,可以幫助他們擴展產品并實現他們想要的性能。

Here is the article Figma wrote about their experience with Rust.

這是Figma寫的關于他們在Rust方面的經驗的文章 。

TL; DR (TL;DR)

Rust is a systems programming language that has been voted as StackOverflow’s most loved programming languages, four years in a row.

Rust是一種系統編程語言,已連續四年被評為StackOverflow最受歡迎的編程語言 。

Rust gives you control over low-level details and provides remarkable improvements in speed and stability.

Rust使您可以控制低級細節,并在速度和穩定性方面取得了顯著改善。

It has helped companies like Dropbox, Figma, and Microsoft build better applications for their customers.

它已經幫助Dropbox,Figma和Microsoft等公司為其客戶構建更好的應用程序。

The language is being increasingly adopted by companies looking to scale their applications with higher performance and concurrency. Sounds interesting? Start learning Rust here.

希望通過更高性能和并發性擴展其應用程序的公司越來越多地采用該語言。 聽起來不錯? 從這里開始學習Rust 。



I regularly write about Machine Learning, Cyber Security, and DevOps. You can signup for my weekly newsletter here.

我定期撰寫有關機器學習,網絡安全和DevOps的文章。 您可以 在這里 注冊我的 每周新聞

翻譯自: https://www.freecodecamp.org/news/rust-getting-started-with-the-most-loved-programming-language/

rust 編程入門

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/390243.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/390243.shtml
英文地址,請注明出處:http://en.pswp.cn/news/390243.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【轉載】springboot:如何優雅的使用mybatis

這兩天啟動了一個新項目因為項目組成員一直都使用的是mybatis,雖然個人比較喜歡jpa這種極簡的模式,但是為了項目保持統一性技術選型還是定了 mybatis。到網上找了一下關于spring boot和mybatis組合的相關資料,各種各樣的形式都有,…

創建react應用程序_通過構建電影搜索應用程序在1小時內了解React

創建react應用程序If youve been meaning to learn React but are unsure of where to start, Scrimbas brand new Build a Movie Search App course is perfect for you! 如果您一直想學習React,但是不確定從哪里開始,那么Scrimba全新的Build a Movie S…

GeoServer自動發布地圖服務

1 NetCDF氣象文件自動發布案例 GeoServer是一個地理服務器,提供了管理頁面進行服務發布,樣式,切片,圖層預覽等一系列操作,但是手動進行頁面配置有時并不滿足業務需求,所以GeoServer同時提供了豐富的rest接口…

selenium+ python自動化--斷言assertpy

前言: 在對登錄驗證時,不知道為何原因用unittest的斷言不成功,就在網上發現這個assertpy,因此做個筆記 準備: pip install assertypy 例子: 1 from assertpy import assert_that2 3 4 def check_login():5 …

11. 盛最多水的容器

11. 盛最多水的容器 給你 n 個非負整數 a1,a2,…,an,每個數代表坐標中的一個點 (i, ai) 。在坐標內畫 n 條垂直線,垂直線 i 的兩個端點分別為 (i, ai) 和 (i, 0) 。找出其中的兩條線,使得它們與 x 軸共同構…

深入理解ES6 pdf

下載地址:網盤下載目錄 第1章 塊級作用域綁定 1var聲明及變量提升(Hoisting)機制 1塊級聲明 3-- let聲明 3-- 禁止重聲明 4-- const聲明 4-- 臨時死區(Temporal Dead Zone) 6循環中的塊作用域綁定 7-- 循環中的函…

MyBatis之輸入與輸出(resultType、resultMap)映射

2019獨角獸企業重金招聘Python工程師標準>>> 在MyBatis中,我們通過parameterType完成輸入映射(指將值映射到sql語句的占位符中,值的類型與dao層響應方法的參數類型一致),通過resultType完成輸出映射(從數據庫中輸出,通…

2021-08-25556. 下一個更大元素 III

556. 下一個更大元素 III 給你一個正整數 n ,請你找出符合條件的最小整數,其由重新排列 n 中存在的每位數字組成,并且其值大于 n 。如果不存在這樣的正整數,則返回 -1 。 注意 ,返回的整數應當是一個 32 位整數 &…

gradle tool升級到3.0注意事項

Gradle版本升級 其實當AS升級到3.0之后,Gradle Plugin和Gradle不升級也是可以繼續使用的,但很多新的特性如:Java8支持、新的依賴匹配機制、AAPT2等新功能都無法正常使用。 Gradle Plugin升級到3.0.0及以上,修改project/build.grad…

如何使用React,TypeScript和React測試庫創建出色的用戶體驗

Im always willing to learn, no matter how much I know. As a software engineer, my thirst for knowledge has increased a lot. I know that I have a lot of things to learn daily.無論我知道多少,我總是愿意學習。 作為軟件工程師,我對知識的渴望…

PowerDesigner常用設置

2019獨角獸企業重金招聘Python工程師標準>>> 使用powerdesigner進行數據庫設計確實方便,以下是一些常用的設置 附加:工具欄不見了 調色板(Palette)快捷工具欄不見了 PowerDesigner 快捷工具欄 palette 不見了,怎么重新打開&#x…

bzoj5090[lydsy11月賽]組題

裸的01分數規劃,二分答案,沒了. #include<cstdio> #include<algorithm> using namespace std; const int maxn100005; int a[maxn]; double b[maxn]; double c[maxn]; typedef long long ll; ll gcd(ll a,ll b){return (b0)?a:gcd(b,a%b); } int main(){int n,k;s…

797. 所有可能的路徑

797. 所有可能的路徑 給你一個有 n 個節點的 有向無環圖&#xff08;DAG&#xff09;&#xff0c;請你找出所有從節點 0 到節點 n-1 的路徑并輸出&#xff08;不要求按特定順序&#xff09; 二維數組的第 i 個數組中的單元都表示有向圖中 i 號節點所能到達的下一些節點&#…

深入框架本源系列 —— Virtual Dom

該系列會逐步更新&#xff0c;完整的講解目前主流框架中底層相通的技術&#xff0c;接下來的代碼內容都會更新在 這里 為什么需要 Virtual Dom 眾所周知&#xff0c;操作 DOM 是很耗費性能的一件事情&#xff0c;既然如此&#xff0c;我們可以考慮通過 JS 對象來模擬 DOM 對象&…

網絡工程師常備工具_網絡安全工程師應該知道的10種工具

網絡工程師常備工具If youre a penetration tester, there are numerous tools you can use to help you accomplish your goals. 如果您是滲透測試人員&#xff0c;則可以使用許多工具來幫助您實現目標。 From scanning to post-exploitation, here are ten tools you must k…

configure: error: You need a C++ compiler for C++ support.

安裝pcre包的時候提示缺少c編譯器 報錯信息如下&#xff1a; configure: error: You need a C compiler for C support. 解決辦法&#xff0c;使用yum安裝&#xff1a;yum -y install gcc-c 轉載于:https://www.cnblogs.com/mkl34367803/p/8428264.html

程序編寫經驗教訓_編寫您永遠都不會忘記的有效績效評估的經驗教訓。

程序編寫經驗教訓This article is intended for two audiences: people who need to write self-evaluations, and people who need to provide feedback to their colleagues. 本文面向兩個受眾&#xff1a;需要編寫自我評估的人員和需要向同事提供反饋的人員。 For the purp…

刪除文件及文件夾命令

方法一&#xff1a; echo off ::演示&#xff1a;刪除指定路徑下指定天數之前&#xff08;以文件的最后修改日期為準&#xff09;的文件。 ::如果演示結果無誤&#xff0c;把del前面的echo去掉&#xff0c;即可實現真正刪除。 ::本例需要Win2003/Vista/Win7系統自帶的forfiles命…

BZOJ 3527: [ZJOI2014]力(FFT)

題意 給出\(n\)個數\(q_i\),給出\(Fj\)的定義如下&#xff1a; \[F_j\sum \limits _ {i < j} \frac{q_iq_j}{(i-j)^2}-\sum \limits _{i >j} \frac{q_iq_j}{(i-j)^2}.\] 令\(E_iF_i/q_i\)&#xff0c;求\(E_i\). 題解 一開始沒發現求\(E_i\)... 其實題目還更容易想了... …

c# 實現刷卡_如何在RecyclerView中實現“刷卡選項”

c# 實現刷卡Lets say a user of your site wants to edit a list item without opening the item and looking for editing options. If you can enable this functionality, it gives that user a good User Experience. 假設您網站的用戶想要在不打開列表項并尋找編輯選項的情…