6

Is there a language, similar to what CoffeeScript is to JavaScript, that compiles to the language of the windows batch|cmd|command line?

The cmd versions I refer to are the ones based on NT, especially XP sp3 and up.

n611x007
  • 8,952
  • 8
  • 59
  • 102
  • 4
    What are you trying to achieve? – ChrisF Nov 04 '12 at 21:36
  • I don't think there is. You can lookup PowerShell, but it doesn't compile to `.bat` – John Dvorak Nov 04 '12 at 21:36
  • @ChrisF Batch is "preinstalled" on most NT-based windows box, but writing in cmd syntax is something I forgot very easily. – n611x007 Nov 04 '12 at 21:41
  • 1
    +1 Interesting idea. The traditional solution to the grave and utterly frustrating lack of basic features of the `.bat` interpreter has been to simply replace it with something a bit less dumb, but wrapping it with another language ought to be possible. Maybe the target audience was lured away by INTERCAL and Befunge? – tripleee Nov 04 '12 at 21:55

3 Answers3

9

Yes there is one language called Batsh, which compiles to both Bash and Windows Batch.

Project: https://github.com/BYVoid/Batsh

Online demo: http://batsh.byvoid.com/

BYVoid
  • 358
  • 4
  • 8
2

As far as I know, what you're asking for doesn't exist, although it would be possible to create such a language, and it would be an intersting exercise.

The alternative is other languages that are also "built-in" to the OS.

Others have mentioned PowerShell, which is very powerful, and is built in, I think, in Win7 and up.

The other alternative is the Windows Script Host for which you can write scripts in VBScript and/or Javascript. It's built-in to WinXP and up.

Andrew Cooper
  • 32,176
  • 5
  • 81
  • 116
  • It would be VERY difficult, because batch is a very limited language. It may be possible to generate a bash script. But I liked the idea of the question:-) – anishsane Nov 06 '12 at 11:39
  • @anishsane - I agree that it would be challenging, but `batch` is Turing complete so it is possible. Depending on the constrcuts in the language you're compiling you'd end up with some pretty gnarly batch code. – Andrew Cooper Nov 06 '12 at 21:33
1

Just for your edification, CoffeeScript is a domain specific language built on JavaScript, so you could in theory intermingle the two. I am not aware of such a language for batch files. The windows powershell might be worth a look see.

cowboydan
  • 1,062
  • 7
  • 15