Daily Rust Thread

What excuses will C fags find today?

Attached: rust.png (1200x1200, 56K)

Other urls found in this thread:

rust-embedded.github.io/book/
carllerche.github.io/mio/mio/index.html
github.com/tokio-rs/tokio
docs.rs/futures/0.2.0/futures/type.Poll.html
github.com/serde-rs/json/blob/master/README.md
twitter.com/NSFWRedditImage

Attached: output.png (500x562, 231K)

reminder that C is the most primitive language out there and the 'too dumb to understand C' argument does not apply in any case

Doesn't it only work properly on x86_64?

Should we be looking forward to Redox any time soon?

also on arm mcu's
rust-embedded.github.io/book/

>What excuses will C fags find today?
To not use Rust? C11 has concurrency, Rust doesn't.

To use C? Probably something like "reimplementing binary trees every time you use them will make you understand how computers *really* work."

Attached: 1546735970957.png (200x241, 40K)

C will never go away, lol. Just give up trying.

>he thinks it's related
cute, now head back to Jow Forums

>I don't need to understand things, let the computer do them for me!

But that's exactly what computers are for, lol.

Yes, certainly.

Next discussion: "unused ram is wasted ram".

i feel like the solution for all this mess was following the clang route, make a language for it and then if some features result in a better code it could be adopted into upstream and then the rest of languages could add that functionality by compiler parameter.

>he doesn't understand binary trees
I think it's time to go back to toying around with SICP or something.

Attached: pepe stop.png (446x435, 70K)

Rust has async/await, C doesn't

hey huurrr hurr, hehehe hur! hurr hurr how do I shot a web hurr
use std::sync::{Mutex, Arc};
use std::thread;

fn main() {
let counter = Arc::new(Mutex::new(0));
let mut handles = vec![];

for _ in 0..10 {
let counter = Arc::clone(&counter);
let handle = thread::spawn(move || {
let mut num = counter.lock().unwrap();

*num += 1;
});
handles.push(handle);
}

for handle in handles {
handle.join().unwrap();
}

println!("Result: {}", *counter.lock().unwrap());
}

Attached: 1544729016111.png (1098x1126, 492K)

C11 has atomics, Rust doesn't.

Attached: 2019-02-02-154709_677x347_scrot.png (677x347, 67K)

Whats with the amount of anti C lately? Is there a trsnnt convention in time?

Rust has generics, C doesn't

Just use a poll(2)-like loop. That's all you really need.
Does Rust even have proper support for anything like that?

Has Rust made anything of relative importance?

If not, shills should spend less time shilling and more time developing something of use

C is simplier asm, rust is not, end of the discussion.

Something like
carllerche.github.io/mio/mio/index.html
?

yes
github.com/tokio-rs/tokio
Unlike poll, it's cross platform too

Rav1e

docs.rs/futures/0.2.0/futures/type.Poll.html
What do you mean? Any language is simpler ask as they all (mostly) compile to machine codes

Attached: 1549532934006.png (1000x432, 165K)

did you have a stroke writing that?

Don't worry about the shills, just go on making stuff and let the shills get paid in peace

Oh shit, the Rust's evangelists are attacking again.

Nope, Redox is a toy OS/Kernel, nothing serious.

Run

>Not even in the standard library
What a fucking joke. Are you saying I'm going to need an external lib to do something simple like generate a random number too?

>69856386

>shifting goalposts

poll is not standard C library

>What do you mean?
simplier in the sense it maps more closely to the asm code than the rest of the languages
C has little to no overhead in function calls, no ownership, no GC, no object.
you manipulate pointers the same way you manipulate jumps in asm.
C is a "raw" language, you can manipulate the hardware as you want and you can interface it with higher-level tools.
I can't see rust stealing C market shares until the compiler is able to produce architecture-optimized code EVERY time we need it.

If you want rust safety and to produce the same asm, you need for example borrow-check, hot path predictions and to remove useless object bloat at compile time.
This is the bare minimum to achieve C efficency and code-generation predictability.

>it maps to asm
You don't need a language mapping to asm if it lets you inline asm itself. Standard C doesn't have asm inlining.

poll its one thing. Now, the necessity to take an external lib to do a simple rand(), its insane.

...

Rust is higher level in a sense that it has smart pointers, methods and such in std, but it has barely any overhead. It has no GC, no runtime and can run on bare metal. You can use raw pointer and low level if you need but you should put them behind safe interface(without undefined behaviour) for convince.

