Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Vorpal

DOS Programming - Advice?

Recommended Posts

I've never programmed before, and I have near zero interest in learning modern languages for use on modern equipment. However I have long had the nagging desire to maybe get old equipment to do stuff, I have a strange fondness for those clunky UIs of the 90's (e.g. DeHackEd).

The other day I resurrected my 90's PC (CRT and all, only 1 failed harddrive!) and also found a GW-BASIC textbook and have been reading it in my spare time, and am feeling like actually putting this effort into some kind of action.

Anyone have any advice on learning resources, or even what I should learn? I did try spending 2 days learning TurboC but powerfully hated it. I feel like I would need a more formal computer science education in order to attack the C variety of languages. But is BASIC a total dead end? Are there any other useful and/or newbie friendly languages from the DOS era?

I feel like I'm going into this blind!

For now I have:

QBasic 1.1
QuickBasic 4.5 (seems like QBasic, except can compile to an executable?)
PDS 7.1 (haven't used though, not sure if I will need it)
GW-BASIC textbook

Share this post


Link to post

Care to elaborate? Version numbers and reasons why I should learn those instead? I find the vast web of compilers difficult to navigate through.

Share this post


Link to post

You're probably going to get frustrated just setting up the compiler under DOS than actually learning the language. If your BASIC software is working, keep using that. It'll teach you the concepts of programming, and it'll be easy to switch languages from there. Too many newbies get hung-up on what language is best, when really early on the most important thing is just getting something working.

Share this post


Link to post

I'd advise against starting with BASIC, since it encourages a number of bad habits such as the GOTO statement.

My suggestion for people new to programming is usually to start with a modern high level language like Python, and progress on to other more difficult languages. When you're a beginner, you're learning fundamentals like assignment and sequence, the basic building blocks of how a program is written. Python is a good language because it presents the minimum amount of boilerplate to do that.

But you've said you have no interest in learning modern languages. Can I ask why? Fact is, modern languages are far better than what we had back in the '80s and '90s for learning programming. Once you've learned the basics, they're transferable skills that you can use to learn a language like C (under DOS) if that's really what you're interested in.

Share this post


Link to post
fraggle said:

But you've said you have no interest in learning modern languages. Can I ask why?


All my early childhood computer experiences were with DOS so it holds a sort of fascination in me. Also I am curious how stuff was done back then, how our favorite programs were made. Plus I believe limitation inspires creativity, like how so many flock to the doom engine for various projects. Lastly I am completely overwhelmed by the current programming landscape, SO many languages, compilers, IDE this IDE that, bug tracking and "best practices" and so on. I just want to bumble about on something simple and maybe get some very old hardware to Do Stuff(tm).

Share this post


Link to post

I get the nostalgia. But FWIW nothing about Python necessitates using an IDE. I've never used one with it. Most of the stuff I've ever written with it has been command line scripts, just like it was under DOS.

Share this post


Link to post
fraggle said:

I'd advise against starting with BASIC, since it encourages a number of bad habits such as the GOTO statement.

Not true if it's QBasic, as it comes with the whole suite of decision and looping blocks we know and love (IF, WHILE, DO...LOOP, SELECT CASE). Pretty sure you can avoid using GOTO or GOSUB...RETURN. I think its only problems are lack of built-in pointers (you have to use ugly memory-accessing functions) and (if I'm not wrong) lack of function pointers. But still, even when I was little, I thought Basic, as well as Visual Basic, were toys, not giving me enough possibilities to make real apps.

I suppose there are Python compilers for DOS, because the topic is DOS programming…

This thread interests me a bit if the discussion shifts to something like Borland Turbo C++ or Pascal or DJGPP or Watcom. I'm interested in making portable DOSBox applications that will work on all platforms that can run DOSBox.

Share this post


Link to post

Python 2.4.2 is the last version available for DOS. Assuming you don't want to just join the people who have moved on to Python 3, I consider using 2.7 to be pretty much mandatory these days.

Turbo Pascal seems like an okay choice if you're really bent on programming for DOS.

Share this post


Link to post

Printz reminded me of the last time I looked at QBasic. It had lots of documentation about various DOS graphics modes. Kind of interesting, but BASIC is still frustrating to use.

Getting compilers from the 90s to work was often more difficult than the programming problems in the books we tried to learn from. Huge motivation killer.

Share this post


Link to post

Speaking of books,
Does anyone know a good comprehensive book on C/Java?

One that explains the language, its features, and how to use them?

Share this post


Link to post

