Rust Mozilla 的编程语言

Rust 是 Mozilla 的一个新的编程语言,由 web 语言的领军人物 Brendan Eich(js 之父),Dave Herman 以及 Mozilla 公司的 Graydon Hoare 合力开发。

创建这个新语言的目的是为了解决一个很顽疾的问题:软件的演进速度大大低于硬件的演进,软件在语言级别上无法真正利用多核计算带来的性能提升。Rust 是针对多核体系提出的语言,并且吸收一些其他动态语言的重要特性,比如不需要管理内存,比如不会出现 Null 指针等等。

特点:

  • 零成本的抽象

  • 移动语义

  • 保证内存安全

  • 线程没有数据竞争

  • trait-based 泛型

  • 模式匹配

  • 类型推断

  • 最小运行时

  • 高效的 C 绑定

cpp 复制代码
// This code is editable and runnable!
fn main() {
    // A simple integer calculator:
    // `+` or `-` means add or subtract by 1
    // `*` or `/` means multiply or divide by 2

    let program = "+ + * - /";
    let mut accumulator = 0;

    for token in program.chars() {
        match token {
            '+' => accumulator += 1,
            '-' => accumulator -= 1,
            '*' => accumulator *= 2,
            '/' => accumulator /= 2,
            _ => { /* ignore everything else */ }
        }
    }

    println!("The program \"{}\" calculates the value {}",
              program, accumulator);
}
相关推荐
devilnumber19 小时前
Java 递归算法 详解 + 核心要点 + 实战运用 + 避坑指南
java·开发语言·算法
独泪了无痕20 小时前
MyBatis魔法堂:结果集映射
后端·mybatis
copyer_xyf20 小时前
LangChain 调用 LLM
后端·python·agent
copyer_xyf21 小时前
Prompt 组织管理
后端·python·agent
asdfg125896321 小时前
JavaBean是什么?怎么理解?有什么用途?
java·开发语言
dsyyyyy110121 小时前
JavaScript变量
开发语言·javascript·ecmascript
z落落1 天前
C#WinForm 窗体切换与窗体传值(登录跳转案例)+WinForm 窗体传值(从上往下传、从下往上传)
开发语言·windows·c#
allway21 天前
How to Echo Multiline to a File in Bash [3 Methods]
开发语言·chrome·bash
weixin_462446231 天前
手把手教你用 Bash 脚本自动更新 /etc/hosts —— 自动绑定网卡 IP 与节点名
开发语言·tcp/ip·bash
一个梦醒了1 天前
安装git bash选项推荐
开发语言·git·bash