16 ms·
QEMU should move from C to Rust
- ghostwriter 6y agoAll bullet points under "Why Rust?" actually suggest that it would be much better to gradually rewrite all critical parts of the project in ATS, thanks to it being a frontend to GCC. Firstly, it's a much more powerful frontend than the current Rust. Secondly, I'd expect it to be less disruptive than a complete compiler switch.
- jhardy54 6y ago> ATS For anyone else who was unfamiliar: https://en.wikipedia.org/wiki/ATS_(programming_language) https://en.wikipedia.org/wiki/ATS_(programming_language)
- luizfelberti 6y agoIf a rewrite is warranted, and despite Rust zealotry being annoying at times I think it has fair points, I think going for something even more hipster than Rust would be a mistake. I wouldn't even call Rust "hipster" anymore. It's already been embraced and rolled out to production by big companies working on hard techinical problems (Cloudflare, AWS, Discord), as well as the crypto community. I think the reasons from steering away from hipster languages for these critical projects are roughly the same ones we use to justify not using hipster crypto for critical, real-world applications
- KingOfCoders 6y agoI also would call Rust the new normal for fast secure code.
- johnisgood 6y agoI still do not understand. Ada is not exactly new. Have you ever seriously considered Ada/SPARK? Might want to give https://www.adacore.com/uploads/books/pdf/AdaCore-Tech-Cyber-Security-web.pdf https://www.adacore.com/uploads/books/pdf/AdaCore-Tech-Cyber... a read, or even https://blog.adacore.com/ https://blog.adacore.com/, or my previous comments on Ada. I called Ada the programming language for writing "fast secure code" for quite a long time now, a "better C" in that regard.
- adamnemecek 6y agoAda just doesn't have the steam behind it.
- johnisgood 6y agoIt certainly lacks the hype, and judging by the comments on here, many people still have loads and loads of misconceptions of the language, negative ones, unlike say Rust's "unsafe code does not affect the rest of the program", for example, which I would call a positive misconception. And of course thus, it also lacks libraries. This is really my biggest problem with it. :/
- 59nadir 6y agoRust isn't nearly popular enough to be referred to as "the new normal" in any field or context. One would have to be in a very closed off bubble to think it is. If they haven't made some big strides with having it certified for use there are entire industries where you can't even use it and get certification, if I understand correctly.
- bananaface 6y agoI wouldn't really call Discord a hard problem. It's web chat.
- Volt 6y agoYou might have missed the "technical" qualifier. Twitter isn't an especially hard problem either.
- bananaface 6y agoI didn't miss the qualifier. Discord is a chat client with very restricted servers. It's really not that hard as technical problems go.
- luizfelberti 6y agoPlease, do tell us what kind of exotic problems you work on, that you think massive scale real-time communications is not a hard technical problem We're eager to know!
- bananaface 6y agoNo, that's stupid. I couldn't build Discord. My point is that as relative problems go, I don't see Discord as a big one. I might be wrong but as far as I can tell it's a solved problem and has been for over a decade. I'd wager you could build it with an incompetent team that had domain expertise. AWS is orders of magnitude more complicated than Discord. Frankly, so is World of Warcraft. What does Discord do that wasn't solved in 2005?
- dodobirdlord 6y ago> AWS is orders of magnitude more complicated than Discord. Frankly, so is World of Warcraft. AWS maybe, insomuch as "orders of magnitude" can mean as little as "100x". But still, unconvinced. There's something like 200 AWS services, and Discord on the whole is certainly more than twice as complex as the average AWS service. World of Warcraft being >100x more complex than Discord doesn't track. > What does Discord do that wasn't solved in 2005? Perhaps you are unaware that Discord has (pretty high quality!) voicechat and livestreaming? Certainly much better than anything that existed in 2005.
- jcranmer 6y agoFrom a cursory search, it looks like ATS is implemented as a "compile to C code" language. This kind of implementation is actually quite concerning, because it means you're punting through a language which is notorious for its heavy reliance on undefined behavior, and there is no way to opt out of undefined behavior in some cases. Also, from what I can tell of its mailing list, ATS is a pretty dead project: https://sourceforge.net/p/ats-lang/mailman/ats-lang-users/ https://sourceforge.net/p/ats-lang/mailman/ats-lang-users/ shows only announcements post-2015.
- vmchale 6y agoIt's a google group! Not dead at all, though it is... ATS :)
- kergonath 6y agoIt’s not more concerning than a language that is compiled to assembler. It all depends on the quality of the compiler/transcoder.
- ghostwriter 6y ago> This kind of implementation is actually quite concerning, because it means you're punting through a language which is notorious for its heavy reliance on undefined behavior, and there is no way to opt out of undefined behavior in some cases. if it were a new project I'd agree, but if there's an existing C codebase, it already contains all these UBs and the goal of the rewrite is to grow a formally-verified critical core functionality in ATS that would still inline the rest of the project intact. This way the formally verified part of the project can grow naturally through small iterative steps without major disruptive changes to the tooling and supportive infrastructure. People who are familiar with C can acquire basic ATS patterns pretty quickly (within a month or so), and the same is applicable to those who are familiar with ML-family languages.
- DSMan195276 6y ago> This kind of implementation is actually quite concerning, because it means you're punting through a language which is notorious for its heavy reliance on undefined behavior, and there is no way to opt out of undefined behavior in some cases. I think it's worth pointing out that you can't always get away from those undefined behavior situations even if you skip C all together. Rust, for instance, has some internal/implementation details I've run across that are just C undefined behavior details leaking out of the LLVM IR instructions they use to implement the language, since those instructions have the same undefined behavior semantics as the corresponding C code they're used for.
- deleted 6y ago[deleted]
- twic 6y agoIs ATS really suited to being an industrial language? How do its standard library, build tools, and library ecosystem compare to Rust's? Admittedly, if you're switching from C, you start with a pretty poor story about all that. But at least that story is widely and thoroughly understood. ATS has an optional garbage collector. It seems the standard library has two implementations of each container type, one which uses GC, and one which uses linear types, so does not need GC, but is more demanding to use. That is pretty cool! What is the situation with other libraries? Is there a convention of assuming GC can be used, or that it can't, or of supporting both?
- ghostwriter 6y ago> How do its standard library, build tools, and library ecosystem compare to Rust's? as ATS is a frontend to GCC, it means that the standard library can be any battle-tested C standard library. On top of that there can be a formally-verified interface that calls underlying C API. Here's an example - https://bluishcoder.co.nz/2012/08/30/safer-handling-of-c-memory-in-ats.html https://bluishcoder.co.nz/2012/08/30/safer-handling-of-c-mem... There's also a safe Prelude and common data structures, implemented in ATS: http://www.ats-lang.org/Libraries.html http://www.ats-lang.org/Libraries.html > Is there a convention of assuming GC can be used, or that it can't, or of supporting both? afaik there's no officially defined convention, but you can have a look how this switch may look like in practice in this video - https://youtu.be/Xkg_EmERYRE?t=1742 https://youtu.be/Xkg_EmERYRE?t=1742
- scythe 6y agoBack when it was on the PL shootout, ATS was consistently in the top five for performance. However, it was also consistently the worst in program size, comparable to Ada (but even more loquacious). Between that and the lack of existing uptake it would probably be difficult for QEMU to adopt.
- deleted 6y ago[deleted]
- stefanha 6y agoArticle author here. Thanks for sharing ATS. I will take a look at it.
- ghostwriter 6y agoHey, no worries! Personally I think this playlist provides a nice set of real-world examples implemented in ATS: https://www.youtube.com/watch?v=dsILVOqYCU0&list=PL6BIXG1a4elukfR7-CDrlCwICk-7K7XI-&index=13&t=0s https://www.youtube.com/watch?v=dsILVOqYCU0&list=PL6BIXG1a4e... And this series of blogposts is a pure gold: https://bluishcoder.co.nz/tags/ats/ https://bluishcoder.co.nz/tags/ats/ And here's the official language introductory resources: Language Tutorial - http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/INT2PROGINATS-BOOK-onechunk.html http://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/... Language Features Overview - http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/ATS2TUTORIAL-BOOK-onechunk.html http://ats-lang.sourceforge.net/DOCUMENT/ATS2TUTORIAL/HTML/A...
- vbezhenar 6y agoWhat’s the status of the Rust project after recent Mozilla layoffs? How much does Rust depend on Mozilla?
- steveklabnik 6y agoMozilla employs a small number of people to work on Rust fulltime, and many of the Servo people contributed to Rust too, even if it wasn't their job. They also pay for the hosting bill for crates.io. They also own a trademark on Rust, Cargo, and the logos of both. Two people from the Rust team have posted about their situation, one was laid off and one was not. Unsure about the others. Many of the Servo folks (and possibly all, it's not 100% clear yet but it doesn't look good) have been laid off. The vast majority of contributors and team members are non-Mozilla, though the Mozilla folk are very important. Rust will survive. This situation is very painful, and it has the possibility of being more so, but (thanks to a lot of work from people (not speaking of myself here) who used to be at Mozilla!) Rust is bigger than Mozilla, and has been on a long road towards diversification. Some other companies have stepped up to pay a bunch of the bills that Mozilla used to pay, namely Amazon and Microsoft. Here's hoping that we get even more involvement in the future.
- boris 6y agoIf Servo is a dead end (by the sound of it), what is the new "halo project" that showcases Rust's use in something non-trivial and widely-used/public? (Not trying to rub salt in the wound, geniunly interested.)
- nicoburns 6y agoA lot of the code from Servo is now in Firefox, and will live on. If widely-used doesn't imply open source then there's a lot of options. Dropbox use Rust in their sync client, as well as in their storage backend. Cloudflare are using it for their VPN. Microsoft are rewriting parts of windows in it. Amazon are using it for their Firecracker micro-vms that power lambda.
- steveklabnik 6y ago
- stephc_int13 6y agoWell, that would be a nice benchmark ;) I would be very curious to compare speed, size and compilation time of the two versions.
- Thaxll 6y agoI think the real benchmark is a large "C" project writen fully in Rust and to compare the issues on the long term, not sure it's safe to asume that Rust would fix all the security issues with all the unsafe code that would be? What a 1.5M LoC Rust low level kind of project looks like?
- bluejekyll 6y agoMy favorite project to point people towards to understand how unsafety can be highly isolated is the work here: https://os.phil-opp.com/ https://os.phil-opp.com/ That very low level educational project can show how little unsafe is needed even at things running on bare metal.
- MiroF 6y agoWell, actix-web is a pretty large project written fully in Rust and it never really had any issues with lack of safety.
- nicoburns 6y ago> I think the real benchmark is a large "C" project writen fully in Rust and to compare the issues on the long term, not sure it's safe to asume that Rust would fix all the security issues with all the unsafe code that would be? I think you overestimate how much unsafe would be required. Most code, even low-level code can be safe.
- staticassertion 6y agoHonestly, I think anyone who has written Rust, even low level Rust, intuitively understands that it wouldn't even be close. It's not really worth measuring - like measuring C vs Java, no one really needs to do it because it's so obvious that C will have many times more memory safety issues.
- stephc_int13 6y agoRust is the new silver bullet...
- tankenmate 6y agoAnd an easy way to tell is there is no section in the post on what the downsides are to picking Rust.
- steveklabnik 6y agoThere may not be an explicit section, but the post certainly talks about how it would be a mistake to rewrite the code, and gives reasons.
- tankenmate 6y agoIMHO that is just a soft touch, it's just saying there might be some areas where Rust isn't a good fit. What the article doesn't address is what the intrinsic costs of switching are, as opposed to what the article does address is that there are probably places where it doesn't have a good fit. In short the article doesn't address what new costs Rust might bring that are intrinsic to using Rust (as opposed to costs that are inherent in making a change to _any_ new language).
- KindOne 6y agoDiscussions on reddit: https://www.reddit.com/r/linux/comments/i56gzj/why_qemu_should_move_from_c_to_rust/ https://www.reddit.com/r/linux/comments/i56gzj/why_qemu_shou... https://www.reddit.com/r/rust/comments/i4rpyc/why_qemu_should_move_from_c_to_rust/ https://www.reddit.com/r/rust/comments/i4rpyc/why_qemu_shoul...
- IceWreck 6y agoWhats with the treand of why X should move to Rust these days? Not saying Rust is flavour of the week but this happens with a new language every couple of years. Everything doesn't need to be rewritten. You switch languages, you might fix some existing bugs but you open lots of other ones.
- steveklabnik 6y agoThis blog post discusses specifically what would be gained by moving to Rust, and why Rust. The word "re-write" does not appear. It is actually suggesting that new work be started in Rust. It even suggests that re-writing what's there is a bad idea!
- rectang 6y agoYou'd never know that the blog post describes such an incremental strategy from all the top-level posts on this page rushing to argue against the straw man of a complete rewrite. :\
- vlovich123 6y agoLike almost even those that claimed to read the article did so haphazardly.
- ghostwriter 6y agoIt suggests two things at the same time - that a re-write would be great - "If people want to convert QEMU to Rust that would be great" - and that the author has other thoughts too.
- nicoburns 6y agoThe story for C/C++ software is a bit different. It has an order of magnitude more security issues than (similarly well written) software in other languages. Mostly because of memory issues. Partly due to undefined behaviour. There's a lot of this software. And until recently C and C++ were more or less the only viable options for writing it. Now there's Rust, and it has the potential to bring rates of security issues down to the levels of other memory safe languages (or even lower - Rust actually has protections against things like thread-safety issues that languages like Java don't). If the language didn't matter, then we'd all be writing in assembly code. It can make a big difference.
- spankalee 6y agoIs it worth the effort to write a "X should switch to Rust" post that ends with "but I personally don't have the appetite to do it"? Migrations of this size aren't not done because they're technically bad ideas, but exactly because they're expensive, messy, and few people have the appetite or funding to do it. Proposing a solution to that is more interesting that just saying "switch to Rust!". Also, I don't know much Rust (still on my PL bucket list), but usually when I dive into a more detailed analysis of such a migration the most relevant parts are around how much unsafe code will be required and whether or not integrating with the existing codebase has to be fine-grained or can be done in larger modules like Rust recommends. I would naively guess that a VM would have lots of unsafe code. Are there any investigations on whether the recent vulnerabilities would have migrated to safe or unsafe code? edit: mea culpa. I didn't read the second to last-paragraph closely enough, which at least proposes a modularized way of doing this with device emulation being written in Rust in separate modules.
- slim 6y agoIs it worth the effort to write a "X should switch to Rust" post that ends with "but I personally don't have the appetite to do it"? he made it to the front page of HN, so I guess the answer is "Yes"
- rvz 6y agoThe answer is "Maybe" but this developer won't do it. Someone else has to make it a reality. Once again and eventually the response is still PoC||GTFO.
- nomel 6y agoEntertainment value is separate from practical value and feasibility.
- adsjhdashkj 6y agoMaybe the practical value is traffic?
- 6y ago
- jeffreyrogers 6y agoSeems a bit silly to rewrite working software in a relatively new language. I like Rust, but it has its own trade-offs. The big one for QEMU being that QEMU developers and users tend to know C already and not be familiar with Rust.
- steveklabnik 6y agoThis blog post agrees with you, and says that re-writing the code in Rust is a bad idea.
- staticassertion 6y agoRewriting the device drivers would be huge. Having been tasked with "Make a QEMU environment safe against advanced attackers" memory safety issues in device drivers were by far the most concerning issue, and the hardest to mitigate.
- jeffreyrogers 6y agoRust definitely has that advantage. The downside is most device driver programmers know C, not Rust. So if you want other people to work on your driver you either have to expect them to want to work on it badly enough to learn Rust or to already know Rust.
- nrclark 6y agoFor the Rustaceans in the thread, I've been wondering - What's the current state of affairs of Rust for non-x86_64 targets? I know it's in flux, and that documentation isn't always up to date. What architectures can rustc target? Can it cross-compile? Can I cross-compile rustc itself, or do a Canadian-cross (where I cross-compile a rustc that wants to target a different architecture than the one that hosts the compiler)? Speaking as somebody who does a ton of system programming for embedded Linux systems, this is basically C/C++'s biggest advantage over Rust - the extreme flexibility of the available toolchains.
- fnord123 6y agohttps://forge.rust-lang.org/release/platform-support.html https://forge.rust-lang.org/release/platform-support.html https://github.com/japaric/rust-cross https://github.com/japaric/rust-cross
- steveklabnik 6y agoEvery Rust compiler is a cross compiler. There can be some issues on some combinations of cross compiling, that is like, you can't run link.exe on a Mac so cross compiling from a Mac to Windows only works if you don't use the msvc target, stuff like that. I personally work on embedded ARM stuff on Windows, so I'm cross compiling from x86_64-pc-windows-gnu to thumbv7em-none-eabihf all the time. No need for a special build or setup, just a "rustup target add thumbv7em-none-eabihf && cargo build --target=thumbv7em-none-eabihf" and that's it. ARM themselves are committing to getting the various ARM targets to Tier 1 support. AVR support landed in nightly recently. Other targets have less support, but that's mostly due to lack of people power, not a lack of interest from us.
- Arnavion 6y agoI know you know this, but just to clarify for other people, "Every Rust compiler is a cross compiler" is only true for pure Rust code. You'll still need a C cross-compiler toolchain to link your final binary, and any Rust libraries that are bindings to external libraries and expect those libraries' C headers / link objects to be pre-installed [1] will need said external libraries' C headers / link objects to be available for the target architecture. So the availability of a C cross-compiler toolchain can affect your ability to compile Rust code for foreign architectures. As a concrete example, at $dayjob we need to compile our code for CentOS 7 armv7 and aarch64, but CentOS 7 does not have a usable cross-compiler toolchain in its repos [2], so we have to run the build process in a centos7 arm container running under qemu. [1]: Eg openssl-sys is bindings to openssl and expects you to have installed the equivalent of your distro's openssl-devel package. In cross-compilation scenarios, this means installing the openssl-devel package for the foreign arch. For debian you'd do something like `dpkg --add-architecture armhf; apt install libssl-dev:armhf` [2]: What it has is only for cross-compiling the kernel, so there's no cross glibc available to link the final binary to.
- jksmith 6y agoToo bad the C beer-goggles have lasted so long that other great languages didn't take hold. Don't know about that theorem proving stuff in ATS, but with some application of hygiene like "if denom <> 0 then" and compile time prechecks on structures that like every Wirthian language ever has offered, maybe the computational arts would be further along right now. Nah, too much trouble. I'd rather not check if denom = 0. Back to writing autonomous car code!
- varbhat 6y agoTelling QEMU to move from C to Rust is bad idea imo. QEMU Devs are probably well versed in Source code of QEMU and C. Telling them to learn new language and rewrite QEMU would be a joke. It would give lot of new problems than solving the current issues. Probably, RUST Devs who are well versed in emulation can start another project in RUST which has same goals of QEMU but telling existing software to rewrite is a big JOKE to be laughed at. This has nothing to do with RUST but "Rewrite in New language" syndrome.
- jdub 6y agoA major QEMU contributor suggesting that future work on a specific subset of components (that are prone to vulnerabilities that are difficult to avoid in C) be done in Rust is not naïve. It's the beginning of a community discussion.
- Twirrim 6y agoFirst up, the person writing the blog post is actively involved in QEMU development. It's not some random person evangelising use of Rust. It's most definitely not naive for them to suggest such a thing, but instead exactly how such things ought to be done. Secondly, you may be started to find out that the QEMU developers seem to be in agreement, with the interest related to Rust for vhost-user, and considering ways interfaces etc. might make that feasible. OPs post to the QEMU development list, thread makes for interesting reading: https://lore.kernel.org/qemu-devel/CAJSP0QWF8g7r5VqU_PRbskWZU3ahCq+eobR8GexUcPrAiYoCPQ@mail.gmail.com/ https://lore.kernel.org/qemu-devel/CAJSP0QWF8g7r5VqU_PRbskWZ...
- xemdetia 6y agoYeah, there's no discussion on this blog post of what a lot of people are doing in writing project-specific linters, static analysis passes, code generators and so on that just ensure higher code quality which to me is more bleeding edge when it comes to actually helping. There's also no mention of the fact QEMU is tightly bound to other C based projects like libvirt and KVM and having developers be able to switch back and forth is extraordinarily useful. It wouldn't just be replacing QEMU but also the ecosystem around QEMU. It's not like QEMU is the application at the end of a dependency chain, it's in the middle for a lot of users.
- siscia 6y agoHow big is a device emulation mentioned in the article? How many of them are necessary?
- rectang 6y agoThe blog post proposes an incremental migration. From the next to last section "How can we change programming language?": > The reason I am writing this post is because device emulation, the main security attack surface for VMMs, can be done in a separate program. That program can be written in any language and this is where Rust comes in. For vhost devices it is possible to write Rust device backends today and I hope this will become the default approach to writing new devices. For all those criticizing the knee-jerk impulse to rewrite, you're arguing against the wrong post!
- xiphias2 6y agoIt seems that the controversies in the comments come from the inexact title. It should have been ,,Why QEMU should incrementally move from C to Rust'', or something similar, that reflects the content of the article better.
- roblabla 6y agoOr maybe people should read the post instead of reading too much into the title?
- afiori 6y agobut the title is important, it claims that the article will give sufficient reasons for QEMU to stop using C in some natural sense and move to Rust. if this is not the reflective of the content or it is a tongue in check exaggeration following a c common template (similarly to the "considered harmful" titles) it is reasonable to criticize the title (it is less reasonable to criticize the article under the assumed content)
- pdimitar 6y agoI'd expect a technical audience to be already aware that any such efforts can only ever be incremental -- so your elaboration would be redundant.
- OnlyOneCannolo 6y ago> Eliminating C programming bugs does not necessarily require switching programming languages. Other approaches to reducing bug rates in software include: > - Static checkers that scan source code for bugs. Does QEMU use a sound static analyzer (like IKOS [1])? [1] https://github.com/NASA-SW-VnV/ikos https://github.com/NASA-SW-VnV/ikos
- stefanha 6y agoNo. Coverity scans QEMU regularly but it is not sound. The challenge with static analyzers is that false positives make people not want to deal with the analyzer reports. I will check out IKOS, thanks!
- OnlyOneCannolo 6y agoOne of the cool things about that particular analyzer is that you can choose how accurate it is in exchange for how long it takes.
- didip 6y agoIf people are really serious about writing virtualization in Rust, they should just contribute to firecracker: https://github.com/firecracker-microvm/firecracker https://github.com/firecracker-microvm/firecracker
- luizfelberti 6y agoFirecracker is a really nice project, but the scope really isn't the same as QEMU, and they are not mutually exclusive projects
- elithrar 6y agoThe project goals of Firecracker - lightweight VMs (literally "microvm" in the name) with the bare minimum device emulation - are definitely removed from QEMU at large. There may be some overlap, but just "contributing to Firecracker" ignores the goals of these projects.
- svntid 6y agorewrite in new language syndrome lol
- beeforpork 6y agoWhat's the current state of compilation times of Rust? How many times slower than C does it compile? Any links to statistics? I know it's hard to compare, but I am interested in developing a gut feeling of what to expect.
- steveklabnik 6y ago> What's the current state of compilation times of Rust? Still slower than we'd like. Some folks are putting in a heroic amount of effort to improve this significantly, but it's going to be a long time before it really happens. Smaller stuff is helping all the time, but has less dramatic impact. > How many times slower than C does it compile? Really impossible to say, because it varies along so many different factors. C will almost always compile faster though, it's true. > Any links to statistics? I know it's hard to compare, but I am interested in developing a gut feeling of what to expect. The closest we have is a few bits of basically anecdotal evidence; we have projects demonstrating that rustc got about 3x faster since 1.0, and we have had at least one (in my mind) pretty reasonable C++/Rust comparison that showed them as being roughly equal. But it's just really hard to get good data here. You should expect something roughly C++-like.
- justapassenger 6y agoBe the change you wish to see in the world. Otherwise, posts like that are mostly people asking others to use same toys as they like.
- stefanha 6y agoArticle author here. I am already working on Rust code for QEMU :). The goal of the article is to start a wider discussion in the QEMU community and encourage others to do the same. I will post more about the things I have been working on when they are ready.
- justapassenger 6y agoHappy to hear that, and I support your effort. If you can show people that Rust actually works and is better, it will help advance QEMU. It'll be much more productive discussion, when you have actual data and code to back you up.
- kasajian 6y agoI find it odd that for the solution proposed for solving problems with C that are explicitly solved by C++ is not to move the code-base to C++ but to an incompatible language, like Rust. Nothing against Rust, but sounds more like someone who wants to work on Rust.
- war1025 6y agoWrong thread, fyi.
- dang 6y agoWe've moved it. Comment was originally posted to https://news.ycombinator.com/item?id=24133146 https://news.ycombinator.com/item?id=24133146. I always wonder about the specifics of how these happen!
- skinkestek 6y ago> I always wonder about the specifics of how these happen! Once I read someone saying they where blind and had forgotten the context or navigated back or something without noticing. I think there were some interesting follow up questions as well.
- dang 6y agoExactly—I bet the reasons are often surprising.
- fezzez 6y agoI think you're in the wrong thread
- agumonkey 6y agomaybe they can recruit the remacs team
- bananaface 6y agoMaybe remacs can recruit the remacs team, frankly
- agumonkey 6y agois remacs looking for itself these days ?
- dilandau 6y agoPut up or shut up fool. Anyone can write a blog asking for a rewrite. Until you start taking real actions, you can't be taken seriously by the people who actually matter to these projects.
- ChrisSD 6y agoa) The post is written by a QEMU dev b) It argues against rewriting QEMU in Rust c) It was the start of a positive discussion on the QEMU dev mailing list
- deleted 6y ago[deleted]
- wtetzner 6y ago> Put up or shut up fool. Please don't use personal attacks. > by the people who actually matter to these projects. According to the author's "About me" section, they are one of the people that matters to the project: > I am an open source developer and contribute to QEMU and KVM. I work at Red Hat. The postings on this site are my own and don’t necessarily represent Red Hat’s positions, strategies or opinions.
- dang 6y agoWe've banned this account for breaking the site guidelines and ignoring our requests to stop. If you don't want to be banned, you're welcome to email hn@ycombinator.com and give us reason to believe that you'll follow the rules in the future. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- dilandau 6y agosorry I thought this was a parody site.
- ausjke 6y agoC11 has safer version of those bad boys(strcpy_s etc) and gcc/clang is more powerful about static checking and runtime checking these days, make existing c code better/safer might be more realistic than rewriting code size of qemu in rust.
- rvz 6y ago"Talk is cheap, show me the code" - Linus Torvalds The author applies the same standard reasons for moving from C to Rust for the QEMU project which are valid reasons. However, I would take the author more seriously if they have done a proof of concept first and then later made their case for this. Otherwise, it is another "rewrite it in rust" post which is yet to materialise into a real project.
- thramp 6y ago> Otherwise, it is another "rewrite it in rust" post which is yet to materialise into a real project. I'm not sure you can reasonably said that "it is another 'rewrite it in rust' post..." if it's coming from a QEMU maintainer. Besides, before starting a large engineering project like this, it's worthwhile to write a high-level proposal _then_ write code. Saves you a lot of wasted effort!
- deleted 6y ago[deleted]
- microcolonel 6y agoStart porting some device emulators, otherwise this is just a waste of time.
- johnklos 6y agoYes. Let's make things less accessible to everyone. People with less resources have had it too good for the last decade or so, and our double digit core, double digit gigabyte memory computers no longer make us feel special, so let's move software to something even bigger and more bloated than anything we've ever seen before.
- jedisct1 6y agoThe best way for QEMU (or anything) to keep improving is to have it written using the languages and tools that the actual maintainers are the most comfortable with. People suggesting rewrites in X/Y/Z are usually not people maintaining these projects. This is evangelism, but it doesn't help with anything.
- stefanha 6y agoArticle author here. Thanks for mentioning it, I have updated the article to clarify that I'm a QEMU maintainer. The article was intended for the QEMU community but now that it's being discussed more widely it helps to be explicit about my involvement in QEMU.
- haolez 6y agoI've heard from different sources that QEMU's code is one of the best C code base available in terms of quality and clarity (and smart tricks!). Tough call.
- dahfizz 6y agoThe following justifications are given: -Use-after-free, double-free, memory leaks, and other lifetime bugs are prevented at compile-time by the borrow checker where the compiler checks ownership of data. -Buffer overflows and other memory corruptions are prevented by compile-time and runtime bounds-checking. -Pointer deference bugs are prevented by the absense of NULL pointers and strict ownership rules. -Uninitialized memory is prevented because all variables and fields must be initialized. These are all only true in safe rust. A hypervisor has to do low level things like translate memory addresses, move stack pointers around, etc. Nearly all the buggy C code, if implemented in Rust, would be wrapped in 'unsafe' and would be just as buggy. I recommend everyone interested in Rust to take a look at how the standard library Vec is implemented[1]. The code is littered with `unsafe` - There is just no way to avoid it and do something useful at the same time. This isn't really a shortcoming of the language, but of modern computers. It is fundamentally an unsafe operation to read or write memory, to communicate with a disk, etc. Every computer program is fundamentally unsafe. Rust does a fantastic job of making this explicit and controlling it as much as possible, but the idea that Rust code is bug free for free is just wrong. [1] https://doc.rust-lang.org/src/alloc/vec.rs.html#300-303 https://doc.rust-lang.org/src/alloc/vec.rs.html#300-303
- estebank 6y agoI think the Vec example makes the opposite argument from the one you put forth. Vec uses unsafe internally in order to have the desiref API and performance characteristics, but it exposes a safe API. If there are bugs in the unsafe blocks that can cause UB all over the place, but it also makes it easier to audit. > There is just no way to avoid it and do something useful at the same time. I don't think that's true. Your code might have to rely on code down the abstraction layers that uses unsafe, as interacting with the hardware is inhere you unsafe, but that doesn't mean that any code you want to write won't be able to leverage the safe abstractions. The argument you're making sounds to me, and please correct me if I'm misunderstanding, that trying to create safe abstractions is sheer folly so we might as well not do so. I've been writing Rust code for years now and I've never had to write unsafe code myself other than when interacting with C code and when doing so I've found issues with the way the API the C libraries were exposing having fundamental issues.
- greg7mdp 6y agoCould the effort be bootstrapped by using a C to Rust translator, like https://github.com/immunant/c2rust https://github.com/immunant/c2rust, preserving the existing semantics prior to updating the code to remove the "unsafe" tags.
- GuB-42 6y agoHaha, good luck porting QEMU to Rust. For those who don't know, the original author of QEMU is Fabrice Bellard. This guy has several winning entries in the IOCCC. One of them is a C compiler, that once de-obfuscated, forms the basis of TinyCC. QEMU C code makes heavy use of macros and gcc extensions. It really pushes C to the limit, it even broke my syntax analysis tools. Now, if the Rust community wants to write a new emulator in Rust, why not, but starting with QEMU may not be the easiest way.