129
submitted 1 year ago by PCChipsM922U to c/[email protected]

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!

top 23 comments
sorted by: hot top controversial new old
[-] [email protected] 38 points 1 year ago

Obviously programmers are obsolete now. There is no need for us anymore

[-] [email protected] 22 points 1 year ago

Arrgh matey, ye be walking ye plank. Ye be sleeping with the fishes down in Davy Jones’ Locker. Yarrrr.

[-] [email protected] 8 points 1 year ago

Every time I have asked chatgpt to code for me it has come up with almost correct nonsense. When issues in the code are pointed out, chatgpt generates new code fixing the issue and creating two more new ones. Some of the issues are using features found in other languages in the language requested.

Programmers - your jobs are not in danger. It will take a programmer to check any generated code really carefully and be sure to understand what the AI has spewed forth.

For something as simple as hello world it would get it right. For creating a function to print numbers with imbedded "," commas (to show powers of 10^3 separation) it got it wrong. It gave a program that returned "123,4567.89"

[-] [email protected] 2 points 1 year ago

My original comment was me being silly. But I totally agree. That's why I love copilot's name. Because the ai is just that, the copilot. We still have to fly the plane for the most part ourselves

[-] PCChipsM922U 1 points 1 year ago

Yeah, noticed this too, simple things, no prob, get into more gritty things and it will make a mistake. And yes, you tell it to fix it, but then 2 more bugs are introduced πŸ˜‚.

[-] [email protected] 1 points 1 year ago* (last edited 1 year ago)

So that means that programmers are being replaced with debuggers. Human debuggers.

[-] [email protected] 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? :-)

[-] [email protected] 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

[-] [email protected] 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.

[-] [email protected] 1 points 1 year ago

this is not due to safety but rather std. Set opt level to 3 and enable fat lto

[-] [email protected] 17 points 1 year ago

The standard lib is statically linked, so there will be a higher baseline binary size. This means that yes, a hello world project may be 10mb unstripped but a considerably more complicated project could in turn be 11mb unstripped. Aka it doesn't matter much in practice.

[-] [email protected] 16 points 1 year ago

I wrote it in C and compiled it for an ATtiny13 and it was 162 bytes. That includes the code to initialize the microcontroller and a bit banged transmit only UART to actually output the text.

[-] [email protected] 9 points 1 year ago

just goes to show: size is relative :-)

[-] [email protected] 8 points 1 year ago* (last edited 1 year ago)

Enable LTO, abort on panic, and a higher optimization level and it'll drop that a ton

[-] [email protected] 1 points 1 year ago

set opt level to 3 and enable fat lto.
even without fat lto enabled, my entire multithreaded voxel engine with multithreaded procedural world generation, procedural structures and multiplayer is 5mb in size.

[-] [email protected] 5 points 1 year ago

yeah, so that is a good example of how AI should be used!

[-] PCChipsM922U 2 points 1 year ago

Well, at least I got a good chuckle out of it πŸ˜‚.

[-] [email protected] -5 points 1 year ago

That in fact is not an hello world project

[-] [email protected] -5 points 1 year ago

That in fact is not an hello world project

[-] PCChipsM922U 7 points 1 year ago
[-] [email protected] 4 points 1 year ago

I guess it's an "Ahoy matey!" Project?

[-] PCChipsM922U 2 points 1 year ago

Fair enough πŸ‘.

load more comments
view more: next β€Ί
this post was submitted on 11 Jul 2023
129 points (89.6% liked)

Programmer Humor

31326 readers
20 users here now

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

Rules:

founded 4 years ago
MODERATORS