/drt/ - Daily Rust Thread

Discuss anything related to Rust, Rust development/news or why Cniles need to give up already and accept the future of programming.

Attached: rust_logo.png (1024x1024, 46K)

Other urls found in this thread:

benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust.html
way-cooler.org/blog/2019/04/29/rewriting-way-cooler-in-c.html
lifthrasiir.github.io/rustlog/why-is-a-rust-executable-large.html
blade.tencent.com/magellan/index_en.html
twitter.com/NSFWRedditGif

kek

Can you do something without using unsafe already?

what's a challenging project I can use to learn rust?

Attached: so_zetta_slow.jpg (700x700, 81K)

You will never be a woman.

Rust compiler

Rust perfectly describes the language: crap no one uses that is covered in fucking rust.
C is the only good language. If you don't think so, you don't understand C. If you think you understand C and think it's not good, then you don't understand C.

Based and Cpilled.

Try programming a microcontroller under 250 kilobyte.

Attached: 1552581607403.png (400x397, 244K)

I shill for Rust while secretly using Ada.

Is nobody realizing that rust is the official cuck language now? First, ((they)) force the sjw coc in open source projects, making development more ((((diverse)))). Rust is their the tool to make programmer more effeminate and making computer science into this bullshit, they want us to become trannies. Be careful.

based.

This is why I only write closed-source Rust programs. They can't ruin my enjoyment of the language if all they have is some compiled binaries.

daily reminder using Rust is equivalent to trying to move an atom with a stick, it doesnt work, you need to get down to the atom level to move it, you need verbose language like C.

stick.get_mover()?.move(atom.into_mut())

vs

ray* atom_ray = atom_ray_init();
char** atoms = atom_ray_get_atoms(atom_ray,&place);
atom_ray_move(atoms[0][1337]);

see retard? its minimal, verbose, just like when u talk, unless you are a reddit npc that is unable to provide proper arguments so they resort to creative wording and mental psyops like hot takes,unpack this etc to "win" an argument

Lisp

Wanna know how I know you've never written a single serious line of Rust in your life?

Tell me, retard

you'll have to be more specific

Are you assuming that nigger knows C? Lmao.
Yeah X_init () returning a pointer to I really hope it is the heap is a non-retard way C programming practice.
Hell if that nigger has ever read the man pages.

Attached: 1544474847341.png (282x424, 50K)

i wrote that in under 25 sec while in queue, stfu retard. go compare libuv against tokio and dilate

sorry sir, but i think you mean

