News for hackers. Stuff that matters.
Re:Rust in QEMU Roadmap by crabbone on Tuesday December 03, 2024 @04:44PM (#42311891)
I wouldn't be so quick to put "easy" and "C++" in the same sentence... Also, C and C++ language tools suck, when it comes to making a language compared to anything in Lisp family, for example, or any language that has Lisp-like macros. C wasn't chosen for it's ability to make other languages. It was an easy target. The benefits are the simpler and more malleable runtime that can be made to do all sorts of weird things where C++ would be much harder to deal with.

In other words, if you don't want the language runtime, if you don't want C++ templates, smart pointers, classes, lambdas, exceptions etc. But, you want to be able to manage memory for eg. realtime kind of system... simply removing all the unwanted stuff from C++ is harder than it is with C.

And, if you did want some / all of those features of C++, there are saner languages to have that (and you'd pay for it by having to drag in their runtime and conventions). Before Rust was a thing, I've seen people choose D instead, for example, as a kind of middle ground between the asceticism of C and unnecessary excess of C++.

Re:Rust in QEMU Roadmap by quotemstr on Tuesday December 03, 2024 @05:07PM (#42312111)
Lisp is a non sequitur. C++ can do the same "weird things" C can. There is literally no advantage whatsoever of choosing to wear the C hairshirt instead of using C++. Not a single one.

Sure, Rust is better than C++ in some ways. You can have a legitimate debate about C++ versus Rust. There can be no debate about C versus C++: the latter is better in every single way.

> unnecessary excess of C++.

Is the unnecessary excess of C++ in the room with us right now?

Again, you don't have to use any part of C++ you don't like. A few minor spelling differences aside, it remains a superset of C. Using C++ not C will not hurt you in any project whatsoever.

Re:Rust in QEMU Roadmap by crabbone on Wednesday December 04, 2024 @09:13AM (#42317564)
I don't know... I basically already answered your question: C++ has way too many things to remove. People working on projects like QEMU don't want exceptions, smart pointers, classes, virtual methods, templates, lambas etc. So, it's more effort to remove all of that / make sure your code doesn't accidentally use any of that.

C is simpler because you don't need to remove any of that stuff, because it's not there to begin with.

My argument about Lisp doesn't say that anyone should use Lisp instead, it just points out that people making the choice between C and C++ aren't concerned by how easy it is to build new languages using the language building tools of C or C++ because both are very bad at it. Had the objective of building a new language been the primary objective of such projects, they'd be using a language with superior language building tools (not necessarily Lisp, there are many alternatives, it's just that neither C nor C++ are good at it).

Re:Rust in QEMU Roadmap by bonzini on Thursday December 05, 2024 @09:50AM (#42328718)
Well, smart pointers and (sort of) templates and lambdas are in Rust. I definitely want smart pointers.
Re:Rust in QEMU Roadmap by crabbone on Thursday December 05, 2024 @10:41AM (#42329220)
Not when you need your own allocator. Anything that tries to manage memory w/o you knowing about it will be working against you.
Re:Rust in QEMU Roadmap by bonzini on Thursday December 05, 2024 @04:53PM (#42333231)
Smart pointers are not really about managing memory, they're about managing lifetimes. Even things like the Rust RefCell are smart pointers.
Re:Rust in QEMU Roadmap by crabbone on Friday December 06, 2024 @05:44AM (#42338472)
Rust lifetimes is a mechanism to manage memory.