It's not ready yet.

I could see Rust as a viable C replacement if it wasn't so obsessed with abstracting away heap behavior. The subset of the standard library that can be used without an underlying OS (or implementations of allocators and threading, at a minimum) is miniscule.
It takes an excessive amount of work to make Rust work on bare metal, meanwhile I can run a makefile using arm-none-eabi-gcc the same way I'd run one for a native toolchain. I don't have to think about FFI in my C and assembly projects- everything just works. Meanwhile, in Rust I have to shove all my asm procedures in stupid wrappers to be able to use them. Cargo is convenient until you try to use it with an atypical toolchain, and rustc doesn't integrate very cleanly with any build system other than cargo.

This

>no runtime

Attached: brainlet.png (800x729, 48K)

>being pedantic
C has a runtime too

that's my point you dumb shit

>Are you saying I'm going to need an external lib to do something simple like generate a random number too?
Provided RNG is subject to constant improvement and new algorithms, this will always be the case for all programming languages. If you unironically use rand(3), please put big red disclaimers on your projects saying your shit is 20 years behind when it comes to safety.

Also, FYI anything in the (2) section isn't in the standard library.

False flags and bandwagon kids

>use std::x::y::z{f1, f2, ... fn};
gave me an anneurism, :: is too autistic for me
>fn
ok
>let (X) x = ...
dynamic typing is convenient but might lead to problems
>vec![]
>!
wtf desu senpai?
>&
>*
dereferencing is nice and all but isn't the whole point of rust safety nets and other faggot shit like that?
>move || { \n
>})}})}))}}})})}}))}}))}}})})});
drink bleach, this is fucking shit
>.unwrap()
Y?
>for x in X
nice
>n..k
nice


why does every new language look like ass? C, Java, Python, etc are all at least pleasant to look at. But Go, Rust? They look like some autistic child scribbled random shit on a wall for an hour.

Since when did C not have generics?

>fuckload of boilerplate and visual noise
>bizarre idiosyncrasies in the stdlib
>binding name shadowing
thank god Nim is getting a borrow checker

Attached: rust_syntax.jpg (640x427, 45K)

beginning

what's the advantage of inlining? i always just assembled them separately and linked it in. is the call instruction really that heavy?

Rust is C++ for brainlets
Ada is 100x better

>std::x::y::z{f1, f2, ... fn};
namespaces
>dynamic typing is convenient but might lead to problems
type inference, static
>wtf desu senpai?
macro
>dereferencing is nice and all but isn't the whole point of rust safety nets and other faggot shit like that?
Ye, but dereferencing was never the problem. Freeing aliased shit and nulls are problems.
>drink bleach, this is fucking shit
true, fucking closures
>Y?
Ignore posibility of failure. Kinda "unsafe" in the sense of crashes, but not in the memory safety way. To be responsible and shit you pattern match.
>Java pleasant to look at
I'll give you C any day, and python can go either way, but Java is just so fucking long winded.

>>what is assembly

Rust is most certainly more difficult to write than C++. The only people that say otherwise are the people that never used either of the languages.
And the only people that recommend Ada are the people that never have used Ada too.

I learned today that rust users have black boyfriends.

>boilerplate
where in that code do you think you saw boilerplate?

I want to learn rust. Is it going to be worth it when so many people tell me it's a toy language?

Best alternative to c is c++. Case closed

It is tho

You mean wife's black sons?

it's the language going forward for the mozilla browser and the firecracker micro vm and a bunch of other modern infrastructure projects and you don't think it's worth learning? Not even worth investigating to see what value add the language has?

baka

C is too easy. I want my job to consist of programming, not programming + some other, unrelated problem, like finance or databases.
With Rust, my whole job could be Rust.

Why do people say this? I am much more comfortable reading/writing Rust syntax than C++, the only time I'd say it's "harder" is when you're specifying lifetimes

It's harder because of lifetimes and ownership mechanics. But it only applies to newbies, once you learn how to write code in Rust way it's really comfortable.

Attached: 1549804838388.png (1081x578, 88K)

>dynamic typing is convenient but might lead to problems
Rust does not have dynamic typing. The only thing that approaches it is trait objects.

There is also that Any trait for full dynamic typing. But I've never seen anyone use it. There is just no use case for it.

>what is _Generic
Check mate atheist

>he had never hand-optimized SIMD to improve scheduling on each port
Shit's fucking crazy. Compiled language-fags will never understand.