let atom_ray = AtomRay::new();
atom_ray.get(0)
.and_then(|atom| atom.move(1337)
.unwrap();

I fucked that one up but oh well

Can't have a method named "move" because it's a keyword

so again, why would u abstract away the raw pointer and other low level stuff if thats how the CPU works in reality for some "and_then" stuff? its as if u tried to add two single digit integers by using set theory and redefining addition

Just rename .move() to .move_to() or whatever the hell "move" is supposed to mean in this context.

>it's another "cnile cannot comprehend the idea of abstracting away low level boilerplate details" post

and why is having verbose direct operations bad? do u need someone to hold your hand while you pretend to do *mental abstractions* to compile your hot take or what?

You're missing the point, why waste your time writing out all of the verbose direct operations when you can write a shorter version that does the same thing, even on the assembly level? It's not hard to learn what each method does, and reading a few chained method names is a lot easier than trudging through 20 lines of boilerplate data manipulation.

Rust cant compete with C because C is more verbose for high performance requirements, more verbose things allow u to optimize far more and reason far better what is going on because its 1:1 mapping of whats happening w CPU, sure Rust is better than C and C++ for writing code/programs that dont need bleeding edge performance, but for high performance code that measures in nanoseconds C will always come out ahead. for anything that doesnt require bleeding edge performance Rust is better than C, but C is literally the bleeding edge language and its not Cs fault u are too dumb to do pointer and other things so u end up w a CVE

D I L A T E
I
L
A
T
E

Cringe

cope

In utero ftm freemartins are extremely common.
Basedboys are bearded women.
Tranny stuff wouldn't be so popular if we weren't surrounded by trannies.

>C is more verbose for high performance requirements, more verbose things allow u to optimize far more and reason far better what is going on because its 1:1 mapping of whats happening w CPU
The only reason C is fast is because this isn't true

alright tranny let me know when a production driver/os/low level project in Rust will beat C

>inb4 links OpenSSL rust when no one is using openssl anymore as tls lib

Have sex

>1:1 mapping

You still using a PDP-11 or something?

>it's another retard boomer thinking C maps 1:1 with CPU episode

Attached: 1542083082815.png (625x773, 126K)

The C in CPU stands for C

Blinking an LED requires barely anything though. Is Rust bloated or are you trolling?

Attached: 1562756410604.jpg (540x540, 44K)

Can't spell cuck without c.

Attached: 12d009de755a3d4c1f2f6282fbc8f898.jpg (272x272, 12K)

Attached: 1537771566378.png (1200x1400, 502K)

C offers 1:1 mapping of how theoretical CPU works not x86 or any other instr mapping, it allows manual memory management meaning u are managing something at the lowest level possible, a C wizard doesnt need tranny compiler to hold his hand when he passes off a pointer to another function, high level abstractions defeat the purpose of low level programming, idk is it so hard to comprehend or what is happening in this thread, apart from the obvious discord trannies shilling Rust yet again

>C offers 1:1 mapping of how theoretical CPU works not x86 or any other instr mapping
So it doesn't
> allows manual memory management
So does Rust
>managing something at the lowest level possible
Unlike standard C, Rust allows you to write inline assembly
>Rest
Cope Harder Cnile Cuck haha

Attached: 1539184552127.jpg (251x242, 15K)

>unsafe
yes Rust allows it but u have to wrap everything inside "unsafe" blocks which defeats the whole purpose of a safe language, if i want to add two numbers im going to use + and two numbers, now some tranny comes along and keeps saying to do it with higher abstractions like watermelons and keeps convincing me to use it with shit tier baits like yours "its still numbers, they are just watermelons, if you just pretend they are numbers its still the same"

do u realize how retarded you sound?

>So it doesn't
it does, on an abstract level independant of instr set

Don't you get tired of writing the same instruction boilerplate in C to handle null pointers and errors?

As hard as you try they're never going to understand problems with Rust like how much slower it is for using pervasive reference counting that prevents it from doing multiple threads

Threadly reminder that since SPARK implemented safe pointers, there's absolutely no reason to use Rust, outside of diversity quota on genderfluid otherkins.
Threadly reminder that the only meaningful comparison applicable to the industry is Rust/C++ because C and Ada are in a league of their own when it comes to safety.
Threadly reminder to dilate.

As an outsider to both C and Rust, I would appreciate this thread more if it focused more on the Rust workflow and less on shitflinging between Rust and C.
Still, a thread dedicated to a programming language shouldn't really exists, and should be part of /dpt/.

Threads like this are bait made so PHP users can giggle when Cniles and Rustafarians brawl with each other

>C is more verbose
You can write your terrible unsafe C code 1:1 with raw pointers in Rust, however Rust has a lot more verbose things in the same context. For example, here's some C code, and there are at least 3 implicit things happening, none which would be implicit in Rust. Spot all of them!
int element_at(char* arr, int index) {
return arr[index];
}

It's not like you need to write more verbose code to have the same meaning with "high performance requirements", either, the other anons already nailed this in but for a different example let's take a look at a function pointer to a function that takes in a pointer to an array of 8 floats and returns a pointer to an array of 8 ints.
Here's the function pointer definitions in Rust and C:
let thing: fn(&[f32; 8]) -> &[i32; 8]; // Rust
int(*(*thing)(float(*)[8]))[8]; // C

You tell me which is more clear.
You know what allows you to optimize your code far more? A good compiler.
benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust.html
See how Rust is faster than C in this in some cases? What's actually happening is that LLVM > GCC.

Attached: 15045609595861.jpg (384x384, 27K)

Literally what C compiler doesn't allow you to write inline assembly?

>unlike **Standard C**
I guess you can't read!

Attached: 86C87E1F2EB64A0DBD4FEF8DE7732117.jpg (1024x576, 53K)

> hello world
> 2 mb

good luck

Hey Cnile, if I included the size of libc with every hello world program you write that wouldn't be a very fair comparison would it? Not that if you wrote for a microcontroller you'd include the standard library anyway, which is like 100kb at most, not 2mb.

Who cares what standard C does/doesn't allow when in practice you almost always have that ability?

no, if i make a mistake in that boilerplate it means i didnt master C and i deserve to be punished for it

its fine, im just waiting for food to arrive and enjoying the discord tRannies

you can write it in Rust but language goes out of your way to do so and instead wants you to write "safe" code, which is why everyone praises Rust so much, their brainlet brains dont want to deal with all the actual thinking and want to leave it to the compiler, again, C doesnt need or want those people, they can circledilate all they want but they will never get past C or dethrone it.

>int(*(*thing)(float(*)[8]))[8]; // C
if u went through C fish book u could read that instantly and figure out what it is like seriously using easier to read as an example, Rust is easier to read, sure, for beginners and brainlets.

>See how Rust is faster than C in this in some cases? What's actually happening is that LLVM > GCC.
those are small programs that many languages cheat on and shouldnt be taken seriously, Java/C# even call native libs on some...
C allows for very complex projects to take only what they need and create an optimized version if they dedicate their time due to how low level and verbose/robust it is. where are all the high performance drivers in Rust? like say vulkan? why did it take 30k lines just to create an interop from C to Rust of Wayland or w/e project, and then the guy gave up, because Rust falls apart once u introduce project complexity way-cooler.org/blog/2019/04/29/rewriting-way-cooler-in-c.html

>C is safe, just git gud
>another CVE is found in big project overseen by neckbeards with few decades in C
Why does this happen all the time.

...so you seem to be proving my point

I don't have to include a giant runtime. Just libc, and its usually already on the OS.

I can even write code without libc that works.
Can't get away from the giant Rust runtime.

>Rust runtime
no such thing. what's needed is static linked, no external dependencies.

Code bases are large and old.
Other "safe" languages like Java have to get nightly updates to stay secure.

Memory access is hardly the thing holding back the industry.
I am definitely a fan of static analysis, but lets be real, most programmers are fundamentally terrible and Rust isn't going to help them. Good programmers can write good C anyway.

I didn't say anything about external libraries.
There is a runtime like you said its statically linked. See how small you can get hello world, and then get back to me.

Because people are lazy and ignorant. C attracts mostly the cowboy programmers who think they're good, so they refuse to use static analysis because that would hurt their ego.
That C and Ada are the only systems languages that can provide safety remains a fact.

gender.unwrap();

C is not safe, C executes what you want it to and that freedom is the reason why its everywhere. face it, rust is like a fast car with training wheels and 20 other safety mechanisms built in, which just limit you and constrain what u can do because you are unskilled and cant think properly to design a good program, if you have experience you dont need the training wheels or any other safety mechanism because u have the experience and knowhow to do it best, fastest way possible in smalles amount of code and thats what C allows you, to manipulate atoms to create something instead of using abstraction building blocks like "?" "match", "if let","unto","into", "map", "iter" etc. those are all safety mechanisms put in place for people that dont have a lot of experience and dont want to waste their time for those .999999999% performance that bleeding edge software will test.

let gender = self.gender();
gender.change();

>err at line 0: gender not mutable

seethe
lifthrasiir.github.io/rustlog/why-is-a-rust-executable-large.html

way-cooler.org/blog/2019/04/29/rewriting-way-cooler-in-c.html
this guy wasted hundreds of hours of his life chasing the tranny circlerjerk because he was too much of a brainlet to use a pointer and remember what it stands for when he was writing code

>After over 1,000 commits I’m giving up on it.

just think about that for a moment

Yes, I remember when this happened and someone immediately posted it on Jow Forums. This guy is a colossal fucking retard who tried to glue together C and Rust and have their ideas of memory management just work together flawlessly. It didn't work. What a shocker. It was doomed to fail from the very start.

i just want to fuck a rust tranny, but i'll be sticking with c++

Rust is no longer bundling jemalloc by default, please don't link outdated posts. Thank you.

Currently there is 11 THOUSAND lines of Rust in wlroots-rs. All of this code is just wrapper code, it doesn’t do anything but memory management. This isn’t just repeated code either, I defined a very complicated and ugly macro to try to make it easier.

This wrapper code doesn’t cover even half of the API surface of wlroots. It’s exhausting writing wlroots-rs code, memory management is constantly on my mind because that’s the whole purpose of the library. It’s a very boring problem and it’s always at odds with usability - see the motivation for the escape from callback hell described above.

To do all of this, and then go write Way Cooler, already a big undertaking, is too much for me to commit to. When the benefit at the end of the day is just so I don’t have to write C, that doesn’t really make it worth it. If I got this out of the box by simply linking to the library, like I can in C++, then it would be much more tenable.

I can always just use unsafe bindings to wlroots, just like I would with any other language. However, the entire point of Rust is that it’s safe. Doing that is not an option because at that point you lose the entire benefit of the language.

Even SQLite which is extensively well tested isn't immune to CVEs: blade.tencent.com/magellan/index_en.html (RCE)

Abstractions !== Safety Mechanisms
What the fuck are you talking about

RAII isn't reference counting

see:

Meant to quote , that's a misclick. Either way yes, gluing together C and Rust and having the resulting Rust API be safe Rust is not only difficult but stupid.

Whille I like what Rust offers over C++ in terms of its type system and how the borrow checker lets me have a safety net for the majority of times I would use a pointer, I wish it weren't so piss scared of when I do want to use a regular pointer. Like, isn't explicitly going &var as *const T enough to tell Rust "I'm going to do something the borrow checker wouldn't understand, just trust me"? Why must I also go "THIS OPERATION MIGHT CRASH MY PROGRAM, I UNDERSTAND THAT" when I can already show from the types that it's a raw pointer I'm dereferencing, and therefore unsafe to do?

Reminder that ATS is the more theoretically sound systems programming language.

The point of unsafe{} is to isolate and minimalize areas where it can happen.

I share your feeling, but it's only true on personal projects. Unsafe blocks are more eye-catchy for other programmers who read the code and visually parse the program structure faster and more thoroughly.

not to mention that you can grep for unsafe easily when auditing dependencies

when i look at code my coworkers have written i want a giant beacon pointing to where they've potentially fucked things up

also

Attached: ayy.jpg (1024x768, 378K)

>its not Cs fault u are too dumb to do pointer and other things so u end up w a CVE
>i should be expected to spend 10 years writing a simple program just to ensure that my pointers are managed properly
Ok grandpa

Attached: PajeetonC.png (1200x1400, 490K)

just ignore those low IQ cniles, Rust is for big boys who are in the top 5% of software engineers. Absolutely the greatest programming language ever designed

Does anyone else get this sort of error when updating Cargo? It was able to download the rand library at first and compile it fine, but now whenever I try to update Cargo's index I get this error, and google doesn't show anything relevant.

Attached: 47b87da8-74de-42f4-a57c-79e95894b2e0.png (686x185, 11K)

Attached: 15377715663789.png (1200x1400, 284K)

Except that rust uses libc for syscalls.

>not using LLVM IL rather than their retarded sons

That's Rust Achilles heel isn't it.
Only C can compile that to like 80 byte

>Only C can compile that to like 80 byte

not him but, so? what's the point? even most embedded environments now have storage of several megabytes. Let's say you have 1980-ish microcontroller with 1KB of storage. In that case your codebase will be very small to be buggy or messy. i.e. you don't need Rust in that case.

But if you have a big codebase that will compile to a modern embedded board with plenty of storage, Rust will have much faster development cycle, much more confidence in the deployed code, and much more maintainable and readable codebase

>not hourly rust thread
One job.

rust can get pretty small, you'll lose std and things like nice stack traces though

also not to mention that Rust by default uses inlining everywhere, so if you could remove that the final size will be much smaller

a while ago, some user here wrote an image viewer in rust, what library did he use?

>much faster development cycle
If it compiles on given board, this might be true. Rust has better type system that helps this.
>much more confidence in the deployed code
If you're a brainlet that eats every marketing claim, sure.
If you have cerebral capacity higher than a rock, the opposite of your shitpost will be true.
>much more maintainable and readable codebase
False. There are far more proficient C programmers than there are Rust programmers.
Stick to proper guidelines, use static analysis tools available and your C will be much more pleasant to work with (and reliable) than an ungodly amount of unsafe {}? .unwrap() |lol| bullshit.

you obviously want to make this personal since you're low IQ

Rsut is much more than just this Jow Forums-tier safe/unsafe argument even though you're using it wrong, it has a powerful and strict type system, zero-cost abstractions, type-safe macros, generics, traits, sum types, iterators, type-safe enums, clean build system, clean testing

>unsafe {}? .unwrap()
never used unsafe blocks unless with FFI to call libc, never called unwrap() unless I am sure 100% it will never panic, use of unwrap() over returning errors is a sign of being a low IQ, which you obviously are

dilate tranny, remember that C stands for COCK. something you got rid off

>dilate tranny
it's obvious you're a low IQ, it's also most probably you're the same one unemployed boomer who gets triggered whenever a new Rust thread is opened.

im a multimillionaire and i hold a phd in set theory and i made 50% of my money with C, again, dilate.

Attached: 1509929084515.jpg (662x602, 212K)

"i am a Jow Forums sperg and i have escaped my containment board"