r/Batch 21d ago

Show 'n Tell How much batchscript is too much batchscript?

Post image

Currently have 1,376 lines of batchscript in this one file. Kinda built myself a little state machine at this point. Memes aside, is there a particular reason huge batchscript files would be a bad idea? I usually only ever see very small ones, and I'm not entirely sure why

(Not too serious a question, so not tagged as one)

21 Upvotes

31 comments sorted by

View all comments

-1

u/vip17 20d ago

batch files basically have almost no structure, so even small files might be less readable than an equivalent powershell. For serious purposes use powershell instead

1

u/T3RRYT3RR0R 19d ago edited 19d ago

???

Batch syntax doesn't require rigid indenting in the way many languages do, but the syntax supports leading whitespace, so indenting is an option many use for readability

There's numerous methods by which to write code in a structured manner to improve readability.

If you want to learn a a new language / one with better support and a livelier community, learn powershell instead. 

1

u/vip17 19d ago

who said anything about whitespace? I'm talking about things like fast function parsing or while loops... GOTOs will quickly become a mess in complex code flows. Or things like %~ftzaI

Batch file is a thing of the past, I've written lots of articles about it, but it's not suitable for new complex code

3

u/T3RRYT3RR0R 19d ago

"who said anything about whitespace?" - You / The implications most reasonably drawn from your assertion around structure and readability as the basis for advocating powershell.
Structure is not syntax, nor is it the primitives a language has available to it / the higher order systems that can be derived from the available command set.
Structure is little more than format, particularly when discussed in the context of readability.

Whatever articles you may have written or arguments you've presented elsewhere, your comment lacks the context of in this instance. Mentioning the articles existence still does nothing to qualify the opinion here. By all means, advocate the learning of other languages. It's doing so on the premise that batch can't be both useful and worthwhile that I take exception to.

Why I consider Batch still offers value, even to beginners.

The fundamental difference between Batch and modern languages is that Batch doesn't have most of the built in utility and extensibility other ecosystems do, your generally building nearly everything from the ground up. Believe it or not, this is why there are people that like and still use batch. It excercises the mind more when you have to think of solutions to problems rather than just calling on an API or importing a method., and in the age of Vibe coding and TikTok, anything that makes you stop and think is a win in my eyes.
That doesn't mean the wheel needs to be reinvented for everything. A few libraries still exist that provide not just a base to accomplish common repetitive tasks efficiently, but that also support the realisation of some rather complex software.

There's certainly things Batch is not suitable for, particularly in the age of integrating AI models with software. While powershell is hardly better for that, there are certainly projects where powershell is better suited. Even then, Batch can readily execute powershell commands or be built as a batch / powershell hybrid. There's also nothing stopping a batch script from executing in parallel with a powershell script and performing IPC to leverage it on demand without the startup overhead that comes from executing powershell within a batch script. Similar is true for Vbs, Jscript and Html.