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);
}
相关推荐
65岁退休Coder3 分钟前
LangChain v1.3.4 笔记 - 07 补充:链式调用 LCEL
后端·python·langchain
卷无止境14 分钟前
FastAPI 部署在 Nginx 后面到底该怎么配
后端·python
码流怪侠15 分钟前
用 WiFi 信号数人头:howmanypeoplearearound 项目深度解析
后端·开源·github
半亩码田24 分钟前
C#转Python第3.1篇:Python 的 class 没有访问修饰符?面向对象的另一条路
开发语言·python·c#
心运软件42 分钟前
SpringBoot+ Vue校园社团管理平台的完整架构设计
vue.js·后端
Wzx1980121 小时前
python沙箱和docker沙箱你选对了吗?
开发语言·python·docker
Jodie同志1 小时前
第16~23天:持久化、HITL、流式、MCP与安全
前端·后端·agent
牧羊人.3331 小时前
Python 办公自动化从入门到入土|09 数据容器之字典
开发语言·python
Jodie同志1 小时前
第1~15天:原生Agent、RAG与LangGraph基础(完整代码实操)
前端·后端·agent
Zane19942 小时前
单例线程安全、生产者消费者、死锁:并发面试三连问串讲
java·后端