Since I've heard Pascal mentioned a few times I think I will give that a go for a few days and report back!

Share this post


Link to post

I'd say just go with what ever you find interesting and helps you get something on the screen asap with minimal busywork. If you already have the BASIC environment set up and a related textbook then that's all you really need. Pick something you'd like to make and start experimenting.

You can learn all about modern languages and practices later if it's something you're still interested in.

Share this post


Link to post
printz said:

Not true if it's QBasic, as it comes with the whole suite of decision and looping blocks we know and love (IF, WHILE, DO...LOOP, SELECT CASE). Pretty sure you can avoid using GOTO or GOSUB...RETURN.

It's a question of "can avoid" vs. "every single BASIC tutorial will teach you to do it the wrong way". The bad habits are essentially baked into the culture of the language, and you can't expect programming newbies to know what they should avoid.

I myself wrote a lot of QBASIC code back in the day and my code was full of GOTOs. Took me several years to unlearn all that.

Share this post


Link to post

You're blaming QBasic for the mistakes of the tutorial authors who were used to older versions that indeed had GOTO and line number design.

Share this post


Link to post

No, I'm being realistic about a language with some fundamentally bad design decisions in its history.

Share this post


Link to post
Voros said:

Speaking of books,
Does anyone know a good comprehensive book on C/Java?

One that explains the language, its features, and how to use them?


For C nothing beats K&R which was written by the designers of the language. Make sure to get the 2nd Edition because the 1st edition uses the pre-ANSI syntax that hardly anybody uses now.
Once you've gotten good at C, make sure to read this book which covers more advanced concepts. If you want to program for a specific operating system, I recommend this book for the Win32 API. The only problem is that it's kind of old, so a lot of the stuff in there is out of date or deprecated. I haven't found anything better yet, outside of the official documentation on MSDN. If you want to program for UNIX/Linux, there's not as much good books. I've heard this one is good, but it might not cover basic things.

I use Java a lot for research and work, but I haven't found any amazing books for it like I did for C, especially since I was taught the language rather than learning it by myself. The Java tutorials work fine if you are familiar with another programming language, but they may be hard for a beginner. When I have something I want to do in Java, I usually look it up on Google. First I check the official documentation, and if I still can't figure it out, look for a Stack Overflow answer. That usually does the trick.

Share this post


Link to post

FreePascal maintains a DOS version, it wouldn't be too bad to go along with that...

Still, you're just setting yourself up for a lot of hurt by trying to stick with DOS. Just learn Python first on a modern Linux or Windows and you'll be far better off.

Share this post


Link to post

You should instead learn how to program properly for a modern system and language before you go back to DOS for nostalgia. You can also just use cross compilers (such as Open Watcom or DJGPP) and use modern version control for your code, and then just run your code on an actual DOS system.

Tosi said:

For C nothing beats K&R which was written by the designers of the language. Make sure to get the 2nd Edition because the 1st edition uses the pre-ANSI syntax that hardly anybody uses now.


It is 2016 and the latest C standard is C11, he may be better off with a book which starts at C11 such as C Primer Plus. Any habits you learn for C89 you will just essentially have to break out of anyway if you want your code to be portable. Stuff such as using char* for data instead of uint8_t.

Tosi said:

Win32


Microsoft essentially just encourages that you program in C# now. However, Java has better supported virtual machines across the common platforms and is used more in the corporate world.

Tosi said:

If you want to program for UNIX/Linux, there's not as much good books.


Many UNIX-like systems come with manual pages which document everything, thus books are not really needed because the documentation is usually standard on every system.

Share this post


Link to post
GhostlyDeath said:

It is 2016 and the latest C standard is C11, he may be better off with a book which starts at C11 such as C Primer Plus. Any habits you learn for C89 you will just essentially have to break out of anyway if you want your code to be portable. Stuff such as using char* for data instead of uint8_t.

I didn't even know there was a C11. I must have gotten it confused with all the new versions of C++ coming out. Now I have to go check it out.
I always used the stdint.h types anyway because it gives you a guarantee of integer sizes, which helps with handling file formats. Still have endianness to work with...

GhostlyDeath said:

Microsoft essentially just encourages that you program in C# now. However, Java has better supported virtual machines across the common platforms and is used more in the corporate world.

I don't work with .NET at all, so I was just recommending the books that helped me learn programming, which is why they were out of date. You always have Mono if you really want to run C# on non-Windows platforms.

GhostlyDeath said:

