Conversation

Jarkko Sakkinen

Edited yesterday
Where all existing Rust books fall short is that they are not Rust books.

They are books on building software with Cargo framework.

A great "Understanding Rust" book would based only on using rustc for all examples, and in the context of that book e.g. GNU make could be used to orchestrate the builds.

Using Cargo is obviously fine but it is in the way of in-depth understanding of the language.

This also means that I really do not recommend any of the books written about Rust because they are all as useful as the Rust documentation, i.e. not that useful.

#rust #cargo
7
7
6

Jarkko Sakkinen

Edited yesterday

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) ;-)

#rust #rustlang #cargo

1
2
8
Results 2.4 KB 64-bit ELF. From that most is metadata. Code and data is 337 bytes.
0
0
2

@jarkko ah dang I agree 100

1
0
1

@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".

1
0
0
@f4grx in order to hack one needs to touch the bottom of the ocean first before swimming on the water ;-)
1
0
2

@jarkko absolutely true!

0
0
1

@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.

1
0
1
@namenlos when I was young everyone started with Turbo Pascal just enough to generate lookup tables with it and then moved to Turbo Assembler :-) At least you have language constructs and a high-level build language. Don't get what you are complaining about TBH.
1
0
0
@laho So for low-level programming, or starting with it with any tool, you don't need that much information to begin with it as you don't have complex frameworks to learn. Just how you tell the toolchain where the entry point is and basic stuff like that...

Thus, it is good way to start Rust when you mind is still in virgin state and not been inducted by the cargo cult just yet ;-)
0
0
1

@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".

0
0
0

@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.

1
0
0

@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.

0
0
1
@AMS So, I think Cargo is great (personally). It is just that in order to use I need to know how it works.
0
0
0