r/ProgrammingLanguages • • Sep 22 '18

Does anybody know of a language that compiles to bash?

Bash syntax is awkward and hard to read. It's also not strongly typed. It would be quite useful for have a language which compiles to bash (or sh for that matter) but is strongly typed. Does anybody know of one.

20 Upvotes

34 comments sorted by

View all comments

2

u/PegasusAndAcorn Cone language & 3D web Sep 23 '18

I believe /u/oilshell is working on something in this area, and may have some valuable perspectives to share.

3

u/oilshell Sep 25 '18

Yes, although I am focused on OSH-to-Oil translation more than Oil-to-bash translation (OSH being a cleaner but compatible version of bash.)

I've considered both strategies, and they're both interesting. Oil-to-bash is less work, but then you're still depending on the bash runtime, which has its own flaws (it's not just the syntax).

The strategy also runs into the "classic" problem of code generation -- attributing error messages. It sounds like it might be a small problem, but I think it can be a dealbreaker.

So I am going to focus on a new shell and OSH-to-Oil translation, but I hope someone comes along and contributes an Oil-to-bash convert for people who want it :)

A shell has very few dependencies though, so I don't think it should be a big deal to install Oil. I've tried to make the build process very simple.

1

u/CoffeeTableEspresso Sep 25 '18

This was my first thought on seeing this post too.