> I've been working on that recently and I have some doubts about this > approach. Java and C++ share some features that Rust does not have. > hsivonen and I have worked around some of these mismatches, but it's been a > fair amount of effort already, and the translator is not that close to > producing Rust code that will even compile. ... > I think the biggest unknown is memory management.
Is this the only thing that's blocking compilation or is there something else, too? I thought the control structure translation was already OK a year ago. I hope I wasn't mistaken about the control structure part. > It's likely that an exact > copy of the C++ approach will upset the borrowchecker, requiring either > unsafe code or a more sophisticated translator. ... > The translator directly prints C++ or Rust code as it traverses the Java AST. > This makes it hard to implement anything beyond a close mapping of > individual syntax elements. Yes, if e.g. Rust unique pointer usage doesn't fit the JS/C++/Java code structure, it's not worthwhile to try to do machine translation. In that case, I'd expect developing a parser from scratch (or translating just the tokenizer control structure once as using that as a starting point) to be better. > Writing our own HTML5 parser would be a lot of work, but does not seem > infeasible. The parsers I've found (including the translated C++ code for > Gecko) are in the 10-20 KLoC range. Yeah, if translation doesn't work out fairly quickly, and it look we're are beyond "fairly quickly" by now, writing directly in Rust makes sense. > We can do a one-time translation from > Java for the most mechanical parts, without building a complete translator. Makes sense at least for the tokenizer. > At any rate we should > pay close attention to Gecko's parser design I think the off-the-main-thread design is worth copying. However, it's probably a good idea to design for a code path without the off-the-main-thread (or I guess task in Rust) overhead for innerHTML. See https://bugzilla.mozilla.org/show_bug.cgi?id=959150#c10 -- Henri Sivonen hsivo...@mozilla.com _______________________________________________ dev-servo mailing list dev-servo@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-servo