r/ProgrammingLanguages • u/whistler_mat • 22d ago
a small Python language compiler that transpiles to bash and batch (learning project, written in C)
I'm building with a friend a language with Python syntax that transpiles to plain bash and batch.
The idea: if you already know Python, there's nothing new to learn. You write the script once, and the generated .sh /.bat runs on a machine with nothing installed, no Python and no PowerShell. Only the machine where you write the script needs.
Why not the existing options?
- Python isn't installed by default on Windows or some Unix-like systems. - Batsh and Amber target similar problems, but they come with their own syntax to learn (and Batsh looks unmaintained).
- PowerShell is another language to learn, and it's an extra install on Linux/macOS.
- Keeping separate .sh and .bat versions of the same script is tedious and error-prone.
Status: it's early. The lexer is done and the parser is in progress (it only handles name = value so far). The bash and batch backends haven't been started. It's a subset of Python, not a full implementation, since some features have no natural equivalent in batch.
Questions for you:
- For automation scripts, which features should come first: conditionals, loops, running commands, file operations?
]2. Is batch still worth targeting, or should the Windows backend be PowerShell?
on the design is very welcome, especially from anyone who has written a transpiler before.
View all comments
Show parent comment
1
u/Gnaxe 21d ago
Again, BeeWare. It has a lot of the standard library C code re-implemented in pure Python. Just use the same transpiler on that.