The source code for DSM (at least version 5.x at present) is available for you to browse through here:
https://sourceforge.net/projects/dsgpl/ ... %20Source/
From there you'll see lots of bash scripts, and mostly compiled C for running the actual hardware side, with PHP and CGI scripts for accessing that from the Web GUI
The rest is a combination of existing packages.
New packages can be written in all sorts of languages and many used by people regularly include Java, Python, .NET (via mono) and C with some web-based tools using PHP and CGI.
Now, given Docker support on higher end devices, you can run pretty much whatever you like too!