LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Domain Specific Language (https://www.linuxquestions.org/questions/programming-9/domain-specific-language-4175469062/)

stateless 07-09-2013 07:38 PM

Domain Specific Language
 
If I wanted to create a small DSL to help manage a (custom) Linux system, what would be the easiest way to go about it? Is there some snazzy programming language out there just for making DSLs and their interpreters? Or maybe a module in another language that is super easy to use and figure out?

In my case, the DSL would center around managing system allocation resources (e.g, "allocate 1000 hours to project xyz") and accounts (e.g., "create project xyz") and have the interpreter execute the correct shell commands or database procedures.

My background is in FP languages, but I'm open minded here to whatever involves the least amount of work.

ta0kira 07-10-2013 02:39 PM

You might be better off writing a library or an extension for an existing programming language. I know that in Python, among other languages, you can fill the global namespace with functions and objects, then interpret an arbitrary file within that namespace. This allows you to encapsulate the program logic in Python or C, and load snippet files that access program hooks. The snippets can merely be a series of function calls that can be written by someone with minimal programming experience, since Python has a minimalistic syntax. At the same time, it also allows you to iterate over a list if you have a lot of repetition. The persistent state allows you to modularize the setup, e.g. set up accounts in one snippet file and allocations in another, so you can use "inert" accounts for testing purposes while you make sure your allocations work properly.

I've used this as a cheap way to incorporate a configuration parser and run-time extension framework into an existing C++ application, but you can certainly do it entirely in Python. And, as others will invariably point out, Python is just one of many options.

Kevin Barry


All times are GMT -5. The time now is 04:50 PM.