-1

Scripting Batch files was the first type of "programming" I learned when I was younger and I remember I used to make my own text games and everything. I don't know why, but I really like the simple yet sometimes puzzling style of Batch/CMD commands. I guess the flow has just been ingrained in my mind haha. Writing complicated programs was almost a puzzle within itself, trying to find a way to break the limits of the command prompt.

But now I'm curious if there are any more-advanced languages with similar style to it. Any suggestions?

Note: Excluding Visual Basic/VBA. I hate it. Too many nights spent frustrated with Excel and Access have worn me out haha.

html5468
  • 17
  • 1

3 Answers3

2

There's no language that have resemblance to the unintuitive for loops in batch neither it's approach to the variables (at least I don't know such).

Your best picks are PowerShell (which has some cmdlet aliases close to the commands in cmd) and KiXtart which borrowed some things from batch, though it's syntax is more close to VBScript.

Due to batch limitations most used techniques to address that are the hybrid scripts (two languages used in the same file - you can expose the more complex logic in other language and keep the core script in batch):

  1. JScript - uses the WSH built-in version of JavaScript that allows you to use ActiveX and WMI objects and the functions from Windows Script Host. The most popular approach.
  2. VBScript - VBScript syntax is not convenient, but in some cases can do things that JScript can't (passing by reference). You can use both JScript and VBScript with the hack in the link.
  3. HTA - mainly when UI is needed - can use both JScript and VBScript without direct access to the WSH functions.
  4. PowerShell - installed by default since Windows 7.Both one line executed commands and hybrids can be used.
  5. .NET - since Vista, every Windows comes with installed .NET framework and C#, Visual Basic and JScript .NET installed. You can use them with batch file but an additional .exe file will be created. Though since .NET Framework 4.6 (comes installed with Windows 10 and can be installed on the older versions too) the msbuild tool comes with inline tasks that allows you to use C#/Basic/JScript .NET without temp files. With C# and Basic you can use Platform Invoke which gives you access to the Windows Core Functions (unmanaged code) - something that cannot be achieved with WSH. .NET is the most powerful tool but slower and less backward compatible.
Paul Wilson
  • 68
  • 1
  • 5
npocmaka
  • 51,748
  • 17
  • 123
  • 166
0

Syntactically speaking I think Tcl/Tk is the language you are looking for. It supports loops and conditions while keeping the "everything is a command" feel. While I don't know if you can do with it what you can do with Bash(os based operations, you'll have to look into it yourself), you can implement pretty much any application that can be implemented with a programming language. I also want to add that it is the first time I heard of games in bash, and while there are better ways of doing it, it sounds quite challenging to implement and looks like lots of fun :)

Conclusion

If you want a command based programming language go with tcl. If you are still looking for the cmd challenge maybe powershell will do the trick (I can't write any more about it because I didn't use it)

0

Batch file scripts are executed by a command shell interpreter. Originally command.com, but now cmd.exe.

If it is the puzzling feeling you get from writing batch files that you want, why not just choose another shell. Developing you bash skills would provide a far more powerful language which includes for loops and variables.

In addition to running on just about anything that calls itself a computer, it is free.

lit
  • 10,936
  • 7
  • 49
  • 80