Fuel手册-更新中 (The Fuel Book)-updating
  • 0.Fuel手册 (The Fuel Book)
  • 1. 开发者快速上手 (Developer Quickstart)
    • 1.1构建智能合约 (Building A Smart Contract)
    • 1.2 构建前端 (Building a Frontend)
  • 2.准备开始 (Getting Started)
    • 2.1为什么是Fuel (Why Fuel)
    • 2.2Fuel是什么? (What is Fuel?)
      • 2.2.1 Fuel工具链 (The Fuel Toolchain)
    • 2.3 模块化运动 (Modular Movement)
      • 2.3.1 单片架构 (Monolithic Architecture)
      • 2.3.4 什么是模块化执行层 (What is a Modular Execution Layer)
    • 2.4 Fuel设置 (Fuel Configurations)
      • 2.4.1 作为汇总的Fuel (Fuel as a roll-up)
      • 2.4.2 作为L1的Fuel (Fuel as an L1)
      • 2.4.3 作为状态通道的Fuel (Fuel as a state channel)
      • 2.4.4 作为侧链的Fuel (Fuel as a sidechain)
  • 3. 技术 (Technology)
    • 3.1 并行交易执行(Parallel Transaction Execution)
    • 3.2欺诈证明 (Fraud Proofs)
  • 4. Fuel虚拟机 (The FuelVM)
    • 4.1合约和调用模型(Contract and Call Model)
    • 4.2内存模式 (Memory Mode)
    • 4.3多重原生资产(Multiple Native Assets)
    • 4.4FuelVM和EVM, 轻松搞明白(FuelVM vs. EVM, Explained)
  • 5.Sway语言 (Sway Language)
    • 5.1 Sway设计哲学 (Sway Design Philosophy)
    • 5.2 Sway的安全性 (Sway Safety)
  • 6.开发者看这里(For Developers)
    • 6.1Sway程序示例 (Sway Application Examples)
    • 6.2 网络 (Networks)
      • 6.2.1 `beta-3`测试网 (The `beta-3` testnet)
      • 6.2.2 `beta-2`测试网 (The `beta-2` testnet)
      • 6.2.3 `beta-1` 测试网 (beta-1 testnet)
    • 6.3 运行一个本地Fuel节点 (Running a local Fuel node)
    • 6.4 Sway语言 (Sway Language) 🌴
    • 6.5 Typescript SDK
    • 6.6 Rust SDK
    • 6.7 Fuel索引器 (Fuel Indexer)
    • 6.8 水龙头和区块浏览器 (Faucet and Block Explorer)
    • 6.9 Fuelup
    • 6.10 Fuel GraphQL API
  • 7. Fuel术语 (Fuel Glossary)
Powered by GitBook
On this page
  1. 5.Sway语言 (Sway Language)

5.1 Sway设计哲学 (Sway Design Philosophy)

Sway follows the design philosophies of Rust and Solidity, with some Fuel ideology mixed in. From Solidity, we took the notion of smart contract programming as a paradigm. This led to storage blocks, contract ABIs as entry points, etc.

Sway 遵循 Rust 和 Solidity 的设计哲学,并混入了一些 Fuel 设计理念。从 Solidity 开始,我们将智能合约编程的概念作为范例。这导致了存储区块、合约 ABI 作为入口点等情况。

From Rust, we took the prioritizations of performance, control, and safety. In Rust, this means the borrow checker, safe parallelism (send and sync), annotated unsafety, etc., mainly to save the programmer from referencing freed memory, shared mutable state, and undesirable memory management. This is great for a general-purpose language model. Sway, however, is not general purpose. Sway targets a blockchain VM environment, where execution is not indefinite, and memory allocation and management are less concerned. Instead, we need to optimize for gas costs and contract-level safety. We applied the philosophy of performance, control, and safety and interpreted it in this new context. This is where Sway gets compile time checks of state mutability, namespacing of state variables, static analysis passes, and gas profiling/optimization.

从 Rust 开始,我们优先考虑性能、控制和安全。在 Rust 中,这意味着借用检查器、安全并行性(发送和同步)、带注释的不安全性等,这主要是为了避免程序员引用释放的内存、共享的可变状态和不需要的内存管理。这对于通用变成语言模型来说非常有用。然而,Sway 不是通用的。 Sway 针对的是区块链 VM 环境,执行不是无限期的,且对内存分配和管理关心较少。相反,我们需要优化 gas 成本和合约级别的安全性。我们应用了性能、控制和安全的理念,并在这个新的背景下对其进行了解释。这是 Sway 获取编译时检查状态可变性、状态变量命名空间、静态分析传递和gas分析/优化的地方。

Previous5.Sway语言 (Sway Language)Next5.2 Sway的安全性 (Sway Safety)

Last updated 2 years ago