It sounds and seems like a language worthy of more investigation on my part, but I have to agree that the militant, presumptive attacks on any language besides their Chosen One has left a bad taste in my mouth.
It sounds and seems like a language worthy of more investigation on my part, but I have to agree that the militant, presumptive attacks on any language besides their Chosen One has left a bad taste in my mouth.
I don't think anyone is arguing that we should throw everything out, however for all my greenfield stuff Rust has been a welcome breath of fresh air. Yeah, there are some people who are a little too over the top but a large part of the support behind Rust is from those of us who've used it in production and found it to be a fantastic language and ecosystem.
*or fortran or pascal
At least for me, part of the attraction of Rust is the development tools around the language itself (e.g. cargo).
Seamless cross-compile. I've done a ton of cross-compile projects, cargo/rustup is the best by far.
One-line dependency import. Saves *hours* setting up build chains.
First-class win32 support. Hard to stress how rare and awesome this is coming from a gamedev background.
Integrated testing. So nice just to have.
Integrated benchmarking, ditto above.If you can write things from scratch in a clear room fashion, perhaps.
C++ is very good, when you need to integrate a lot of 'low-level' libraries (that are alredy in C or C++) together in a meaninful way, like for instance, browsers do.
Like the capacity to 'talk' with FFMPEG, levelDB, linux, etc.. in a complete native fashion basically.
I think in that regard Rust is sort of late to the party, and will find a wall hard to beat down, once the adoption rate get some maturity.
If you are already a experienced C++ dev, compared to modern C++, Rust has very little to offer. Of course is more modern, (maybe) more ergonomic?
But little things like package manager or explicit lifetime management by itself wont cut it.. at least not for people with large codebases already in C++.
When you are younger, programming languages look like that secret ingredient that will turn whatever you do into a magical tool.. But experience tells you that nothing beats hard work or that you should understand the strenght and weakness of each language, and know when and how to use it.
So for the problem domains where C++ are being used, it will get hard to beat, because a lot of great software are already there, and can be integrated in a native fashion, with whatever you do on top of it.
And by the way, modern C++ is already secure enough, making some selling points for Rust, a little bit of cosmetic right now.
If you throw a language like Swift into the equation.. particularly i think they(C++ and Swift) form a lovely and unbeatable couple.
The reason I ask is just about every item you laid out I've had the opposite experience.
Talking with C/C++ is trivial with bindgen and clang. Embedding in C++ is likewise straightforward. I mean Firefox is one of the larger C++ codebases out there. The package manager is great and makes dropping in things much less painful.
On the security front I don't think you can compare the two, I can easily think of things like iterator invalidation that C++ just doesn't handle well.
The last big project I did in Rust ran on 6 different targets(x68 win32/linux/osx, android armv7/x86, wasm) targeting 3 different rendering stacks(OpenGL, HTML Canvas, Android Views) integrated deeply with a Lua interpreter. Having done cross-platform stuff like this in the past it was a build/toolchain nightmare. With Rust everything was straightforward and pretty darn painless.
But there are a ton of domains where C++ doesn't have anything special to offer and you could just as reasonably write the code in rust.
I totally agree that Rust is a great language and has wide applications. It doesn't fit my current needs, but I don't doubt it meets many people's needs. More power to them -- and it's cool to have a "The new C++ killer language" which can actually live up to its hype, unlike Java and C# and Go and D.
I'm sure I'd much prefer it over Go, for example.
I'll also counter that having worked in a fairly math heavy 3D graphics space I've never needed them, although our requirements may be different.
Rust toolchain still fails support on mixed mode debugging.
With C++, I can have a mixed .NET, JS and C++ solution and without problems debug and single step across all languages, regardless of targeting desktop, server or UWP.
Similar applies to Java or Android tooling.
Additionally if one is into native desktop coding, bindings to Gtk and Qt are still work in progress, and there isn't nothing that would match something like Blend.
Finally, the borrow checker still hinders some programming patterns that are quite common on GUI code, a few of them will be tackled with NLL.
Ah, and cargo does not support binary libraries although rustc can handle them, which is an issue for companies selling libraries.
I am aware all these issues will be eventually fixed, it is just as I see the situation currently.
I follow Rust since Graydon Hoare's initial vision for it. Which i love it when it first came out. The garbage collected Rust had so much potential, in my point of view.
Then when i started to follow it, it was chaging into this current encarnation trying to chase C++, and market as a better C++.
I've coded in it for a period of 6 months, i like it, i understand its value, but somehow with the explicit lifetime thing, it started to become even more painful to code in it, even compared to C++, where you still have to create a header file and a impl file, without a proper module system.
The first Rust vision, now was re-created even more beautifully in Swift.
I get it what Rust is, i think it has its value and its place, im just saying that it will get a time where it will be very harsh to Rust get more adoption, because, even if you like it, you just cant get out of the great ecosystem all coded in C and C++. Interfacing with C for other languages is pretty easy, but you still have to wrap C++ interfaces, and use just some features, because you lost access to the whole thing (think LLVM for instance).
So C++ has this net effect, which it achieved by the virtue of all this amazing software ecosystem, where giving its talking its native language its much easear to interact with.
Had you said Poney I'd have agreed, but I don't see how Swift matches the first Rust vision (a safe concurrency model).
That's sorta funny that you use that example, since rust is a Mozilla project, and they've already moved some parts of Firefox over to rust, and plan to move more in the future. Clearly this is not an impediment; reasonable C/C++ interop was a must-have for rust's design.
> If you are already a experienced C++ dev, compared to modern C++, Rust has very little to offer.
That's a weird argument to make. Essentially you're arguing that you should never learn any new languages once you have proficiency in something similar? That would seem to be a bit short sighted.
> ... at least not for people with large codebases already in C++.
Sure. No one's saying "throw out all your C++ code and rewrite everything in rust" (and if anyone is, they can be safely ignored). But that doesn't preclude taking a look at some parts of your code that might benefit from being written in a safer language, or rewriting small tools in rust, or considering it for new projects.
> When you are younger, programming languages look like that secret ingredient that will turn whatever you do into a magical tool.. But experience tells you that nothing beats hard work or that you should understand the strenght and weakness of each language, and know when and how to use it.
No one's saying languages are magic, just that, by some metrics, some are objectively better. This might be an odd example, but I did Java for many years before switching to Scala a couple years ago. In the past few months I've had to go back to Java, and it's been frustrating that it's so easy to write certain classes of bugs that I just never see or write in Scala. Does that make Scala some magical tool that fixes all my problems and means I don't have to do any work? No, of course not. But it is objectively better than Java by some metrics (and sadly, worse by others).
> modern C++ is already secure enough
That's a pretty bold claim, and I'm certain it's not true. You might have a different idea of what "enough" is than I do, though. I'd believe that the "default" state-of-the-art C++ use is more secure than it was 10 years ago, but that doesn't mean that a language like rust can't offer superior safety guarantees.
And there's something to be said about encouraging safer practices through language features and convention. If you can make certain kinds of errors in C++ programs (I don't see pointer arithmetic going away any time soon, or people always using vectors and the like and never raw arrays), then you (or someone else) will, regardless if there are safer ways that help you avoid those kinds of errors. Given a language with a huge surface area like C++, and disagreements on what are the "safe" parts to use, it's inevitable.
> If you throw a language like Swift into the equation.. particularly i think they(C++ and Swift) form a lovely and unbeatable couple.
Despite Swift's open source status, I really don't see it making any meaningful foothold outside macOS/iOS.
I don't have a horse in this race. I abandoned C++ years ago, and I've only started learning rust a few weeks ago. I like it, but I have a lot to learn, and I've already found some rough spots that aren't so great. No tool is perfect.
There is not a single large-scale network-facing widely attacked piece of software I'm aware of in C++ that has not fallen to some memory safety problem. Memory safety issues frequently produce RCE.
Sorry. In hindsight, and out of the context like this, i think i picked up harsher words than i should. I dont meant to be disrespectful to all the great and valuable work that is going on the Rust community.
> There is not a single large-scale network-facing widely attacked piece of software I'm aware of in C++ that has not fallen to some memory safety problem. Memory safety issues frequently produce RCE.
Sure, Rust will be better at this. No doubt. But lets not forget that a lang like C++ needed to evolve while still working, so how much of those security issues are there given the use of ancient code practices of the past? software coded in the 90's even the 80's. I guess we at least should wait for when Rust has millions of tools, and billions of line of codes running in production, to see what sort of issues might plague Rust code the most. But Rust will need to get there first. So lets not forget that its a language created in the 70's and that is responsible for great tool, and is still being used to build big project, with millions of LOC and with many devs working in groups in some very sophisticated pieces of software, and this is no small feat.
What i meant to say, earlier, that maybe is not so clear, is the choice is not as unidimensional, by just cherry picking one point of view when you need to decide what kind of tech, fits the best for a given scenario. Im trying to point out that other languages like C++ or even C, still can be good bets, when you look into more vectors of influence, not only in the security aspect, or what language have more FP idioms in it. In the real life, is not as easy as some Rust evangelists imply it is.
C++ its not as good as Rust in the security aspect, theres no doubt about it, but the modern C++ is fine when you sum the vectors of what language will fit the best for a given scenario. I mean, you can be explicit about ownership, and make the api clear about ownership and lifetime. Of course Rust choose to be more pedantic about it. But as a C++ dev i have no issues with lifetime or owership management just by using smart pointers, std::move, etc.. (even in a multi-threaded environment)
But i dont think is as easy, as the Rust community is implying, that is to "just use Rust" for a project, where C++ may also be a good fit.
Even for new, clean room projects, i think C++ may be a better fit for certain scenarios, and im glad that theres also Rust as a choice. But i think sometimes this zealot type of evangelism sometimes more based in spreading fear, than by selling Rust for its own virtues, can hurt more than it looks like.
I guess by now, Rust doesnt even need to be compared to anything else, thanks to great hackers like you its already showing its own virtues. Im just trying to say that by now it probably reached a peak of users that can use the language in more low-level scenarios, and it probably should aim to get more of the Ruby, Python, PHP, NodeJS crowd, to fill its army.
Because from now on it would be harsher for Rust to get more adoption, without a big ecosystem backing it up (Like Swift has with Apple, Java with Android and C and C++ has with Unix)
But C++ was a mess from the very beginning, many of its problems are inherited from C, and the language itself was an ugly extension to C, not a carefully elaborated new language. So most new features were introduced to repair the breaches of such messy design.
Why to have nullptr dereferencing? Why to have an undefined behavior on option<> dereferencing? Why to have dangling refs? Why not to check borrow possibility statically? God, we don't event have a decent and safe variant (sum) type in c++. Adding all that (unnecessary) complexity c++ has (how many whatever-values and initializations does it have?). It is unsafe as hell, and lots of stuff could be made safer trivially in a new language (say, rust or F*).
>What makes it worse is that a null pointer in an option<> is handled as None instead of Some
What? How could NULL be treated as Some?
I think your parent must have been doing something strange; if you have a *const T, one that's null will still be a Some. It's &T, which cannot be null by definition, that uses the null value as None, since it cannot be null.
If you can reproduce you should file a bug.
Otherwise, I've redesigned the affected subsystem so I'm not sure I could reproduce the behaviour
When packing such an address into a mut or const within a Option<>, a NULL will be treated like a None when you write, essentiall, Some(NULL).
This 100 times over. It's a language that seems novel and strong enough to stand on its own merits - but there's a section of the community that makes me want to stay away.
I wish they'd spend less effort re-writing already working tools in C and more effort writing new, better tools. A drop in replacement for "ls" isn't that exciting for me.
And a good getting your feet wet project for someone else :)
Note, that the answer doesn't say that it can't benefit security, which would be a principal argument for OpenBSD. It brings side reasons as to why it's not easy to do (like integrated tools, developers' availability and so on).
Oh wait, that's right, none of them has even gotten around to writing a replacement for ls, grep, .....
Some did: https://www.redox-os.org
> Oh wait, that's right, none of them has even gotten around to writing a replacement for ls, grep,
They did that for some utils: https://github.com/redox-os/coreutils
> This seems to be a more reasonable approach that trying to force an existing operating system to adopt their language.
I don't think anyone is forcing to adopt anything here. The question was about integrating languages like Rust in OpenBSD.
Who exactly? Can you actually point to anyone making this desire known in earnest?
Is this really a thing? Folks keep pointing out this bugbear of folks going out and asking projects to rewrite in Rust and ... there aren't that many examples of this.
If anything most of the more famous Rust projects (ripgrep, redox, etc) are clean-slate.
Personally, I don't find this a bad idea, as long as it is not the primary thrust. The reason it is needed is that you aren't going to convince everyone to change the default tools they've used for however many years. If you want to make things safe, you have to swap out implementations and keep same/similar interfaces.
That doesn't change the fact that Rust programs are, when memory safety is concerned, more secure than C++ programs. This is true both in theory and in practice.
Why would not knowing C++ bar people from anything? It's a wildly specific skill, diminishing in importance every day.