TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Printf Oriented Message Protocol

106 点作者 Davidbrcz9 个月前

12 条评论

unwind9 个月前
This is innovative and kind of brilliant, I&#x27;m impressed!<p>- Binary message formatting for efficiency and data integrity (float to&#x2F;from string is messy)<p>- Familiar printf()-style format strings that the compiler can check[*] gives type safety!<p>- No preprocessing and&#x2F;or code generation from message templates or anything like that.<p>Really nice!<p>Edits: markdown and grammar.<p>[*]: This uses an extension I think to mark the argument as a format string
评论 #41237429 未加载
评论 #41241966 未加载
评论 #41243227 未加载
chrchr9 个月前
It reminds me of Perl&#x27;s &#x27;pack&#x27; and &#x27;unpack&#x27;.<p><a href="https:&#x2F;&#x2F;perldoc.perl.org&#x2F;perlpacktut" rel="nofollow">https:&#x2F;&#x2F;perldoc.perl.org&#x2F;perlpacktut</a>
评论 #41238232 未加载
评论 #41237725 未加载
fisian9 个月前
To mention a usecase for this library: it is used as part of the software Parrot ships with their drones.
评论 #41236184 未加载
immibis9 个月前
IIRC <i>Cube 2: Sauerbraten</i> uses a similar concept for network, though the format strings aren&#x27;t similar to printf (just a simple list of sized types) and the types&#x2F;format aren&#x27;t transmitted on the wire.
nurettin9 个月前
&gt; How the knowledge of the format string is shared is out of the scope of this library. It can simply be a shared header with defines.<p>They don&#x27;t force you to share the format strings at connection time. In fact, it is just a thin layer around sockets and you just override the message handler. I like it! Might be improved further with something like libfmt which is also used by spdlog.
jbverschoor9 个月前
How is the string length determined? How does this handle packed bits&#x2F; and odd sized numbers, for example a 5 bit digit and 3 flags
评论 #41236973 未加载
评论 #41236477 未加载
tonyg9 个月前
Feels similar to the dbus serialisation format.
inetknght9 个月前
I&#x27;ve used libpomp to interact with Parrot&#x27;s Anafi drones.<p>This library takes the idea of modern type safety and throws it away. Instead, the library leans in on `printf()` instead, which is known to be <i>un</i>safe. And it does it in a memory-unsafe language.<p>...on a drone. Where safety <i>needs</i> to be important (even a small drone can do significant damage).<p>It&#x27;s neat and all. But that&#x27;s a killer anti-feature in my opinion. I wouldn&#x27;t use it on <i>my</i> drones.
khimaros9 个月前
i wonder if there is anything equivalent to this for rust?
touringmachine9 个月前
This is very clever. Furthermore, lmao.
lukevp9 个月前
I don’t really get the advantage of this over either json (for human readability), protobuf (for type safety and schemas at the parsing layer), etc. it seems like it mostly has disadvantages and would be difficult to implement efficiently because there are not consistent characters to tokenize.
评论 #41235849 未加载
评论 #41235970 未加载
评论 #41236790 未加载
评论 #41236716 未加载
lanstin9 个月前
The format (%ii) semantics aren&#x27;t platform independent that seems like an obvious error.<p>And code gen and protocol descriptions bring a certain useful discipline to modifying existing protocols.<p>But it has that funky C style so I bet people using C like it.