Ask Slashdot: Is it Practical To Replace C With Rust?
interval1066 writes: I've heard of rust from various sources around the net for a few years and never paid it much mind, there are so many new languages out now since my early days doing C programming, which what I've stuck to and made me my career. Now I'm heading a project that uses a RoR application to control a large series of sensors and controls in a manufacturing process. Naturally I want to talk to the hardware using a GEM extension written in C, as I've done before.
But another engineer who is not a fan of C (seems few younger engineers are) said he could write the extensions needed easily in Rust. Seems like this is a thing. I took a closer look at rust and it looks to me like another attempt at "C" without pointers, except rust does have a kind of pointer, it appears. I like its ranking on a list of fastest languages, and it seems pretty simple with an initial tool footprint that is quite small.
But what are the trade offs? Another language, and one that few engineers know (much like Vala, which I like very much but has the same small user base). What if I need another engineer to work on the code? I pretty much know what I can expect from C/C++, rust is a huge unknown, what if I run onto a roadblock? The engineer pushing for rust is emphatic, should I bulldoze him or take the plunge?
But another engineer who is not a fan of C (seems few younger engineers are) said he could write the extensions needed easily in Rust. Seems like this is a thing. I took a closer look at rust and it looks to me like another attempt at "C" without pointers, except rust does have a kind of pointer, it appears. I like its ranking on a list of fastest languages, and it seems pretty simple with an initial tool footprint that is quite small.
But what are the trade offs? Another language, and one that few engineers know (much like Vala, which I like very much but has the same small user base). What if I need another engineer to work on the code? I pretty much know what I can expect from C/C++, rust is a huge unknown, what if I run onto a roadblock? The engineer pushing for rust is emphatic, should I bulldoze him or take the plunge?
No one ever got fired for using C.
Im just 2 cubicles away from you, sad i read about it here
You should definitely investigate rust. It's very well designed. It has great support to call into C code and C libraries. It compiles fast. The standard library is much more convenient than C/C++. You have complete memory safety by default, without garbage collection. It has great support for safe multithreading. Over time, your speed will increase because you won't be spending weeks tracking a heisenbug due to memory corruption. There is some learning overhead, but it's worth it.
The biggest issue is that you won't have as big of an ecosystem around rust. You won't find good support for all of the libraries that you might want to use. But those problems aren't insurmountable.
The whole point of C is to be close to the hardware. The hardware has pointers. Why obfuscate?
C is pretty rusty.
Support my political activism on Patreon.
No.
They don't like C because they haven't been taught it properly and instead go for things that are just trying to re-invent the wheel. Tell this guy to STFU, read a copy of the K&R book, and then get back to work using the native language of *nix.
Where I am they chose SpineJS a few years ago, looked like a great language, easy, etc. After a few years, one thing we noticed was the lack of online help when you run into issues. It's just not that widely used. Rust is ranked 49th on Tiobe. Maybe it will be the next best thing, but if it isn't, you'll be stuck with something that has little community support.
... that determines its success or not in a non-nieche segment.
It's the mass of developers that already know it, it's the accumulated code base (both locally and globally) and most importantly: the eco system of tools surrounding it: the compilers, the IDEs, the debuggers, the static/dynamic code analysis, build systems, code generators, mock tools, coverage tools etc.
The new kids on the block have a lot of catching up to do in areas which are not directly language related.
If you're ever going to be porting it to another platform, then do it in C; there are C compilers available for almost every piece of hardware out there. If you're certain it only needs to run on a single, unchanging platform for the lifetime of the code, then using Rust might be a good idea.
I've abandoned my search for truth; now I'm just looking for some useful delusions.
How many other engineers are going to be expected to know and maintain this? Ones you have on staff? Are you making sure to hire for folks who know Rust? If you have one, is your ops team up to supporting applications written in Rust, familiar with the errors and can handle it? What's the life expectancy of the app? Ever going to need to port it in the future?
Don't forget to factor in the bus factor, when you lose a whole engineer.
Lots of folks end up missing these and you end up with mysterious legacy code the business completely depends on for day to day ops that no one knows or understands. Heck, the other day, I was asked to unlock a windows NT laptop because it was the only known repository of source code for an app that was written over a decade ago - hopefully.
Show him this story to indicate your attention to him and use C instead of this new-fangled and still-evolving language anyway.
You'll get better debugging tools, more productivity (since you know C better) and a wider pool of replacement developers should the need arise.
Stupidity is an equal opportunity striker.
Fellow slashdotter Bill Dog
But it's still immature. I wouldn't personally use it for anything important.
---- Den ene knappen er powerknapp, den andre er Bender voice knapp "Bite My Shiny Metal Ass"
The engineer pushing for rust is emphatic, should I bulldoze him or take the plunge?
Take yourself out of the loop. Give it to the engineer. He/she wants to push it. Let him/her. Make the engineer responsible for pushing it, training people, documenting the procedures. Provide room to enable it to happen.
This is how the engineer grows and an engineer and how you grow as a manager, learning to trust the technical opinion of those doing to technical work.
I should use this sig to advertise my book ISBN-13 : 978-1501515132.
Isn't humor supposed to be funny?
1st paragraph is false, due to the rather extraordinary design process that Rust went through.
designers also go off on an ego-trip, introducing numerous gratuitous syntactic changes, overlooking important features in their predecessor language they didn't understand
The Rust community is quite large, including many skilled language designers. The Rust github repository has ~1200 contributers. With that pool of talent,
there are no features of C/C++ that the designers don't understand. With this kind of community, and a formal change review/feature addition process, there's not much danger of a single ego-tripping designer messing up the language.
adding features few people actually need
The project transitioned from a hobby project to an official Mozilla project in 2009. During the 6 years from 2009 to 2015 (when the Rust 1.0 design was stabilized and released), a lot of Rust code was written. Features that seemed like a good idea at the time, but which had little practical use, were removed before 1.0.
3rd paragraph is also incorrect. The main feature of Rust is guaranteed memory safety, without a garbage collector, enforced by compile time type checking rather than by introducing run-time overhead. This memory safety includes a guarantee that shared global data can't be corrupted by simultaneous writes from different threads, something that no other language offers. C++ doesn't offer this today, no other language does.
I agree that Rust will influence future languages, but I don't think it will have much effect on C. The C++ community is already looking at Rust and trying to figure out how to compete with what it offers.
I have written a truly remarkable program which this sig is too small to contain.
This. C can be fixed. It takes time, and compilers are usually ahead of the standard. How long did it take for C to get the restrict keyword? That allows us to control pointer aliasing in a portable way. The impetus for that was that FORTRAN could outperform C because, AFAIK, it assumes no aliasing.
There are already a lot of static checkers for C. I'm willing to wager they can catch just as many bugs at compile-time as Rust. Having such tools is almost as good as having checks integrated into a standard implementation. If you go ahead in C, the standard may catch up to you without you having to worry about the risk of a new language.
For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
1) The Rust project is not controlled by Mozilla. Just look at the copyrights on the rust source code. It's permissive open source, with copyright shared by ~1200 individuals, and Mozilla is not on that list. So this is like spreading FUD by warning people that Linux is controlled by the Linux Foundation (Linus's employer)--hint, it isn't.
2) Mozilla and Oracle are quite different. The Mozilla Foundation is a non-profit, open source organization that exists to provide a public benefit through the creation of open source software. The Mozilla Corporation (employer of some of the Rust developers) is a wholly owned subsidiary that donates all of its profit to the foundation. By contrast, Oracle is known for being one of the most rapaciously greedy software organizations in existence: just consider the Oracle article on Slashdot right now, about how Oracle rips off customers via "traps" in the opaque licencing terms.
3) How can you be sure that Rachael Craig and Nicolette Verlinden are cisgender males? They have female names and photos.
So yeah, I'm pretty sure the parent is a troll, and I fell for the bait.
I have written a truly remarkable program which this sig is too small to contain.
Even if templates are already present in C++, they are a PITA to use. Rust is really really easy to use for those.
The interesting feature of new programming languages is often not what they make possible - you can write any program in the world in assembler, after all - it's what they make default.
Rust doesn't allow null values or null pointers. The Rust compiler automatically frees memory when the last reference to it goes out of scope. Variables are immutable by default. You can't use pointer arithmetic by default. Only one mutable reference to any piece of memory is permitted to exist at any one time by the compiler.
You don't need a new programming language for those features, you can write code in any existing language that follows those conventions. But by making good software development practices the default and having the developer jump through extra hurdles to do things in a way that might be dangerous, the general level of code quality is improved. C or C++ might evolve to the same defaults in 20 or 30 years - but if you want to write low defect systems code quickly today, Rust deserves a look.
Also, the language designers list most of the features they listed and what they drew them from, and some features in the 0.x releases were dropped when they found few practical uses for them.
So you spent 5 hours of your time, and 5 hours of tech support time, to avoid the data entry clerk spending 6 hours simply rekeying the data? Why? Doesn't sound like the right choice, unless the clerk had gone home already or something.
The C++ community is already looking at Rust and trying to figure out how to compete with what it offers.
Like what?
Here is Stroustrup talking for over and hour and a half just three weeks ago about how to both narrow and enhance C++ to achieve, among other things, a degree of memory safety, pervasive ownership semantics (std::owner<>) and enabling the compiler do a better job of detecting faulty code. The parallels with Rust are impossible to miss.
It has been a long time since anything challenged the C/C++ paradigm. In that time a large number of non-"systems" languages have emerged, leaving the low-level stuff to C/C++, and a smaller number of systems languages (Objective C, D, etc.) have also emerged, but nothing so far has provided enough value to motivate broad adoption. I think Rust is a language that does bring sufficient value. I am certain it is inspiring people to use and advocate it, as evidenced by this story.
It's disappointing to see the sheer number of Rust haters emerging from among C/C++ programmers. You can pan around the comments in this story yourself and read an abundant supply of irrational, ignorant and petulant comments. If Rust disappeared tomorrow it wouldn't cause a ripple, yet it's hated like Java or SQL. Sad.
Maw! Fire up the karma burner!
What about for something like an OS?
The only coherent argument I've seen for writing an os C rather than C++ is the annoyance of setting up the C++ runtime (it can be done though). The only other arguments I've seen basically assume that the world of computing has not advanced since about 1995. What were valid points then are simply wrong now.
Or for tiny little embedded stuff where memory is an issue? (Honestly curious, I'm not current with the latest C++ developments.)
C++ doesn't use more memory than C. In fact because the language is more advanced, idiomatic code is often more efficient and less consuming of memory than C. C++ runs just fine on an ATtiny MCU and things don't get much smaller than that.
Bear in mind C++ is almost a strict superset of C. Everything you can do in C, you can do in C++. But C++ is a more powerful language and it gives you the power without compromising on size or speed.
SJW n. One who posts facts.
Reminds me of the time the owner and his wannabe tech friend were poking around the IT closet one night, and mysteriously, our payments database crashed, corrupted, and unrecoverable. I spent all night trying to restore the previous days receipts. Hell, I even tried a hex editor to get something, anything. The file was complete garbage. Probably $100K unaccounted for, I was thinking the bank and investors are not going to like that, the company may be toast.
The next morning, I told the accounting boss (owner's daughter) I had to use the backup, and all the payment records from the previous day were lost. She got the four accounting clerks to re-enter the previous days payments in about 30 minutes. Dang, no big deal.
I learned a valuable lesson that day, and hopefully, so did the boss.