سلام دنیا

بیایید به ساده ترین برنامه Rust ممکن یعنی یک برنامه Hello World کلاسیک بپردازیم:

fn main() {
    println!("Hello 🌍!");
}

آنچه شما می‌بینید:

  • توابع با fn معرفی می‌شوند.
  • بلوک‌ها با پرانتزهای باز و بسته مانند C و C++ محدود می‌شوند.
  • تابع main نقطه ورود برنامه است.
  • زبان Rust دارای ماکروهای hygienic است، println! یک نمونه از این است.
  • رشته‌های Rust دارای انکودینگ UTF-8 هستند و می‌توانند شامل هر کاراکتر یونیکد باشند.
This slide should take about 5 minutes.

This slide tries to make the students comfortable with Rust code. They will see a ton of it over the next four days so we start small with something familiar.

نکات کلیدی:

  • زبان Rust, زبان بسیار شبیه به سایر زبان‌های خانواده C/C++/Java است.یک زبان امری است (imperative) و سعی نمی‌کند چیزی را مگر اینکه کاملاً ضروری باشد، دوباره اختراع کند.

  • زبان Rust, یک زبان مدرن با پشتیبانی کامل از چیزهایی مانند یونیکد است.

  • Rust uses macros for situations where you want to have a variable number of arguments (no function overloading).

  • Macros being ‘hygienic’ means they don’t accidentally capture identifiers from the scope they are used in. Rust macros are actually only partially hygienic.

  • Rust is multi-paradigm. For example, it has powerful object-oriented programming features, and, while it is not a functional language, it includes a range of functional concepts.