Programming Languages: Choices for OpenWrt – Mislav Novaković [OpenWRT Summit 2018]

What is the best language for prototyping in OpenWRT?

Trade-off between speed of development and limited resources in the devices.

C/C++ is a low-level language. Fully supported in OpenWRT, supported on all platforms. C/C++ code can be wrapped to other languages with SWIG.

Python has good support in OpenWRT, easy to integrate C code. Take care of differences between Python 2 and 3.

Lua is extremely light-weight, heavily used in OpenWRT (UCI and LuCI), easy to integrate C code. Take care of differences between Lua 5.1 and Lua 5.2/3.

Go is compiled. Always statically linked, so binaries are large. MIPS is not fully supported. Good for prototyping because a lot exists already.

Rust is compiled, statically linked, but sizes are much smaller than Go. MIPS is not fully supported. More difficult to write than Go. Lots of correctness guarantees. Not supported in OpenWRT.

Nim is compiled to C or JavaScript, very easy to cross-compile (just point to the C cross-compiler). No OpenWRT integration, no release yet either.

Node.js is a JavaScript runtime. Heavy.

Perl is a dynamic language.

PHP is a server-side scripting language. Supported in OpenWRT.

Ruby is a dynamic language, OO. Good OpenWRT support. Slow.

Binary sizes: C and C++ are equal and very small (4KB). Go is huge, Rust is large, Nim is not bad. Scripting languages need a lot of additional libraries, especially Python and Node.js. Ruby, PHP and Perl are not too large. Lua is very small (400KB).

For an HTTP server, Nim, C, C++ and Perl are the fastest. Go and PHP are also pretty fast since they’re optimised for that. Rust, Node.js and Lua are half as fast as C. Lua an Python are the slowest.