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);
}
相关推荐
IT_陈寒2 小时前
SpringBoot这个自动配置坑我跳了三次
前端·人工智能·后端
用户395240998803 小时前
排坑日记:ASP.NET Core 中 "Required field is not provided" 验证错误全记录
后端
红尘散仙4 小时前
想写一个像样的终端 App?试试把 React 的开发体验搬进 Rust TUI
前端·rust
用户8356290780514 小时前
使用 Python 自动化 PowerPoint 形状布局与格式设置
后端·python
Oneslide5 小时前
sudo免密权限配置不生效
后端
vivo互联网技术5 小时前
从 Web 到桌面:基于 Tauri 2.0 + Vue 3 打造 vivo 线下门店「大头贴」拍照体验系统
前端·rust
站大爷IP5 小时前
为什么Python不用var或let声明变量?
后端
赴星半途5 小时前
NestJS实战-创建AuthService
后端
北冥有鱼5 小时前
mqtt 测试
前端·后端