Many UNIX-like systems come with manual pages which document everything, thus books are not really needed because the documentation is usually standard on every system.

Unless you are already a pretty skilled programmer, UNIX man pages aren't going to be of much help. Most of them are just a step above reading the source code. Even the ones with example code don't typically explain what the code is doing beyond one or two sentences.

Share this post


Link to post
Tosi said:

I don't work with .NET at all, so I was just recommending the books that helped me learn programming, which is why they were out of date. You always have Mono if you really want to run C# on non-Windows platforms.


Compared to support on other platforms, .NET is rather new and rather incomplete. Java on the otherhand has pretty much been tried and tested and the library is supported on the most popular platforms.

I do not touch .NET at all however since Java has better Linux support.

Share this post


Link to post

A big reason some of us use .NET is because so many people have their offices filled with servers running Windows and MS SQL Server. The IT department is always comfortable supporting it.

It's the same with BASIC. It's horrible, but there's a surprising demand in the small-business world for people who know how to use VBA. The disturbing part is MS has gone 16 years without upgrading the scripting functionality of their office software. Those kinds of projects are the right scale for a lot of people, but VBA is just so clunky and limited.

Share this post


Link to post
fraggle said:

I myself wrote a lot of QBASIC code back in the day and my code was full of GOTOs. Took me several years to unlearn all that.

I just had a look at some QBASIC code I wrote back in high school. I used subroutines all over the place (as I hadn't worked out how to use functions at that point). The only GOTO I could find was actually a GOSUB that I called after executing an external application so I could redraw the screen to the intial state (the screen refresh code being outside of the loop inside that subroutine).

I avoided line numbers though. Those were the devil, and weren't even a part of the original BASIC language.

Share this post


Link to post

I would say avoid BASIC or QBASIC, common consensus there.

If you are serious about DOS only, then everything printz mentioned is what you'll want, along with x86 assembly. Don't be scared of it, it's not really that hard and Art of Assembly is a great book for learning it. If you have a logical mind then Assembly being hard is untrue and if you get really good at it you can still optimize better and debug your code easier, which is pretty much required in a dos environment anyways since getting a hold of SoftICE is going to be difficult and making it work even more so.

Tosi also mentioned good stuff.

Watcom C , Turbo Pascal, MASM/Turbo Assembler or some other modern assembler will serve your purposes. You can always experiment in dosbox and use it for debugging.

Learning better habits in coding now is probably a good idea, but some of it you will not be able to go backwards with because it's not supported in the older compilers so that point is somewhat moot.

Best thing to do is just jump in and do something, make mistakes and learn from them. Read everything you can find, and looking in the available source code that's been released since. It's a big world to step into and it can be overwhelming, start with small simple things and learn as you go and don't be afraid to fail.

Share this post


Link to post

There's no need to bother with Watcom C. DJGPP maintains ports of the current GCC to DOS.

Share this post


Link to post

As an alternative, you could try to install linux in such old systems, but it will take a long while until you come up with a system that does not rape the RAM. Without the graphical interface, of course.

The advantage being that whatever you create, will be usable for everyone using linux, too.

Share this post


Link to post

Normal answer is to learn C.

If one absolutely wants to avoid that then my recommendation is to check out Freebasic. It is a modern derivative of Basic. It has support for the Quickbasic dialect and its own new one. It creates code and has a compiler for DOS, Windows and Linux and is actively maintained.

I have used it a couple of years ago to create game trainers, very efficient and self-contained. Once I compiled a little console application I had made for DOS and ran it with Dosbox, pretty cool. I remember the filesize was big because of the DOS extender.

Check out this for more DOS-related info:
http://www.freebasic.net/wiki/wikka.php?wakka=FaqDOS

But Vorpal are you sure that you can't/won't learn plain ol' C? You can do anything from them on. And can easily learn most languages based on that skill.
http://www.learn-c.org/

You can get the Orwell Dev C++ IDE+compiler package here:
http://orwelldevcpp.blogspot.gr/

Share this post


Link to post
chungy said:

There's no need to bother with Watcom C. DJGPP maintains ports of the current GCC to DOS.

Watcom C can still compile 16-bit code, though. (But that's probably not an issue on a system from the 1990s...)

Share this post


Link to post
chungy said:

There's no need to bother with Watcom C. DJGPP maintains ports of the current GCC to DOS.

Hmm. Last time I checked there hadn't been a new release in years, but apparently there was a new release a couple of months ago (first since 2002 it seems). Glad to see the project is still vaguely alive.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×