This is what most people who complain about Rust rewrites don't get. It's not just about memory safety and some new language features. Rust simply did a lot of things right and is nice to work with. New developers actually join Rust projects while old tools written in C struggle to survive.
Yeah, I enjoyed when fish shell did their rewrite and people were arguing whether it makes sense technologically, like it's a mature codebase, so it's not likely to reduce the number of bugs and yadda yadda yadda.
None of this mattered, because fish is developed by a group of hobbyists. They didn't want to continue developing in C++, because it was a pain in the ass. And for sure, one of the reasons they wanted to switch to Rust is because it's new and exciting.
These reasons are perfectly valid, because they're volunteers. If they're not having fun, then they will just developing.
Look, undeniably some coding languages are miles better than others, but I don't think any of them would fall under my personal classification of what the word "fun" means...
Yeah, same. The fact I can chill the fuck out and basically not have to worry about an enormous class of serious, hard-to-spot bugs makes it a lot more fun for lower-level programming.
Like, yeah, I still need to worry about obstacles like other drivers, animals, etc., but it's a lot more fun driving on a road that isn't completely teeming with potholes and black ice.
Yup. I come from a mostly embedded C or C++ background with a constant 10% Python for assorted scripts. Rust feels pretty great, basically all the things I like about all of those languages with fewer of the annoyances. And cargo and clippy are fantastic. My biggest annoyance is remembering which of the approximately 213 Result/Option chain handlers I should use in a given situation.
Thanks for naming my biggest problem with writing rust code. Every crate has it's own particular Result chain, doesn't it. To the point we have anyhow and eyre to help with this mess.
My current solution is usually to just make a bunch of stupid match statements and fix whatever clippy complains about. Then if any remain be sure to “accidentally“ tag the friendliest rust expert I know on the PR and see if they say anything.
edit:
They usually say something like, “you could replace those matches with a and_else, map_err, unwrap_or, and_then? and a filter_map.”
It was fun when knowing programming was almost a superpower that you had to learn by reading lots of books, etc. Now a computer can do much of the job. The computers are even solving long-open Erdos problems. We're all just mediocre meatbags.
C is firmly in the "not fun" camp with PHP, JavaScript and Bash. I'd say even assembly is more fun, in a puzzle challenge sort of way.
The most fun language I've used is QuakeC, because the only thing you can do with it is write Quake mods. It was a pretty neat language too from what I remember. It even automatically detected infinite loops!
We all have different definitions of "fun." C won't surprise you when you try to add a string and an array; it'll do exactly what you told it to do, which then translates to assembly code with a very predictable pattern.
On a different note, bash scripting is well-defined and mostly consists of understanding that common tools can be chained together to provide useful output; combined with the very well-defined string operations, I've found that bash scripts can address over 99% of cases people try to throw sed and awk at. It's almost surprisingly powerful.
Lol... I'm sure there's a meme or graph for where you are in learning C to believe this.
then translates to assembly code with a very predictable pattern.
Even this is a stretch. Modern C compilers can do some wild transformations. I assume you've seen the classic one where UB makes it jump to a function that you never actually call.
bash scripting is well-defined
Yeah I mean Bash's problem isn't that it's poorly defined - it's that the definition is awful!
GKH is to me the second most important guy in the Linux world today next to LT, and he definitely deserves more credit for his efforts maintaining the kernel. Maybe Greg doesn't get as much press attention because he doesn't make as profound statments as Linus tends to.
I'm actually looking into learning zig. The deal is that I don't really have an use case for it. My work vastly prioritizes development speed over actually fast programs
Arguably Zig has a simpler approach to memory management (which can also lead to more errors, arguably) which makes the transition from
C somewhat easier. Downside is that the language is still under heavy development and you definitely have to be up for the ride.
Agreed that it makes the transition from C easier, but I'd also say it makes the transition from C more pointless. I don't really know that much about Zig but from what I've heard, I don't really get the benefits - if you want a fast systems-level language without guard rails, why aren't you just writing C (or C++, if that's your thing)?
Zig is way better than C in many other respects, so if you want a modern sane language and you're either a Rust luddite or working on a project where memory safety isn't that important, it might be attractive.
Like, if the choice is C or Zig, then Zig is pretty much a no-brainer (or it will be when it hits 1.0). It just fixes so many insane things about C that have been broken for literal decades.
working on a project where memory safety isn’t that important
I can't really imagine anything where this is not the case, unless you're doing like... I dunno, small scripts for personal use or something? But why would you use Zig or C or even Rust for that, just do Python or even bash at that point? Python is memory safe and perfectly suitable for very small programs where static analysis gives little benefit.
There are definitely some cases where memory safety isn't especially important:
Single player games
Apps that don't process external data (e.g. a simple calculator).
Lots of things running on microcontrollers, where the form of input could never possibly cause any security issues. E.g. a motor controller or a basic syringe pump or a (non-smart) washing machine or something.
Tests, e.g. I've considered writing RISC-V tests in Zig. They're traditionally written in C or assembly.
In cases like those, memory unsafety mainly leads to non-security bugs and annoying debugging sessions. But I wouldn't say it's as much of a deal breaker compared to e.g. writing a video codec or font renderer or web browser or DNS server or whatever.
I still think Rust is a better choice than Zig in most cases anyway, even ignoring memory safety. But in these cases it's at least a defensible choice.
zig does have guard rails, they're just different approaches. zig defaults to optional types where null must be handled. and memory safety is checked through unit testing and exposing debugger memory allocators that check for different memory corruption bugs.
rust takes a shift left approach where all declarations drive safety whereas zig takes a more laid back shift right where it's expected you'll have written tests. rust will force all developers to conform to produce good code where zig requires a bit more though, i mean every dev writes test cases right?
Saying that "memory safety is checked by tests" is basically saying "memory safety is not checked". Yes, you can write tests. How do you know the tests cover all cases? How do you know the tests aren't buggy?
Also, what about memory safety across threads? Are you testing multi-threaded scenarios? Are you ensuring you have no data races?
I also don't understand how this is an argument for Zig over C. You can also test memory safety of your C code via various means, but it's never a guarantee. Zig is the same. So again, it seems a bit more pointless to go from C to Zig. Going from C to Rust brings actual tangible guarantees of memory safety (outside of any unsafe usage, obviously).
in c code you will see malloc, alloc, free w/e scattered through the code base, most static tools lack because they don't control the memory and just analyze address spaces or do static code analysis. they look top down and try to catch errors.
zig's design forces you to create a memory allocator before any object initializations (alloc/free) and is typically constructed at the top level and passed through to functions. this allows you to swap implementation easily and use the allocator to claim memory or return an error to the caller if it can't.
you can do some simple static allocator, general purpose allocator (can grow memory space as you allocate more objects) or in this case to test memory safety a debug allocator which you use in your tests. This moves the memory inspection inside of where your program allocates memory. this is more of an inside out approach where the analysis is produced by controlling the memory allocations and frees through a standard interface.
@SorteKanin@kewjo Fuzzing! Zig is working on an integrated fuzzer that will work seamlessly with the testing system.
And for those cases you don't catch, there's ReleaseSafe which have runtime checks to prevent illegal behavior.
Zig removes a lot of the footguns of C and also provides a lot of the tools you'll need anyway built-in. The debug allocator does leak-checking. You have to unwrap your nulls. There is compile-time duck-typing so generic data structures don't have to rely on void pointers. Also no separate preprocessor language.
i like the way zig interfaces with c. even though it's a "newer" (not 1.0) language you can import native c which means you have access to already really fast libraries. the build script and macros are the same language you write your code. the best part is you can interface with normal code (not unsafe) and can create boundaries where sure in the c side you can't enforce memory safety, but where you interface you can convert into memory safe types.
to talk more about memory safety i think rust does a great job, however there are some inconsistentcies where a lot of memory allocations can throw out of memory errors that will crash the app whereas zig you could gracefully handle it. this is probably more important for lower level things like kernel than an app where not recovering means everything goes down.
honestly i wish there was an opt in borrow checker as some patterns are easily expressed, but honestly i would opt out for async code as it just gets verbosely over-declarative imo. also the new async in zig is really really cool.
You can trivially use C libraries in Rust, or any system language that supports the C ABI for that matter, and this includes many hobbyist languages. Zig is not special.
No Zig definitely is special. You don't have to do any extra busy work to call C code - you can pretty much just #include the header and that's that. It's similar to calling C from C++.
In any other languages - including Rust - you have to do some work declaring functions, wrapping them and so on. It's not hard but it definitely is a non-zero amount of tedious work (especially before AI). There's absolutely no way you could describe it as "trivial", unless someone else has already done that work for you.
But I don't think it is a significant Zig advantage really. When I'm writing Rust, it's extremely rare that I want to call any C code that someone else hasn't already done the tedious wrapping for.
zig is a bit special in this regard though as it is a c compiler not just using ffi. this means you could swap out gcc, make autotools etc and drop in zig with a build.zig. mostly useful if you want to migrate large code bases as you can incrementally port the parts you want.
if you're picking it up for a new project then yeah this probably doesn't impact you much.
Beyond what amounts to a packaging difference, what does that even mean?
How do you think zero-cost C ABI support (including fully working cross-lang LTO) works in lang implementations that have that? And how do you think that's different from what Zig gives you?
Note: “Zero-cost” means zero runtime cost, not zero compile cost. The compiler does real work — monomorphization and inlining — to make abstractions disappear, and that work shows up as longer build times. See Reducing Compile Time for the trade-off.
most of the benefits come from a shared code base, one compiler (which is insanely fast with incremental rebuilds and can watch files for changes) means changes in the c code reflect in a single build step within seconds. the benefit is primarily for the developer as the compiler output should be relatively similar.
rust does a great job, however there are some inconsistentcies where a lot of memory allocations can throw out of memory errors that will crash the app
That is not an "inconsistency". Crashing the application when you run out of memory is honestly in almost all cases the correct call and crashing is memory safe. Most applications can do absolutely nothing when running out of memory. "Handling" OOM is extremely complicated and most applications simply cannot handle it in any way.
Of course low level stuff needs to sometimes actually handle this, but it's mostly an operating system thing. And Rust still allows you that control, it's just not the default behavior of the collections and such in the standard library, because again, it almost never makes sense to try to handle OOM. But if you really need that behavior, you can have it.
Isn't also half the point behind Rust the ability to evade the GPL and make Linux more vulnerable to takeover by corporate? Last I checked Ubuntu is replacing some GNU stuff like coreutils with Rust.
Do you seriously think that's how IP law works? If you weren't able to write GPL Rust code, Rust would not be free software. That would require the Rust project to issue software licences to programmers that stipulate that you must not create GPL-licensed software using Rust.
Rust is free and open-source, like most programming languages. That means you are allowed to make whatever software you want with it, including GPL software. There's nothing stipulating that you can't...
You can write GPL rust code, you can also write non-gpl rust code. Gnu coreutils are gpl, if I choose to write functionality compatible with coreutils from scratch in rust I can relicense that as I please (ie not GPL) OP is postulating the driver behind rust rewrites is not for the language features but to allow coreutils functionality to be relicensed as closed source software.
OP is postulating the driver behind rust rewrites is not for the language features but to allow coreutils functionality to be relicensed as closed source software.
And that postulation is extra laughable because non-GPL coreutils implementations always existed. And by always, I mean they actually predate the GNU implementation itself (which was a originally a "rewrite" btw 😉).
And yes, they don't target GNU compatibility, but some of them are perfectly serviceable as is (e.g. the freebsd ones), and adding GNU compat to them would have been infinitely easier than starting a Rust implementation from scratch anyway.
Another laughable aspect regarding the coreutils/uutils case in particular is that uutils didn't even start as a corpo-driven or corpo-backed project. It was literally a Mozilla employee having fun in his free time, especially during Covid, and community contributions in the same vein. Rewrites of non-GPL projects (e.g. sudo) were ironically much better backed.
From my experience here and elsewhere, the people who make such stipulations don't even know which licenses the core packages in their own systems adopt. Many of them don't even know what these licenses' provisions precisely entail. They just perpetuate some retarded circlejerk probably started by some clueless+malicious e-celeb that goes like:
linux distro -> C -> gpl -> not corpo -> good
rust -> not gpl -> corpo -> bad
I mean, you can create a GPL fork of the Rust coreutils if you so please. Or you could do a rewrite in any programming language of your choice and license permissively.
In any case, I profoundly cannot bring myself to care about the fact that you can legally create a proprietary fork of permissively licensed FOSS. I don't think it's right to impose any restrictions on what people can do with software/code, which of course conflicts with the fact that other people can take your code and restrict what other people can do with it. So choosing between copyleft and permissive licensing is a balancing act of that contradiction. I don't think it's wrong to end up on the side of permissive licensing.
Linux kernel code is GPLv2 licensed irrespective of language.
There are thousands of (A)GPL rust crates/libraries out there.
The majority of crates are indeed still liberally licensed, but so are most new projects from the last decade, irrespective of the choice of implementation language.
Rust project rewrites don't exclusively replace GPL projects, because there aren't actually that many core GPL software packages to replace. Neither sudo nor zlib are GPL software, just to give two examples. A lot of implemented-in-C core packages in your system right now are actually liberally licensed.
And just for the sake of accuracy, the supposed threat of liberal vs. copyleft is not about the so called corporate take over or control. It's about the ability to have proprietary forks/spin-offs. Plenty of GPL projects are corporate-controlled and always have been (see what projects Red Hat maintains).
You should try properly educating yourself on matters, instead of just taking whatever bullshit random often-clueless if not also malicious e-celebs spout at face value, or wherever you're getting these retarded theories from.
61 Comments
ExLisper@lemmy.curiana.net · 57 pts · 63d
This is what most people who complain about Rust rewrites don't get. It's not just about memory safety and some new language features. Rust simply did a lot of things right and is nice to work with. New developers actually join Rust projects while old tools written in C struggle to survive.
Ephera@lemmy.ml · 16 pts · 62d
Yeah, I enjoyed when fish shell did their rewrite and people were arguing whether it makes sense technologically, like it's a mature codebase, so it's not likely to reduce the number of bugs and yadda yadda yadda.
None of this mattered, because fish is developed by a group of hobbyists. They didn't want to continue developing in C++, because it was a pain in the ass. And for sure, one of the reasons they wanted to switch to Rust is because it's new and exciting.
These reasons are perfectly valid, because they're volunteers. If they're not having fun, then they will just developing.
abc@suppo.fi · 9 pts · 61d
Yup. I'm an old fart who learned C as my first real language. Rust is just fun.
Angryhumanoid@fedinsfw.app · 26 pts · 63d
Look, undeniably some coding languages are miles better than others, but I don't think any of them would fall under my personal classification of what the word "fun" means...
_hovi_@lemmy.world · 52 pts · 63d
Different strokes I guess. Personally, I do have a good time writing Rust and fun feels like the right word
TheTechnician27@lemmy.world · 24 pts · 63d
Yeah, same. The fact I can chill the fuck out and basically not have to worry about an enormous class of serious, hard-to-spot bugs makes it a lot more fun for lower-level programming.
Like, yeah, I still need to worry about obstacles like other drivers, animals, etc., but it's a lot more fun driving on a road that isn't completely teeming with potholes and black ice.
BartyDeCanter@piefed.social · 12 pts · 63d
Yup. I come from a mostly embedded C or C++ background with a constant 10% Python for assorted scripts. Rust feels pretty great, basically all the things I like about all of those languages with fewer of the annoyances. And cargo and clippy are fantastic. My biggest annoyance is remembering which of the approximately 213 Result/Option chain handlers I should use in a given situation.
magikmw@piefed.social · 3 pts · 63d
Thanks for naming my biggest problem with writing rust code. Every crate has it's own particular Result chain, doesn't it. To the point we have anyhow and eyre to help with this mess.
BartyDeCanter@piefed.social · 4 pts · 62d
My current solution is usually to just make a bunch of stupid match statements and fix whatever clippy complains about. Then if any remain be sure to “accidentally“ tag the friendliest rust expert I know on the PR and see if they say anything.
edit: They usually say something like, “you could replace those matches with a and_else, map_err, unwrap_or, and_then? and a filter_map.”
badmin@lemmy.today · 14 pts · 63d
Fun is when you're allowed to achieve what you want to achieve with less bullshit to worry about.
Or in more respectable technical terms, when you're allowed to focus on core logic above everything else.
eah@programming.dev · 0 pts · 63d
It was fun when knowing programming was almost a superpower that you had to learn by reading lots of books, etc. Now a computer can do much of the job. The computers are even solving long-open Erdos problems. We're all just mediocre meatbags.
SpaceNoodle@lemmy.world · -1 pts · 63d
Except for C
FizzyOrange@programming.dev · 0 pts · 61d
C is firmly in the "not fun" camp with PHP, JavaScript and Bash. I'd say even assembly is more fun, in a puzzle challenge sort of way.
The most fun language I've used is QuakeC, because the only thing you can do with it is write Quake mods. It was a pretty neat language too from what I remember. It even automatically detected infinite loops!
SpaceNoodle@lemmy.world · 1 pts · 61d
We all have different definitions of "fun." C won't surprise you when you try to add a string and an array; it'll do exactly what you told it to do, which then translates to assembly code with a very predictable pattern.
On a different note, bash scripting is well-defined and mostly consists of understanding that common tools can be chained together to provide useful output; combined with the very well-defined string operations, I've found that bash scripts can address over 99% of cases people try to throw sed and awk at. It's almost surprisingly powerful.
JavaScript is just a hot fucking mess.
FizzyOrange@programming.dev · 1 pts · 61d
Lol... I'm sure there's a meme or graph for where you are in learning C to believe this.
Even this is a stretch. Modern C compilers can do some wild transformations. I assume you've seen the classic one where UB makes it jump to a function that you never actually call.
Yeah I mean Bash's problem isn't that it's poorly defined - it's that the definition is awful!
SpaceNoodle@lemmy.world · 0 pts · 60d
I've been programming for 35 years, and professionally for over 20, so I'm pretty far along the curve, thanks.
FizzyOrange@programming.dev · -1 pts · 60d
Well I guess not everyone learns at the same rate.
SpaceNoodle@lemmy.world · -2 pts · 60d
Don't worry, you might make it to the start of the bell curve one day.
BB_C@programming.dev · 1 pts · 60d
the portable assembly meme
🤣🤣🤣🤣🤣🤣🤣
Rentlar@lemmy.ca · 18 pts · 63d
GKH is to me the second most important guy in the Linux world today next to LT, and he definitely deserves more credit for his efforts maintaining the kernel. Maybe Greg doesn't get as much press attention because he doesn't make as profound statments as Linus tends to.
Gonzako@lemmy.world · 14 pts · 63d
I'm actually looking into learning zig. The deal is that I don't really have an use case for it. My work vastly prioritizes development speed over actually fast programs
SorteKanin@feddit.dk · 7 pts · 63d
Why are you considering Zig instead of Rust? Or is it in addition?
Gonzako@lemmy.world · 23 pts · 63d
Cooler name
SorteKanin@feddit.dk · 16 pts · 63d
Can't argue with that
communism@lemmy.ml · 7 pts · 62d
But consider, Rust being named what it is led to the project name ffmpreg
sunbeam60@feddit.uk · 5 pts · 62d
Arguably Zig has a simpler approach to memory management (which can also lead to more errors, arguably) which makes the transition from C somewhat easier. Downside is that the language is still under heavy development and you definitely have to be up for the ride.
SorteKanin@feddit.dk · 5 pts · 62d
Agreed that it makes the transition from C easier, but I'd also say it makes the transition from C more pointless. I don't really know that much about Zig but from what I've heard, I don't really get the benefits - if you want a fast systems-level language without guard rails, why aren't you just writing C (or C++, if that's your thing)?
FizzyOrange@programming.dev · 4 pts · 61d
Zig is way better than C in many other respects, so if you want a modern sane language and you're either a Rust luddite or working on a project where memory safety isn't that important, it might be attractive.
Like, if the choice is C or Zig, then Zig is pretty much a no-brainer (or it will be when it hits 1.0). It just fixes so many insane things about C that have been broken for literal decades.
SorteKanin@feddit.dk · 2 pts · 61d
I can't really imagine anything where this is not the case, unless you're doing like... I dunno, small scripts for personal use or something? But why would you use Zig or C or even Rust for that, just do Python or even bash at that point? Python is memory safe and perfectly suitable for very small programs where static analysis gives little benefit.
FizzyOrange@programming.dev · 2 pts · 61d
There are definitely some cases where memory safety isn't especially important:
In cases like those, memory unsafety mainly leads to non-security bugs and annoying debugging sessions. But I wouldn't say it's as much of a deal breaker compared to e.g. writing a video codec or font renderer or web browser or DNS server or whatever.
I still think Rust is a better choice than Zig in most cases anyway, even ignoring memory safety. But in these cases it's at least a defensible choice.
kewjo@lemmy.world · 1 pts · 61d
zig does have guard rails, they're just different approaches. zig defaults to optional types where null must be handled. and memory safety is checked through unit testing and exposing debugger memory allocators that check for different memory corruption bugs.
rust takes a shift left approach where all declarations drive safety whereas zig takes a more laid back shift right where it's expected you'll have written tests. rust will force all developers to conform to produce good code where zig requires a bit more though, i mean every dev writes test cases right?
BB_C@programming.dev · 4 pts · 61d
🤣 🤣🤣🤣🤣🤣
SorteKanin@feddit.dk · 1 pts · 61d
Saying that "memory safety is checked by tests" is basically saying "memory safety is not checked". Yes, you can write tests. How do you know the tests cover all cases? How do you know the tests aren't buggy?
Also, what about memory safety across threads? Are you testing multi-threaded scenarios? Are you ensuring you have no data races?
I also don't understand how this is an argument for Zig over C. You can also test memory safety of your C code via various means, but it's never a guarantee. Zig is the same. So again, it seems a bit more pointless to go from C to Zig. Going from C to Rust brings actual tangible guarantees of memory safety (outside of any
unsafeusage, obviously).kewjo@lemmy.world · 2 pts · 61d
in c code you will see malloc, alloc, free w/e scattered through the code base, most static tools lack because they don't control the memory and just analyze address spaces or do static code analysis. they look top down and try to catch errors.
zig's design forces you to create a memory allocator before any object initializations (alloc/free) and is typically constructed at the top level and passed through to functions. this allows you to swap implementation easily and use the allocator to claim memory or return an error to the caller if it can't.
you can do some simple static allocator, general purpose allocator (can grow memory space as you allocate more objects) or in this case to test memory safety a debug allocator which you use in your tests. This moves the memory inspection inside of where your program allocates memory. this is more of an inside out approach where the analysis is produced by controlling the memory allocations and frees through a standard interface.
liberty@mathstodon.xyz · 2 pts · 61d
@SorteKanin @kewjo Fuzzing! Zig is working on an integrated fuzzer that will work seamlessly with the testing system.
And for those cases you don't catch, there's ReleaseSafe which have runtime checks to prevent illegal behavior.
Zig removes a lot of the footguns of C and also provides a lot of the tools you'll need anyway built-in. The debug allocator does leak-checking. You have to unwrap your nulls. There is compile-time duck-typing so generic data structures don't have to rely on void pointers. Also no separate preprocessor language.
SorteKanin@feddit.dk · 1 pts · 61d
To prevent some illegal behaviour. Again, I'm not an expert on Zig, but as far as I understand, even Release"Safe" is not actually memory safe.
Hupf@feddit.org · 4 pts · 63d
For great justice
Zink@programming.dev · 5 pts · 63d
Someone set up us the Rust?
kewjo@lemmy.world · 3 pts · 61d
i like the way zig interfaces with c. even though it's a "newer" (not 1.0) language you can import native c which means you have access to already really fast libraries. the build script and macros are the same language you write your code. the best part is you can interface with normal code (not unsafe) and can create boundaries where sure in the c side you can't enforce memory safety, but where you interface you can convert into memory safe types.
to talk more about memory safety i think rust does a great job, however there are some inconsistentcies where a lot of memory allocations can throw out of memory errors that will crash the app whereas zig you could gracefully handle it. this is probably more important for lower level things like kernel than an app where not recovering means everything goes down.
honestly i wish there was an opt in borrow checker as some patterns are easily expressed, but honestly i would opt out for async code as it just gets verbosely over-declarative imo. also the new async in zig is really really cool.
BB_C@programming.dev · 2 pts · 61d
You can trivially use C libraries in Rust, or any system language that supports the C ABI for that matter, and this includes many hobbyist languages. Zig is not special.
FizzyOrange@programming.dev · 3 pts · 61d
No Zig definitely is special. You don't have to do any extra busy work to call C code - you can pretty much just
#includethe header and that's that. It's similar to calling C from C++.In any other languages - including Rust - you have to do some work declaring functions, wrapping them and so on. It's not hard but it definitely is a non-zero amount of tedious work (especially before AI). There's absolutely no way you could describe it as "trivial", unless someone else has already done that work for you.
But I don't think it is a significant Zig advantage really. When I'm writing Rust, it's extremely rare that I want to call any C code that someone else hasn't already done the tedious wrapping for.
BB_C@programming.dev · 1 pts · 61d
You know
bindgenexists, right?FizzyOrange@programming.dev · 1 pts · 61d
Yes. It's not as easy and reliable as Zig.
kewjo@lemmy.world · 1 pts · 61d
zig is a bit special in this regard though as it is a c compiler not just using ffi. this means you could swap out gcc, make autotools etc and drop in zig with a build.zig. mostly useful if you want to migrate large code bases as you can incrementally port the parts you want.
if you're picking it up for a new project then yeah this probably doesn't impact you much.
BB_C@programming.dev · 1 pts · 61d
Beyond what amounts to a packaging difference, what does that even mean?
How do you think zero-cost C ABI support (including fully working cross-lang LTO) works in lang implementations that have that? And how do you think that's different from what Zig gives you?
kewjo@lemmy.world · 1 pts · 61d
from rust docs:
most of the benefits come from a shared code base, one compiler (which is insanely fast with incremental rebuilds and can watch files for changes) means changes in the c code reflect in a single build step within seconds. the benefit is primarily for the developer as the compiler output should be relatively similar.
BB_C@programming.dev · -1 pts · 61d
That has nothing to do with what we were talking about. And in any case:
Needs qualification vs. other languages for binaries with comparable runtime performance.
(Hint: you will be surprised.)
Not special or unique.
Not only not special, but literally exists in all workable build tools.
bindgen+build.rsis the Rust version of this.SorteKanin@feddit.dk · 2 pts · 61d
That is not an "inconsistency". Crashing the application when you run out of memory is honestly in almost all cases the correct call and crashing is memory safe. Most applications can do absolutely nothing when running out of memory. "Handling" OOM is extremely complicated and most applications simply cannot handle it in any way.
Of course low level stuff needs to sometimes actually handle this, but it's mostly an operating system thing. And Rust still allows you that control, it's just not the default behavior of the collections and such in the standard library, because again, it almost never makes sense to try to handle OOM. But if you really need that behavior, you can have it.
mrbn@lemmy.ca · 6 pts · 62d
To learn rust, I just started writing all my personal projects in rust. I started with REST apis and basic CLIs.
Marija_@programming.dev · 11 pts · 63d
Memory safety is hard to ignore.
veniasilente@lemmy.dbzer0.com · -31 pts · 63d
Isn't also half the point behind Rust the ability to evade the GPL and make Linux more vulnerable to takeover by corporate? Last I checked Ubuntu is replacing some GNU stuff like coreutils with Rust.
terabyterex@lemmy.world · 42 pts · 63d
are you claiming that a program written in rust evades thr gpl? thats not a thing.
or...
are you saying , things are being rewritten (regardless of language) with a different license. scary but not a rust thing.
veniasilente@lemmy.dbzer0.com · 6 pts · 63d
The second.
communism@lemmy.ml · 3 pts · 62d
Do you seriously think that's how IP law works? If you weren't able to write GPL Rust code, Rust would not be free software. That would require the Rust project to issue software licences to programmers that stipulate that you must not create GPL-licensed software using Rust.
Rust is free and open-source, like most programming languages. That means you are allowed to make whatever software you want with it, including GPL software. There's nothing stipulating that you can't...
BeardedGingerWonder@feddit.uk · 1 pts · 62d
You can write GPL rust code, you can also write non-gpl rust code. Gnu coreutils are gpl, if I choose to write functionality compatible with coreutils from scratch in rust I can relicense that as I please (ie not GPL) OP is postulating the driver behind rust rewrites is not for the language features but to allow coreutils functionality to be relicensed as closed source software.
ISO@lemmy.zip · 2 pts · 62d
And that postulation is extra laughable because non-GPL coreutils implementations always existed. And by always, I mean they actually predate the GNU implementation itself (which was a originally a "rewrite" btw 😉).
And yes, they don't target GNU compatibility, but some of them are perfectly serviceable as is (e.g. the freebsd ones), and adding GNU compat to them would have been infinitely easier than starting a Rust implementation from scratch anyway.
Another laughable aspect regarding the coreutils/uutils case in particular is that uutils didn't even start as a corpo-driven or corpo-backed project. It was literally a Mozilla employee having fun in his free time, especially during Covid, and community contributions in the same vein. Rewrites of non-GPL projects (e.g. sudo) were ironically much better backed.
From my experience here and elsewhere, the people who make such stipulations don't even know which licenses the core packages in their own systems adopt. Many of them don't even know what these licenses' provisions precisely entail. They just perpetuate some retarded circlejerk probably started by some clueless+malicious e-celeb that goes like:
linux distro -> C -> gpl -> not corpo -> good
rust -> not gpl -> corpo -> bad
communism@lemmy.ml · 2 pts · 61d
I mean, you can create a GPL fork of the Rust coreutils if you so please. Or you could do a rewrite in any programming language of your choice and license permissively.
In any case, I profoundly cannot bring myself to care about the fact that you can legally create a proprietary fork of permissively licensed FOSS. I don't think it's right to impose any restrictions on what people can do with software/code, which of course conflicts with the fact that other people can take your code and restrict what other people can do with it. So choosing between copyleft and permissive licensing is a balancing act of that contradiction. I don't think it's wrong to end up on the side of permissive licensing.
ISO@lemmy.zip · 32 pts · 63d
You should try properly educating yourself on matters, instead of just taking whatever bullshit random often-clueless if not also malicious e-celebs spout at face value, or wherever you're getting these retarded theories from.
terabyterex@lemmy.world · 3 pts · 63d
Miaou@jlai.lu · 15 pts · 63d
What does this have to do with Linux?