中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-17 08:48
47,813 topics / 349,904 posts / today 1 new / 48,259 members
DOS疑难解答 & 问题讨论 (解答室) » [Discussion] Comparing Batch Files and Programming Languages — Just Throwing Out Some Ideas
Printable Version  701 / 3
Floor1 foxandmonkey Posted 2005-04-14 00:00
初级用户 Posts 23 Credits 129
Usually a dedicated programming language needs a specific compiler and even a runtime, while the compiler and runtime for batch files are just the cmd provided by Windows, which saves a lot of the prerequisites the former needs. It can even directly call system routines, like shutdown, and that is very hard to do in a simple programming language (such as TC2). So DOS has the advantage of write-and-run immediately. Finished batch files can also be compiled into machine code with programs like bat2com and com2exe, which is convenient for protecting one’s ideas.
The command line can replace graphical operations to complete transactional tasks simply and precisely, and can even handle some simple numerical calculation problems. For example, the classic “Tower of Hanoi” problem can be solved with a batch file right on the desktop without relying on a dedicated language. This advantage is especially meaningful when you temporarily run into a problem outside that needs computer calculation.
I’d like to discuss with everyone just how strong DOS really is in programming.
I think the elements a programming language should have are:
1. Variables ----- In DOS you can use set and %c. Can they only represent integers and strings?... Complex data structures --------- arrays, structs... probably not, right?
2. Mathematical operations -------- + - * / logic, shifts
3. Modularity --------- Functionality similar to functions or procedures can be done with goto, and that’s fairly convenient
4. Libraries ----- This is really great! The libraries for batch files are all DOS internal and external commands plus those in path, especially those in system32, which is much more convenient than high-level languages calling system routines
5. Branch control --------- Are IF and FOR the only two available?
6. Input/output ------ I only know three kinds: command-line arguments, choice, redirection, and pipes. I don’t know whether there are others, such as output to a printer or memory
7. Graphical interface -------- I don’t know whether drawing functions or winform calls can be done in DOS. I found the tree command in XP cmd very interesting, it has a bit of a graphical feel
8. Low-level operations ----- debug, this is very powerful! But it’s used little in .bat, asking for materials ing
That’s about all I can think of. Please correct me and add to it, teachers.
Thanks
Salute
Floor2 willsort Posted 2005-04-14 00:00
元老会员 Posts 1,512 Credits 4,432
Re foxandmonkey:  Very well summarized. It’s really rare to see such an insightful post. I can see the OP put a lot of work into it, and I salute the OP.  Just a little supplement:  1. Scripting languages: batch files are also a kind of scripting language. In the big family of scripting languages, their status actually is not very high. In UNIX-like systems, SHELL is an outstanding representative of this kind of language, basically already very close to compiled high-level languages. There are even more scripting languages on the Internet, js, vbs, perl, and so on, each with its own characteristics. But batch files win in that they exist in the well-known and commonly used DOS and Windows, and they are simple and easy to learn. So their popularity is much higher.  2. About variables: for DOS or Windows systems, all variables are strings, not integers. Only in special command and program interfaces are they converted into integer and other types of variables (for example for and set /a). Of course, if you want to implement complex data structures, then you need other specialized data programs. High-level languages merely integrate this data handling into the compiler.  3. Arithmetic operations: DOS systems do not include this function. Only set /a under NT has this implementation. Then the other functions you mentioned need third-party programs to implement. Under DOS, the better-known one should be eval, which supports many kinds of operations and types.  4. The library issue: what you mean should be something like “standard library” and “system library,” right? Actually, what we more commonly use is the “custom library” under the current path, namely third-party tools and programs. Also, API functions can be used in batch processing. Besides using Rundll32, you can also dynamically create tiny PE programs to call APIs that Rundll32 cannot call.  5. Graphical interface: this question is rather obscure. Most implementations are quasi-graphical, such as Wbat. Earlier UCDOS had special display functions, and you could use “escape sequences” to call the graphics functions in the UCDOS SDK, but I rarely use them. In addition, using the Qbasic that comes with DOS for drawing, or using DEBUG to call the DirectX/OpenGL libraries, are also possible approaches. However, I rarely see such usage.
Floor3 foxandmonkey Posted 2005-04-14 00:00
初级用户 Posts 23 Credits 129
We already have very few DOS courses in college now. Last time I wrote a loop brute-forcing a permutation/combination problem, and for looks I wrote it in C#. But when I took it to the target machine, just the runtime environment alone was a headache. That machine was 98; first it said it needed the .NET Framework, then after I copied over dotnetfx it wanted IE5.5+
With bat, three for loops got it done. Back to simplicity, anytime, anywhere
Floor4 defrag Posted 2005-05-22 00:00
中级用户 Posts 570 Credits 456
I like to use batch files for the outer shell, BASCOM2.0 for the inner core, and add line numbers, then things like graphics, arithmetic, variables, low-level operations, and so on can all be implemented
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023