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);
}
相关推荐
秋名RG8 小时前
Java 基础语法
java·开发语言
程序员阿明8 小时前
spring boot4+springAI 2加redis多轮对话存储
spring boot·redis·后端
码行山野赴时序归途8 小时前
C 语言文件操作完全指南:从打开到关闭
c语言·开发语言
2501_937860948 小时前
Java 文件操作与IO(下):字节流、字符流实战IO读写
java·开发语言·python
MetaLite8 小时前
SpringBoot整合FastJson2数据脱敏-接口日志与失败降级
java·spring boot·后端
xixingzhe28 小时前
SpringBoot 接口缓存实现
spring boot·后端·缓存
事圆则缓8 小时前
Kotlin 高阶工程化与 Android 深入实践
android·开发语言·kotlin
驭渊的小故事8 小时前
java抽奖项目-奖品上传中传递参数类型的错误
java·开发语言
名字还没想好☜8 小时前
Go 时间格式化为什么用 2006-01-02:time.Format/Parse 的参考时间、时区与解析踩坑
开发语言·后端·golang·go
Dream Cosmos8 小时前
C++ 多态下篇:虚函数表、动态绑定与多态底层原理
开发语言·c++