← Back to context

Comment by zozbot234

5 years ago

> This article is about a new Clang extension:

> An exciting feature just landed in the main branch of the Clang compiler. Using the [[clang::musttail]] or __attribute__((musttail)) statement attributes, you can now get guaranteed tail calls in C, C++, and Objective-C.

> What does Rust have to do with this? Nothing.

Rust has a planned keyword for this exact feature, namely 'become'. So the author would be able to use it in Rust just as well, as soon as support for it lands in an upstream LLVM release.

Regardless, writing raw C as the article suggests in order to parse a quasi-standard high-level format is cowboy coding. It's a nice hack to be sure, but it's not the kind of code that should be anywhere close to a real production workload. Instead, this feature should be implemented as part of some safe parser generator. Not necessarily written in Rust but something that's at least as safe.

> Rust has a planned keyword for this exact feature, namely 'become'. So the author would be able to use it in Rust just as well, as soon as support for it lands in an upstream LLVM release.

The author is demonstrating a new Clang feature. Then, again, what is the point of mentioning Rust?

> writing raw C as the article suggests in order to parse a quasi-standard high-level format is cowboy coding.

So what? Cowboy coding lets you appreciate even more languages where you don't need to do it, AND gives you a better understanding of how they might work.

> it's not the kind of code that should be anywhere close to a real production workload.

Again, not a single time in the article the author suggests that.

> Instead, this feature should be implemented as part of some safe parser generator

Which safe parser generator would you recommend for writing a protobuf parser (preferably one that yields at least 25% of the throughput claimed by the OP)?

Full disclosure: I believe there is no such thing, and if what you're asking the OP is to write one, it would likely benefit greatly from generating code that leverages tail recursion. Yeehaw!

I think you might need a reality check and see how many systems run C code in production.

  • No cowboy would treat their servers like cattle.

    Joke aside, the Linux kernel is mainly developed in C and runs in production everywhere.