Live data from Hacker News

Ubus (OpenWrt micro bus architecture)

openwrt.org

21–30 of 56 posts

Re: Ubus (OpenWrt micro bus architecture)

#21
post #6

Earlier quoted context omitted.

Considering the repo dates back to 2010 (predating Rust by 4+ years), there probably wasn’t a better option that could run on the embedded devices that OpenWRT targets.

The project age is good background info. However Rust didn't invent memory-safety, there were reasonable options for system programming at that time too (eg Ocaml, Go, Ada, etc). edit: Also D in safe mode like mentioend above - not sure if it was around in 2010?

Another consideration (apart from the 64MB ROM / 8MB RAM configuration OpenWRT targets, up from 32MB / 4MB in 2010) is that the original—and still very popular—platform for OpenWRT is Linux on big-endian MIPS, which does not exactly have ubiquitous compiler support outside of the C world. (Rust treats it as Tier 2, on par with Windows on ARM and Solaris on x86-64, which isn’t bad as these things go.) So—Go is about as realistic as Java, OCaml I don’t think runs on MIPS, neither does MLton, and IIRC the GNU Ada implementation was in a much worse state then. There’s also the part where the devs are by necessity C hackers, what with sorting out the manufacturers’ kernel patches and all.

Re: Ubus (OpenWrt micro bus architecture)

#22
post #19

Earlier quoted context omitted.

200k is very large in the OpenWrt world

Ada then? Eg on https://ada.godbolt.org/ you can see the default program compiled to ~25 lines of assembler. edit: actually it contains a call to a bounds check function that presumably is in the runtime library, i don't know how big that is. A major point in this is that C also has a fairly big runtime library that should be factored into the comparison!

> C also has a fairly big runtime library

The original releases of OpenWRT used uClibc, which is nowhere near Glibc levels of bloat (Musl beats it on code quality and is used today, but didn’t exist back then). Also, yeah, you’re going to have a libc on a Linux system no matter what, so this is one of the rare cases where dynamic linking makes for a legitimate optimization.

Re: Ubus (OpenWrt micro bus architecture)

#23
post #19

Earlier quoted context omitted.

200k is very large in the OpenWrt world

Ada then? Eg on https://ada.godbolt.org/ you can see the default program compiled to ~25 lines of assembler. edit: actually it contains a call to a bounds check function that presumably is in the runtime library, i don't know how big that is. A major point in this is that C also has a fairly big runtime library that should be factored into the comparison!

Current OpenWRT uses musl libc[1] which can be optimized to have a tiny footprint and supports full static linking, before that it used ucLibc which was similarly optimized.

You can still build software for OpenWRT that requires the much bigger Glibc, but of course it will not work that well on devices with limited memory.

[1]: https://musl.libc.org/

Re: Ubus (OpenWrt micro bus architecture)

#26
post #2

Did they consider using a memory-safe language for this?

A decent question, I've wondered about Rust programs on openwrt but at the moment they're just too big! Linking the stdlib into every binary doesn't help, and the code is generally larger than the C equivalent. It doesn't seem unsolvable though, I'm hopeful. no_std rust binaries can be near competitive with C.

Binary size is sometimes a big deal. Two decades ago I investigated using C++ for an "embedded" linux ssh server, but decided the 30kB overhead was too large (target was a 4MB laptop). The server ended up being used in OpenWRT and other places, I'm curious if it would have happened if I'd gone with C++ instead.

Re: Ubus (OpenWrt micro bus architecture)

#27
post #8

Story time.. I coded a similar thing when I started working after graduation for a DTV software company; we needed to have an IPC on Linux and I whipped up some very crude equivalent of protobuf (which I didn’t know about), based on an RLE lib i stumbled upon and without any form of discovery. It was circa 2009, I had only been exposed to plain text protocols and didn’t know about json. In hindsight, we might’ve been…

Only if you choose to be a plumber. You can equally write new things if you want.

Also I think "any problem is solvable" needs some qualification - there are a ton of problems that have yet to be solved or are super complicated. I still haven't figured out how unbounded model checking works for example.

Re: Ubus (OpenWrt micro bus architecture)

#28
post #23
post #19

Earlier quoted context omitted.

Ada then? Eg on https://ada.godbolt.org/ you can see the default program compiled to ~25 lines of assembler. edit: actually it contains a call to a bounds check function that presumably is in the runtime library, i don't know how big that is. A major point in this is that C also has a fairly big runtime library that should be factored into the comparison!

Current OpenWRT uses musl libc[1] which can be optimized to have a tiny footprint and supports full static linking, before that it used ucLibc which was similarly optimized. You can still build software for OpenWRT that requires the much bigger Glibc, but of course it will not work that well on devices with limited memory. [1]: https://musl.libc.org/

Musl libc seems to be 2 MB ish, it's smaller than glibc but still something when comparing to other languages and their runtimes.

Re: Ubus (OpenWrt micro bus architecture)

#29
post #26
post #2

Did they consider using a memory-safe language for this?

A decent question, I've wondered about Rust programs on openwrt but at the moment they're just too big! Linking the stdlib into every binary doesn't help, and the code is generally larger than the C equivalent. It doesn't seem unsolvable though, I'm hopeful. no_std rust binaries can be near competitive with C. Binary size is sometimes a big deal. Two decades ago I investigated using C++ for an "embedded" linux ssh se…

>I'm hopeful. no_std rust binaries can be near competitive with C.

I feel like Rust without std might as well be a different language. Almost all of the available mindshare, docs, libraries are dependant on it.

Sure, you can use it. But to me it just looks like technological poverty. Even compared to the C ecosystem.

Re: Ubus (OpenWrt micro bus architecture)

#30
post #29
post #26

Earlier quoted context omitted.

A decent question, I've wondered about Rust programs on openwrt but at the moment they're just too big! Linking the stdlib into every binary doesn't help, and the code is generally larger than the C equivalent. It doesn't seem unsolvable though, I'm hopeful. no_std rust binaries can be near competitive with C. Binary size is sometimes a big deal. Two decades ago I investigated using C++ for an "embedded" linux ssh se…

>I'm hopeful. no_std rust binaries can be near competitive with C. I feel like Rust without std might as well be a different language. Almost all of the available mindshare, docs, libraries are dependant on it. Sure, you can use it. But to me it just looks like technological poverty. Even compared to the C ecosystem.

I'd disagree. Using something like Embassy is pretty pleasant for embedded development, less worries than C. The only issue is maturity.

There were sufficient crates to write a ssh server for a rp2040 (mostly out of curiosity) using what's available in no_std.

Post reply on HN