China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-29 00:15
中国DOS联盟论坛 » DOS疑难解答 & 问题讨论 (解答室) » [Discussion] Comparing Batch Files and Programming Languages — Just Throwing Out Some Ideas View 652 Replies 3
Original Poster Posted 2005-04-14 00:00 ·  中国 湖北 武汉 电信
初级用户
ProGamer
Credits 129
Posts 23
Joined 2005-04-14 00:00
21-year member
UID 38147
Gender Male
Status Offline
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
I'm a progamer who work with windos
not a programmer with windows
Floor 2 Posted 2005-04-14 00:00 ·  中国 山西 临汾 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
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.
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 3 Posted 2005-04-14 00:00 ·  中国 湖北 武汉 电信
初级用户
ProGamer
Credits 129
Posts 23
Joined 2005-04-14 00:00
21-year member
UID 38147
Gender Male
Status Offline
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
I'm a progamer who work with windos
not a programmer with windows
Floor 4 Posted 2005-05-22 00:00 ·  中国 山东 济宁 电信
中级用户
★★★
痴迷DOS者
Credits 456
Posts 570
Joined 2004-10-09 00:00
21-year member
UID 32281
Gender Male
Status Offline
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
DOS不是万能的,没有DOS是万万不能的
自古系统谁无死?留取胆清照汗青!uploadImages/20035317345478982.png
Forum Jump: