> If you have an IoT device and want to share logic between the device and cloud ... You could represent the logic in C but arguably something like JS is better suited
Is this ever realistically the case? JavaScript aside, I would expect there to be an interface layer in the form of some compact protocol (e.g. CoAP) for communication and for the IoT device to be doing as little as humanly possible.