Earlier quoted context omitted.
I think any language with a large runtime would be out of the question, because Openwrt has to fit into system with very limited storage.
To put it in context: On some devices you have 32MB flash storage in total . 32 Megabytes, not gigabytes. This is not a typo. This needs to fit the bootloader, the Linux kernel, the initrd, the rootfs containing all the user-space tools making OpenWRT an actual usable OS and whatever daemons you need to implement your particular network needs. Oh and you probably want the WebUI too. In 32MBs. There are newspapers onl…
Ubus (OpenWrt micro bus architecture)
11–20 of 56 posts
Re: Ubus (OpenWrt micro bus architecture)
#12iw event | awk '/new station/ {print $4}' | xargs -n 1 sh -c 'ubus send new_station {\"mac\":\"$1\"}' _
(Yes, this contains silly hacks to work around busybox limitations)
Re: Ubus (OpenWrt micro bus architecture)
#13Earlier quoted context omitted.
I think any language with a large runtime would be out of the question, because Openwrt has to fit into system with very limited storage.
To put it in context: On some devices you have 32MB flash storage in total . 32 Megabytes, not gigabytes. This is not a typo. This needs to fit the bootloader, the Linux kernel, the initrd, the rootfs containing all the user-space tools making OpenWRT an actual usable OS and whatever daemons you need to implement your particular network needs. Oh and you probably want the WebUI too. In 32MBs. There are newspapers onl…
Re: Ubus (OpenWrt micro bus architecture)
#14Re: Ubus (OpenWrt micro bus architecture)
#15In case you want to react to stuff connecting to your router via ubus: iw event | awk '/new station/ {print $4}' | xargs -n 1 sh -c 'ubus send new_station {\"mac\":\"$1\"}' _ (Yes, this contains silly hacks to work around busybox limitations)
Re: Ubus (OpenWrt micro bus architecture)
#16Earlier quoted context omitted.
To put it in context: On some devices you have 32MB flash storage in total . 32 Megabytes, not gigabytes. This is not a typo. This needs to fit the bootloader, the Linux kernel, the initrd, the rootfs containing all the user-space tools making OpenWRT an actual usable OS and whatever daemons you need to implement your particular network needs. Oh and you probably want the WebUI too. In 32MBs. There are newspapers onl…
This is a good point. But Ocaml and Ada are not in the 2MB helloworld club (eg Ocaml is more like 200k), don't know about Go. Also accounting that to a single binary is not the right perspective I think - adopting a safe language in OpenWRT should be arranged so that all the programs using that language can share the same copy of the runtime.
Re: Ubus (OpenWrt micro bus architecture)
#17In case you want to react to stuff connecting to your router via ubus: iw event | awk '/new station/ {print $4}' | xargs -n 1 sh -c 'ubus send new_station {\"mac\":\"$1\"}' _ (Yes, this contains silly hacks to work around busybox limitations)
I'm pretty sure that there already is an event emmitted upon station connection
Re: Ubus (OpenWrt micro bus architecture)
#18Did they consider using a memory-safe language for this?
There is no real case to be made against the idea of memory safety, but there is a case to be made for C. You can write C code such that its unit tested, fuzzed, statically analyzed and reviewed, and often embedded code has one or two specific jobs. I would have loved to see Zig here, as it makes all of the above (testing, analysis, code clarity for review) easier, but its also not memory safe necessarily. You could…
I'm not saying C is a wrong choice here, but this argument doesn't make much sense to me. All the other languages also come with "useless garbage" (some even with a collector for them). I don't see why you'd need that many unsafe blocks either.
I feel like Rust, as a language, is much better equipped for writing a daemon like this. I'll even go as far as to say that modern C++ (C++2x) is a better choice than C for this stuff with its superior memory and resource management tools.
Of course most of the OpenWRT development is done in C, so doing it in another language requires a very good reason. I wouldn't look at the concept of "a networked daemon exchanging messages between arbitrary services" and think C of all languages is a good fit unless every other developer on the team can only write C.
Zig would've been a nice way to meet halfway, but the language isn't finished yet.
Of course the point is moot because this particular project existed years before any of the modern alternatives or many of the C++ improvements were even available. Still, if they'd start a project like this again, I'd hope they'd pick a better language for it.
Re: Ubus (OpenWrt micro bus architecture)
#19Earlier quoted context omitted.
This is a good point. But Ocaml and Ada are not in the 2MB helloworld club (eg Ocaml is more like 200k), don't know about Go. Also accounting that to a single binary is not the right perspective I think - adopting a safe language in OpenWRT should be arranged so that all the programs using that language can share the same copy of the runtime.
200k is very large in the OpenWrt world
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!
Re: Ubus (OpenWrt micro bus architecture)
#20Earlier 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!
But libc will be there anyways, unless you are rewriting absolutely all of userland.