Wednesday, 4 January 2017

Getting Past C : Rust / Go

Getting Past C: "Now for the exciting questions: which language, and when?

We don’t have answers to those yet, but the field is narrowing and the time we might attempt a translation is getting closer - in the most optimistic case it could be as little as 6 to 9 months out. The catalyzing event is not just the emergence of two plausible candidate languages but the fact that both seem now to have reached a self-sustaining community size, so we can be reasonably confident they won’t croak and leave us stranded.

No prize for guessing that our two plausible candidates are Go and Rust.

There’s lots of web evangelism around both languages, so I’m not going to attempt a detailed comparison here. I’m just going to hit a few high points about how their traits intersect with NTPsec’s particular needs.

Probably the first question that will occur to a lot of you is: "Huh? Wouldn’t the stop-the-world pauses from garbage collection rule out Go? And the answer is…​they might, but (a) the actual time-critical sections in NTP are small and wrapped tightly around the clock-manipulation calls, and (b) Go’s runtime allows you to lock out GC during critical sections.

In any case, the Go developers have a pretty convincing story about holding stop-the-world pauses down to the small-number-of-milliseconds range. We’ll have to measure, but that just might be tolerable even without the GC lockout.

Still, the absence of GC overhead is a point in Rust’s favor. So is Corrode, the automatic C-to-Rust translator. The Go developers wrote a translator to move their Go compiler from C to Go, but it has no documentation and "Here Be Dragons!" warnings in the README.

Russ Cox’s talk on the C-to-Go translator claims it handles a large subset of C that notably does not include…​unions and certain kinds of goto. These are restrictions we can deal with. It may be usable. And if it’s not, maybe I can up-gun it until it is - language parsing and translation is a kind of problem I’m pretty good at and enjoy working.

In the end it might come down to which language I feel more comfortable in. (It’s good to be king the principal coder at times like this.) And I don’t know which that’ll be yet."

'via Blog this'

No comments:

Post a Comment