An example of “Hello World” with raw Rust:
#![feature(no_core,lang_items,start)]
#![no_core]
#![no_std]
#![no_main]
#[lang = "sized"]
pub trait Sized {}
#[lang = "copy"]
pub trait Copy {}
#[no_mangle]
#[start]
pub extern fn _start ()
{
loop {}
}
You can compile it I think with:
rustc +nightly --crate-type bin -C link-arg=-nostartfiles test.rs
In such book you could obviously use core and std but this is as minimal as it can get (almost) ;-)
@jarkko I would beg to differ. Understanding the language shouldn't be disrupted by having to figure out, how to turn it into machine code. Once we go beyond simple single file examples, just using rustc is not enough and burdening the user with the rather archaic Makefile syntax and details of compiling and linking would just distract from the topic. I would even argue, that single file examples benefit from the ability to do "cargo run".
@jarkko Even though my experience with Rustlang is minimal, I can 100% agree with this. Overall the usage of Cargo in documentation examples gives me NPM vibes even though Rustlang should appeal to those working with low-level systems (C, Cpp).
I really hope gcc-rs and the standardization process changes how these books introduce developers to Rustlang.
@jarkko well, we might be roughly the same age (although my journey did start with QBasic before moving on to Turbo C++). I'm not complaining about modern Dev tools. On the contrary. I just think that focus on Rust as a language isn't helped by using rustc and Makefiles instead of doing a simple "cargo run".
@jarkko I have bounced off rust several times because cargo is bloated unusable npm-rot. I see glimpses of a decent language under there, but it is basically undocumented as everything assumes you want the webdev experience.
@jarkko
Some people came to me to know how to learn programming and I told them to starts with logic, algorithmic and data structures then choose a programming language that resonates with them. I don't understand why people want to learn using to code by directly learning a language from books like the one you're describing.
What they actually end up learning is not how to program but just how to use a toolchain/framework ; this knowledge is perishable and isn't portable and leads to frustration.