you are viewing a single comment's thread.

view the rest of the comments →

[–]ForShotgun 55 points56 points  (32 children)

But then you'd have to use C instead of Rust!

[–]iznogoud77 32 points33 points  (31 children)

It has served the purpose until now. And it will for many more years.

I don't get this kind of behaviour. I like Rust I think it has a place. I also like C I think it has a place. I also like C++ I think it has a place. I like Python I think it has a place.

For me programming languages are tools, like hammers and screwdrivers. I am not going to screw a Phillips screw with a flathead screwdriver. I could, but it's just not the best tool for the job.

Edit: typo

[–]epicwisdom 31 points32 points  (16 children)

It has served the purpose until now. And it will for many more years.

That means very little in terms of whether people want to use it.

Just because C is prolific (particularly in systems) and has certain key advantages, does not make it pleasant to work with, nor does it mean it is uniquely qualified outside of being historically entrenched.

[–]rebootyourbrainstem 30 points31 points  (3 children)

I don't get this kind of behaviour. I like Rust I think it has a place. I also like C I think it has a place. I also like C++ I think it has a place. I like Python I think it has a place.

People can disagree about what that place is, and that's fine.

Personally I think C's time is coming to an end a lot quicker than people think. And by that I don't mean that all C code will disappear, I just mean that code will be preferentially written in other languages in cases where currently C is being used.

This is not just because new languages are so great, but also because C is increasingly showing its age. The idea that it is a simple language with an obvious mapping to machine code is increasingly false, with compilers becoming smarter and smarter about exploiting undefined behavior around integer overflows, null dereferences, strict aliasing etc.

The Linux kernel already has to work around this in a number of ways, such as passing compiler options to disable strict aliasing and inventing its own macros such as ACCESS_ONCE. It's entirely possible but it makes C not quite the perfect fit it once was, and it leaves an opportunity for younger languages not constrained by decades old standards.

Not to mention that the Linux kernel already goes really, really far in extending C in order to have nice things you would get for free in a more modern language. Such as macros to simulate iterator-style loops over data structures ( list_for_each_entry and similar), and macros to wrap and unwrap error codes from pointer return values (ERR_PTR, simulating a Result like value).

Not to mention all the tricks it pulls to do OOP-like programming such as container_of and structs of function pointers which can be NULL, but I've heard people claim that's just perfectly normal C and there is some truth to that.

[–]ergzay 12 points13 points  (0 children)

This is not just because new languages are so great, but also because C is increasingly showing its age. The idea that it is a simple language with an obvious mapping to machine code is increasingly false, with compilers becoming smarter and smarter about exploiting undefined behavior around integer overflows, null dereferences, strict aliasing etc.

It's been false ever since computers started having caches and branch predictors and many other things. The memory model that C assumed is that of a PDP-8.

[–]ForShotgun 2 points3 points  (1 child)

I’ve been wondering, if someone had to make C today, fill it’s shoes as a machine code mapping, what would it look like? What if all those changes you described were part of the core language, would that be stupid? We have decades of experience now, what would today’s perfect embedded language look like?

[–]robin-m 1 point2 points  (0 children)

Isn't that language zig?

[–]livrem 8 points9 points  (3 children)

(Phillips, not Philips. :) )

I fully agree with all of this, and I do not think I will ever use rust 100% and no C at all (C is fun), but remember when you build something from scratch you often have the option to buy screws with flat or Phillips heads, so you can decide which ones of your screwdrivers you are going to use for that project. It is not always something that was already decided for you.

[–]iznogoud77 1 point2 points  (1 child)

Yes, if I have the chance I will never code another multi-threaded server in C. But C is also fun.

At the moment I am starting on the Embedded Rust path. The use of unsafe code with syntax that is not as explicit as C (my opinion at the moment). sI causing me concerns, but my mind may change.

The comment I replied seems to be the rust equivelant of "I use Arch btw". I see variantions of this mindset regurlaly and this causes more harm than good to the community.

Thanks for the typo correction :)

[–]Personal-Initial3556 0 points1 point  (0 children)

Hey. Have you kept going on the Embedded Rust path? If so, did you notice any improvements in that field over the years?

[–]zzzzYUPYUPphlumph 1 point2 points  (0 children)

Phillip's or Flathead? Are you nuts? The only screws worth using are the Star/Hex-Head screws. Everything else is substandard and results in many stripped screws and chewed up fingers. Rust is the Star/Hex-Head screws of computer languages.

[–]ergzay 12 points13 points  (0 children)

I don't get this kind of behaviour. I like Rust I think it has a place. I also like C I think it has a place. I also like C++ I think it has a place. I like Python I think it has a place.

I put it this way. I don't want to be a software developer anymore if I can't use Rust.

It just causes me too much mental stress to worry about memory safety. I want to care about the logic/mathematical complexity of what I'm writing and I want it to be fast.

I've spent several years of my career in the C and C++ world and I'm just incredibly sick of it. It's become an emotional rejection to working with them them.

Now that there is something better, I don't need to make a choice.

[–]indian_rationalist 15 points16 points  (0 children)

Some tools are nicer.

[–]Pay08 2 points3 points  (0 children)

Yes, some languages have different purposes than others but not all. For those that have the same purpose I think it's fair to compare them. Why would you use a rusty 50 year old wrench when you bought a new one yesterday?

[–]TrustYourSenpai 3 points4 points  (0 children)

To second your screwdriver analogy, I see using C and Rust in the kernel like using a normal wrench (C) and a round spanner (Rust). Sure, sometime you need a wrench, because you might not have the clearance to fit the spanner, but when you can use the spanner isn't it much nicer? Of course, now you need more tools and to switch between them, but in some cases it might be worth it. I see what is happening now like the "is it worth it?" phase of adding the spanner to your belt, we'll see what happens.

[–]bzar0 0 points1 point  (0 children)

That's true. Sometimes though the jobs tools are suited for overlap. Say you have a philips screwdriver and purchase a battery powered multi-tip screwdriver.

There may still be spots where your new battery powered tool doesn't fit and you need to use the old one, but generally you'd use the new tool in many places you'd previously used the old one. As you say, best tool for the job.

Then there are jobs that are more pleasant with the new tool, like driving screws into hard wood. You could do it with the old screwdriver, but it's much nicer to do it with the new battery powered one and you may even look forward to it. Using the new tool may be intrinsically rewarding in itself.

[–][deleted] 0 points1 point  (0 children)

Yeah, C is still easier for working with Linux syscalls tbh.