3 ms·
I created a programming language called NCD. It is a mostly imperative language but where each statement can make the program backtrack to that point. The origi
by ambrop7 10y ago
I created a programming language called NCD. It is a mostly imperative language but where each statement can make the program backtrack to that point. The original intended use case was for configuring the network on Linux but it is really practical for similar things like starting programs based on the presence of hardware.
The interpreter is written in C and is open source [1]. There is quite some old documentation here [2] (needs to be moved, this was from a google code wiki). An online demo with several example programs can be found in [3] but it does not have all the latest features of the language.
The interpreter is completely asynchronous (uses epoll etc; this is why the Javascript demo was so easy). It has many build-in modules that allow to do quite a lot of things (including sub-processes with pipe I/O, TCP client and server, receiving events from input devices, observing devices through udev events).
The language is actually built from a relatively small core which defines the syntax and basic semantics, and a larger set of modules which implement different statements. Many of what would in other languages be part of the language exists as a module in NCD, e.g. the var() statement and even If.
And here [4] is a real program written (mostly) in this language, that does something completely different from network configuration (allows controlling a Sphero robot using a joystick).
[1] https://github.com/ambrop72/badvpn/tree/master/ncd https://github.com/ambrop72/badvpn/tree/master/ncd
[2] https://github.com/ambrop72/badvpn-googlecode-export/blob/wiki/NCD.md https://github.com/ambrop72/badvpn-googlecode-export/blob/wi...
[3] https://rawgit.com/ambrop72/badvpn-googlecode-export/wiki/emncd.html https://rawgit.com/ambrop72/badvpn-googlecode-export/wiki/em...
[4] https://github.com/ambrop72/spherojoy https://github.com/ambrop72/spherojoy