121

Arrr, me hearty! Ye be askin' for a simple piece o' code in Rust, peppered with pirate comments. Here be a wee program that prints a hearty greeting:

fn main() {
    // Avast, me hearties! We start our voyage here.
    let greeting = "Ahoy, matey! Welcome aboard!";

    // Yo ho ho! We print our greeting to the open sea!
  println!("{}", greeting);
}

Now ye be havin' a taste o' pirate-infused Rust code! If ye be havin' any more requests or need further assistance, feel free to speak up, and I'll be at yer service!

you are viewing a single comment's thread
view the rest of the comments
[-] aussiematt@lemm.ee 16 points 1 year ago

When I compiled that program, the executable was around 10MB. I wrote the same program in C, and the executable was 15kB. That's about 3 orders of magnitude difference. Is Rust really 1000 times better than C? :-)

[-] axum@kbin.social 19 points 1 year ago* (last edited 1 year ago)

Rust turns a lot of safety things 'on' by default.
Turning all of that off for a tiny program that doesn't need it such as hello world results in a comparable size.

This is a good talk on rust
https://youtu.be/VlSkZYBeK8Q

And this one goes over size reduction
https://youtu.be/b2qe3L4BX-Y

[-] aussiematt@lemm.ee 6 points 1 year ago

Thanks for the resources. I'm old school, and so far haven't really looked into Rust; I look forward to watching the talk you linked to.

load more comments (1 replies)
load more comments (6 replies)
this post was submitted on 11 Jul 2023
121 points (89.5% liked)

Programmer Humor

32410 readers
282 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS