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 编程入门

rust 编程入门_面向初学者的Rust –最受欢迎的编程语言入门相关推荐

  1. rust面向对象_面向初学者的Rust操作员综合教程

    rust面向对象 目录 (Table of Contents)

  2. java会被rust替代吗_自从尝了 Rust,Java 突然不香了

    Rust 是软件行业中相对而言比较新的一门编程语言,如果从语法上来比较,该语言与 C++ 其实非常类似,但从另一方面而言,Rust 能更高效地提供许多功能来保证性能和安全.而且,Rust 还能在无需使 ...

  3. 数据库初学者_面向初学者的免费6小时数据科学课程

    数据库初学者 Data science is considered the "sexiest job of the 21st century." Learn data scienc ...

  4. sql查询初学者指南_面向初学者SQL Server查询执行计划–类型和选项

    sql查询初学者指南 When a DBA is working with the SQL Server, he/she might sometimes say that the execution ...

  5. sql查询初学者指南_面向初学者SQL Server查询执行计划–聚集索引运算符

    sql查询初学者指南 We have discussed how to created estimated execution plans and actual execution plans in ...

  6. sql查询初学者指南_面向初学者SQL Server查询执行计划–非聚集索引运算符

    sql查询初学者指南 Now that we understand what Clustered Index Scan and Clustered Index Seek are, how they o ...

  7. java编程工具 初学者_面向初学者的Java编程在线课程

    java编程工具 初学者 There are many java programming course online provided by many services. I use Udemy be ...

  8. Python 入门手册——面向初学者的编程教程

    Hi!你是否正在学习 Python?如果是的,那这篇文章就是为你而准备的,在文中你将会找到 Python 语法的详尽描述以及大量的 Python 代码示例,它将会指导你的 Python 编程之旅. 涵 ...

  9. rust 局域网联机_分享自己用 Rust 写的可以直接利用 SOCKS 代理的游戏加速器

    之前分享了一款自己用 Go 写的游戏加速器 IkaGo,但是我也在文章中多次提到,加速器最重要的是线路而不是技术.为了能更好的利用好手上的一些优质的众所周知的 SOCKS 代理,我又开发了一款加速器( ...

最新文章

  1. 使用 RPI.GPIO 模块的脉宽调制(PWM)功能
  2. liunx防火墙常用命令
  3. 视频专辑:张孝祥Java邮件开发
  4. 简单的客户端,服务端通信
  5. numpy-自定义ufunc函数和广播
  6. 【CodeForces - 574C】Bear and Poker(思维,剪枝,数学)
  7. w ndows10即将停止更新,微软开始警告Windows 10 v1909用户即将停止更新服务
  8. 至少清楚知道兼容IE8 ie9 ;持续更新
  9. 语言学 —— 中文的构词与规律
  10. CLR寄宿(上) MSCOREE.DLL
  11. 数学作图工具_推荐工作学习中用到的三款在线作图神器!
  12. HarmonyOS APP 开发入门
  13. 网吧万兆到桌面服务器配置,网吧篇:2019网吧组网及交换机推荐 万兆千兆到桌面...
  14. 牧月科技完成近5000万元天使轮融资,为无人驾驶货运物流提供解决方案
  15. fatal: The remote end hung up unexpectedly
  16. 叠片过滤器:过滤器设备的普遍使用
  17. 全球与中国家庭捕鱼船市场深度研究分析报告
  18. www.ty66.php,韬轩阁
  19. android 经典rpg,安卓TOP10:SE经典RPG游戏《最终幻想7》领衔
  20. ​Hello Qt(四十七)——QtQuick基础​

热门文章

  1. 【信号】信号集、sigprocmask、sigpending
  2. 进程间同步(互斥量、信号量)
  3. Java架构师必备框架技能核心笔记,工作感悟
  4. MSCRM二次开发实现自动编号功能
  5. OsharpNS轻量级.net core快速开发框架简明入门教程-代码生成器的使用
  6. 第十二届湖南省赛 (B - 有向无环图 )(拓扑排序+思维)好题
  7. 多线程之间的通信(等待唤醒机制、Lock 及其它线程的方法)
  8. css样式中如何设置中文字体?
  9. Jsp2.0自定义标签(第二天)——自定义循环标签
  10. JMM模型到并发编程