Cfag here. Genuinely interested in trying rust. What advantages does it have over C. Also people keep trying to get me to learn go. I know nothing about these nu-languages.

Do not bother with Go, it's a managed language that can compete with Nodejs at best. This is not a systems programming languages.

>What advantages does Rust have over C
Lifetimes+ownership - it guarantees that you will have no data race, no null pointers, no invalid pointers, no double free etc
RAII by default
UTF-8 by default
Tagged unions
Methods, drop trait(destructors), traits, polymorphism without inheritance
Nice error handling without slow and dangerous exceptions
Hygienic macros
Compiler plugins
Standard, crossplatform build tool with dependency manager, no need for makefiles
Standard inline assembly
Standardized bare metal
Lambdas, closures
Robust and easy to implement iterators
Functional approach
Pattern matching
Destructuring
Typing that doesn't require explicit types 99% times because it can be deducted from usage.

Just check this out: github.com/serde-rs/json/blob/master/README.md
That json! macro, derives and stuff. I've never used more comfortable json support in any strongly typed language that this.

> I want my job to consist of debugging memory leaks, segfaults, double frees, memory corruption, out-of-bounds access and data races

>What advantages does it have over C.
I wouldn't really compare Rust to C, it's more like C++.

I'll give it a go then. I've got some side projects in C that haven't really gone anywhere. Main project is tensor flow in python, may try converting that to rust, it's only 200 lines.

Not really but who knows, Linux started as a toy kernel too.

.

Attached: 30_min_gay.gif (612x591, 161K)

rust is an alternative to c++. if you are looking for an alternative to c, try zig. one example on how its better than c is that it has defer keyword, which allows you to cleanup resources easily instead of using goto

> rust is an alternative to c++. if you are looking for an alternative to c, try zig
What does this even mean? All these languages are from the same niche, pretending they don't is a lazy way to avoid comparison. Both C++ and Rust are pretty good alternatives to C, which makes it look obsolete and primitive, because it is.

Rust sucks

>What does this even mean?
C is a very simple langauge, which provides fairly direct control over memory. Both C++ and Rust are much more complex, and generally handle memory behind significantly greater abstractions.

The level of control is the same - both C++ and Rust are non-GC languages, which incur no run-time performance cost. At the same time memory management (and resource management in general) in them is much simpler and less error-prone.
> C is a very simple language
I would argue it's not, considering the number of pitfalls you encounter - see Linus' ramblings about strict-aliasing.
But even if we call it so, we need to distinguish between being simple itself and being simple to use. 6502 assembly is a very simple(primitive) language, but it's hard to use. C is a more complex language, but it's easier to use than assembly. C++ and Rust are even more complex languages, but they're much easier to use properly (i.e. without introducing hard to catch errors) than C. With no noticeable increase in cost, I think the focus should be not on the simplicity of a tool itself, but on the simplicity of using it properly.

In other words, while hand tools are very simple by themselves, power tools are so much simpler to use for anything non-trivial.

>handle memory behind significantly greater abstractions.
Rust's Box is literally just a pointer. It automatically allocates memory on creation and frees on destruction, something you'd have to do anyway in C, which can easily lead to bugs. Same for smart pointers, they are minimalistic with no runtime overhead in comparison to C, but with much less pitfails.

>In other words, while hand tools are very simple by themselves, power tools are so much simpler to use for anything non-trivial.
That's a perfect analogy for what I was trying to say.

I meant "greater abstractions" from the programmer's perspective.

it is a popular language for blockchain projects. e.g One of the biggest Ethereum clients is in rust. And the related ecosystem.

holy fucking shit! this is Rust code? wtf
they even rewrote how For works lol

>automatically allocates memory
Dropped

For over iterators is supported in nearly every modern language.
Rust's switch(match) and enums are much more interesting.

*ahem*
int a = 1;

kek pun

Shit analogy. That's stack allocation, retard.

A better analogy would be a C function that allocates something, and returns a pointer to it, which by the way, Box::new literally is.

From what I've read, there are RAII tricks in C. And yes, it's as much a non-zero-cost-abstraction macro hell as it sounds.

Like strdup?

So?
Are you afraid of manual stack management? I thought C programmers can handle memory allocations.

fn main() {
let v = vec![1, 2];
v.iter().map(|&a| {
v.iter().map(|_| &a)
});
}

raii is fucking gay, you can achieve the same thing at the same cost with nothing more than a generic function

As a rust user I wholeheartedly agree with this.