Idioms and Patterns Story
Hello World
Home  Repo
Top, Bottom

Hello Libs

Demonstration compares C#, C++, and Rust "Hello World" programs


This page is now just a copy of Hello World, awaiting data and text. Each item in the IdiomsAndPatterns repository focues on a simple program construct built in each of the three languages: C++ 20, Rust 1.49, and C# 9.0. This may help you use what you know of C++ or C# (or Java) to learn Rust more easily. We start here with the simplest programs in each of the three languagues. Find instructions for downloading build chains for each of these languages in Tooling.
C++ - Blue Theme hide // Hello.cpp #include int main() { std::cout << "\n Hello World from C++" << "\n\n"; } C++ build and execute cd build C:\...\HelloWorld\Cpp\build> cmake .. >NULL C:\...\HelloWorld\Cpp\build> cmake --build . >NULL C:\...\HelloWorld\Cpp\build> "./debug/HelloPrj.exe" Hello World from C++ CMakeLists.txt # CMake HelloPrj - build C++ with CMake project(HelloPrj) set(CMake_CXX_STANDARD 20) # build HelloCMake.obj in folder # build/debug add_executable(HelloPrj Hello.cpp) C++ Project Setup Steps to create Project: - Create directory for project - Add source code file - Add CmakeLists.txt - CMakeDemo - mkdir build - cd build - cmake .. >NULL - cmake --build . >NULL - "./debug/PrjName.exe" Rust - Rust Theme // HelloWorld::main.rs fn main() { println!("Hello, world!"); } Rust build and execute C:\...\HelloWorld\Rust> cargo run -q Hello, world! cargo.toml [package] name = "rust" version = "0.1.0" authors = ["James W. Fawcett "] edition = "2018" [dependencies] Rust Project Setup Steps to create Project: - Issue command: cargo new PkgName - Edit cargo.toml to provide pkg_name in snake_case - cd src - Edit main.rs for project constent - cargo run -q C# - Black Theme hide using System; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } } C# build and execute C:\...\HelloWorld\CSharp> dotnet run Hello World! C# Project <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework> net5.0 </TargetFramework> </PropertyGroup> </Project> C# Project Setup Steps to create Project: - Issue command: dotnet new console - Edit Program.cs for project constent - dotnet run

4. Epilogue

The following pages provide sequences of code examples for idioms and principles in each of the three languages cited here, e.g. C#, C++, and Rust. Object model differences will often be pointed out in comments within the code blocks.