I usually use c for systems programming but rust comes with so many convenient shit that I can't help but pick it everytime I need to write a tui or cli tool or driver or whatever.
I've been using it for months I tried to force myself to write in c but I couldn't. It was too cumbersome and my skills had atrophied from using the retardation of rust
The borrow checker is a cruel mistress, but it does work. Forget about life times they are too big brained for me.
Lifetimes hurt my brain, ugly syntax doesn't help either
the one thing I hate about Rust is the lifetime syntax, not sure how I'd do it instead though
Don't use lifetimes unless you really have to
You don't need to use lifetimes for most things. Cloning is fine.
The syntax isn't ugly, you're just tasteless (and too used to other languages)
Rustsisters, I'm about to start using it (and HRT), is visual studio code really the best IDE to use?
I use vim with rust analyzer and it's perfect.
Why the fuck would you force yourself to write in C if you know Rust?
The only reason to write in C is if you're too lazy to learn Rust, or you're in anem environment where it's not an option, like some embedded or legacy kernel support.
I'm in a company where the only language for our hardware is C. But somebody started Rust support two years ago, I'm gonna pick the project back up. You can be sure the moment I have it, I'm not touching a line of C anymore.
>t.
not an argument
ACK-poodle
>Wallace, 54 from Birmingham trooned out
bro are they even trying hahahah
Isn't Rust embedded still a pain/not feasible?
NTA and I haven't personally used it for embedded but as far as I know it's mixed. Not every architecture/platform is supported by Rust, and these that are aren't 100% guaranteed to work(ie they don't automatically run tests on new compiler versions). And I heard there is some very unsafe fuckery with handling interrupts. But in general I heard mixed opinions, some people loved it some hated. You should probably look into the embedded book and check it for yourself.
https://docs.rust-embedded.org/book/intro/index.html
my only gripe with rust is that it's compiler sucks ass and the output is bloated so can't really use it in something like arm cortex m, for anything above embedded side though it beats everything for sure
GCC support for Rust when
Didn't GCC added limited Rust support few months ago? They are missing some features like borrow checker but basic compilation should work IIRC.
Implementing something that complex is going to take time.
Rust frontend, GCC backend: https://blog.antoyo.xyz/rustc_codegen_gcc-progress-report-22
GCC frontend for rust: https://rust-gcc.github.io/2023/04/24/gccrs-and-gcc13-release.html
no variadic functions
it's supported for C ABI
There should be an RFC out right now for implementing variadic generics, like C++. Variadic functions like the printf family of functions in C were a mistake, however.
>Variadic functions like the printf family of functions in C were a mistake, however.
?
Correct.
https://cwe.mitre.org/data/definitions/134.html
Zig doesn't have this issue. The format string has to be known at compile time.
Well yeah. Zig has comptime. Basically a super powerful unified system for macros, generics, and constexprs. It's Zig's one big killer feature, and sadly the one thing Zig fans don't play up more often. Still, Rust does the same thing with proc macros.
No, they're not. There's plenty of better approaches developed by other languages that should be used. But if you have a singular compiled function that can reach arbitrarily down into the call stack based on a user supplied parameter (as we had with C's va_args), you have a recipe for memory corruption.
>There's plenty of better approaches developed by other languages that should be used.
Like what? They exist everywhere, and they won't overflow your buffer if you use JavaGolang or whatever other GC'd language.
>and they won't overflow your buffer if you use JavaGolang or whatever other GC'd language.
The solution used in Java and Go is to make variable arguments a syntactic sugar for passing an array as an argument (and that array has its length info embedded in it). If you wanted to do the same in Rust... you could just pass an array. Or you could use the fucking format macro which is literally just building a fucking parameter array for you.
Meanwhile C's problem has NOTHING to do with GC. You could give C a GC, and its style of variadic functions would still be inherently insecure. C is not doing syntactic sugar. C is pushing an arbitrary number of parameters on the stack. Variadic functions in C do not know how many parameters they have. They just know how to read the next parameter. And that allows an attacker who is able to supply a format string to peek and poke at arbitrary locations in memory.
Why not c++?
C++ suffers from the C baggage and it prevents C++ from having good defaults i.e. not move by default, implicit conversions etc
The C "baggage" is the only part of C++ that is actually good. Nobody would have ever bothered with C++ otherwise.
>The C "baggage" is the only part of C++ that is actually good
Not a single thing is good about C baggage. C++ would not evolve into what it is if the C baggage was any good.
> Nobody would have ever bothered with C++ otherwise.
People back in the day were too naive and fell for the "C++ is a C superset" meme.
At the end of the day C++ now is a horrible kitchen sink of a language with zero vision and coherence. It wants to be a Rust-like but also has to remain compatible with C idioms. Do you not see its struggle?
I don't think C++ being somewhat C compatible is not the reason its a terrible kitchen sink mess. What features of C do you think are causing C++ real issues?
Copy by default instead of move for example.
Plus the nonsensical implicit conversion garbage which allows a function pointer to be treated as a bool. What a stupid idea.
> Copy by default
C does not have objects. It is not meaningful to move a primitive or struct.
Implicit conversion of pointers to bool would have no effect on further development c++. You might not like it, but it in no way complicates or limits the language.
All languages have objects. Any instance of a struct is an object.
What does it mean though to move a struct. Moving is only meaningful when you have destructors.
Moving in C just means making a shallow copy.
I am a nocoder. I am immune to rust tranny propaganda.
Use Zig
OP here, this is me btw
cute
Tranny
larp
NTA but zig is not an option until it reaches v1.
Doesn't change the fact that variadic functions are ok.
wake me up when it has guaranteed consteval
overrated.
How do scala users find libraries? For example if I want to find a library for C# or F#, I search for dotnet X library/wrapper. How do you do it with Scala/Clojure?
Sorry wrong thread
Scala and Clojure can use Java libraries just like how F# uses C# libraries.
Have the problems here been addressed yet?
https://queue.acm.org/detail.cfm?id=3212479
This is as much a criticism of C as it is of hardware vendors. And honestly, it's not a very strong criticism. The abstract machine presented by C is pretty damn generic and not that heavily tied to the PDP-11. There's a reason it was easily ported to other architectures. And making hardware that is optimized for running C code makes sense when so many operating systems and language interpreters are written in C. And many other languages use compiler backends designed to compile C, but which are portable to other front ends.
Just use Zig you homosexual