Live data from Hacker News

Win16 Memory Management

os2museum.com

71–80 of 86 posts

Re: Win16 Memory Management

#71
post #2

Sometimes I think that if it were the old days, I probably wouldn't have been able to program. I remember that these days we program on top of 64bit virtual addresses, but how did developers do it back then

I can tell you about my experiences with this, which from what I hear are unusual. I first learned programming in C128 BASIC. Then on the PC it was QBasic and Turbo Pascal, and later Perl.

What all of these languages have in common is that you can write meaningful programs entirely without pointers or manual memory management. In particular, all of these languages handle strings in a natural, high-level way (treating them as a value) and don't require you to allocate and free buffers for them. Perl goes a step further with arrays and hashmaps and employs a full garbage collector.

I have vague memories of trying C for the first time and getting completely lost and bogged down by all the pointers and memory management. My reaction was the same as yours: how does anyone program in this. Why bother with this complexity when you can just use Pascal where you simply don't have to.

Of course, the Pascal compiler was likely written in C or assembly and all the memory management still had to happen even if it was hidden away from me. To some people, this might mean that I “lost” something, but to me, it meant greater freedom as I was able to explore the world of higher-level programming which I found interesting, and not have to bother with the low-level details which I found tedious and even infuriating.

Re: Win16 Memory Management

#72
post #62

Earlier quoted context omitted.

I usually start with game: guess the number. The computer generates a random number between 1 and 100. And you have to guess. When you’re too high, the computer says “too high” and likewise when you’re too low. It’s a great starter program because it teaches you strings (the output printed), integers, comparisons, conditionals, and iteration (you keep guessing until you get it right). And the whole thing only take ar…

Thanks! This is a good idea. I was thinking about typing games and such because he needs to learn words before doing anything useful, but guessing games are definitely fun, too. I can definitely write simple games using QBASIC (was preparing a Dospian on Rpi 4 as his 6 years old birthday gift). Do you have any blog, or any recommendation of books to read for such topics? Maybe I can find some "Programming for kids" b…

My parents got me this QBASIC book when I was in elementary school and I remember it being pretty accessible even for very young readers.

https://www.abebooks.com/Absolute-Beginners-Guide-Qbasic-Per...

Also the Usborne series are classics and a lot of them have been made freely available:

https://usborne.com/us/books/computer-and-coding-books

Re: Win16 Memory Management

#73

Windows never had a global name space for dynamic symbol resolution. IMHO one of the best design decisions they made; the Unix dynamic linking model seems absolutely like an absurd workaround in comparison. Also, no mention of FixDS? https://www.geary.com/fixds.html

> the Unix dynamic linking model

What? It's just like static linking! Only, you know, we do it at load time. At least the filenames of the shared objects to load are included into the executable — we could instead just load and search the whole of /usr/lib in unspecified order, you know!

Re: Win16 Memory Management

#74
post #58

Earlier quoted context omitted.

char FAR *p; char FAR *mem = farmalloc(65536); for (p = &mem[65535]; p >= &mem[0]; p--) { dostuff(p); } Nice one. To be fair to Windows, good C courses should still teach this, but I'm not sure if they do :-) It's UB to set a pointer to before the first element of an array, or after the last element plus one. So, if it knows the call to farmalloc/malloc returns the start of an object, a modern C compiler on a modern…

None of my college CS courses used programming languages that featured FAR pointers. The above example would cause an infinite loop on Win16's seg:off far memory model, but compiling on Win32 would not cause an infinite loop. Problem is that far pointers only affect the offset, not the segment. So decrementing a 0 value offset would just wrap around to 0xFFFF and the segment would stay the same, so you're going from…

My point is the example code has a generic C bug, not depending on FAR, which is why it should be taught in good C courses.

Although the code worked on Win32, and works on most modern C compilers, it's not guaranteed to work on modern C compilers, especially with aggressive optimisation turned on.

Re: Win16 Memory Management

#75
post #63

Earlier quoted context omitted.

All software is portable by that former definition. When people talked about portable before, they meant code that used an abstraction that was platform agnostic. And that’s how it’s still used today. It’s just we have better abstractions now so our expectations of what is “portable” have gotten stricter. Eg the P in POSIX (which is nearly 40 years old now) is “portable”. The point of POSIX was to provide common abst…

It was about making software easier to port. You still couldn't necessarily just write software for all operating systems at once, but you had less porting work because less stuff was different because of the standardisation. So open(argv[1], O_RDONLY) works on all POSIX systems, but if you want to create a pseudoterminal, it's different on each, and if you want to create a container, they don't even use the same con…

But you’re now arguing the same point I am: Portable means low effort porting.

Saying something “can” be ported doesn’t make it portable. People would port games from the NES to the Master System, to 8 bit Micros but in most cases they were effectively complete rewrites because there wasn’t any common abstractions between those platforms.

Where as tools like POSIX provided abstractions to make code portable.

As I said before, the only reason you think the term has changed over the years is because the abstractions have gotten better and thus people’s expectations for how much effort should be required to port have gotten stricter. But that doesn’t mean the term means something totally new.

And by the way, I have authored portable terminal emulators and $SHELLs. ;)

Re: Win16 Memory Management

#76
post #62

Earlier quoted context omitted.

I usually start with game: guess the number. The computer generates a random number between 1 and 100. And you have to guess. When you’re too high, the computer says “too high” and likewise when you’re too low. It’s a great starter program because it teaches you strings (the output printed), integers, comparisons, conditionals, and iteration (you keep guessing until you get it right). And the whole thing only take ar…

Thanks! This is a good idea. I was thinking about typing games and such because he needs to learn words before doing anything useful, but guessing games are definitely fun, too. I can definitely write simple games using QBASIC (was preparing a Dospian on Rpi 4 as his 6 years old birthday gift). Do you have any blog, or any recommendation of books to read for such topics? Maybe I can find some "Programming for kids" b…

To be honest I just picked moments when the kids were bored and wanted daddy time but weren’t buzzing around the house with excess energy to burn.

It wasn’t something I specifically planned in advance for. Which meant though whole experience was less like homework for them.

As I’m sure you know, sometimes kids just want to experience the stuff their parents do. And when they’re in that kind of mood it’s a lot easier to sit that at a computer than it would be normally.

Re: Win16 Memory Management

#77

Windows never had a global name space for dynamic symbol resolution. IMHO one of the best design decisions they made; the Unix dynamic linking model seems absolutely like an absurd workaround in comparison. Also, no mention of FixDS? https://www.geary.com/fixds.html

Not all UNIXes, Aix dynamic link model is XCOFF and quite similar to Windows.

Re: Win16 Memory Management

#78
post #42

In 1994 I was 2 years out of school. I'd written one windows shareware application and a whole lot of unix-y things. People were excited about the internet but most people didn't have access. Unix shell accounts via dialup were common though. One day I was encouraged to write a Windows Sockets emulation layer for ordinary dial-up shell accounts like those offered by netcom. The idea was to allow the use of the recent…

Owning reference books like Petzold, already doing C++ and TP coding on Windows 3.x, I am quite sure that the protection was there for Win16 applications in 386 Enhanced mode.

Now in regards to DLLs it all depended on which memory segments were being used, and the respective code on DllMain in regards to the thread/process attachment code and related handles.

Knowing what to search for quickly gave me this article from back in the day,

https://learn.microsoft.com/en-us/archive/msdn-magazine/2000...

Re: Win16 Memory Management

#79
post #71
post #2

Sometimes I think that if it were the old days, I probably wouldn't have been able to program. I remember that these days we program on top of 64bit virtual addresses, but how did developers do it back then

I can tell you about my experiences with this, which from what I hear are unusual. I first learned programming in C128 BASIC. Then on the PC it was QBasic and Turbo Pascal, and later Perl. What all of these languages have in common is that you can write meaningful programs entirely without pointers or manual memory management. In particular, all of these languages handle strings in a natural, high-level way (treating…

On the contrary, Pascal compilers were usually written Pascal with a bit of assembly where needed :)

Re: Win16 Memory Management

#80
post #2

Sometimes I think that if it were the old days, I probably wouldn't have been able to program. I remember that these days we program on top of 64bit virtual addresses, but how did developers do it back then

I think programming often was easier back then. You didn’t have to know about 120 AWS services or security issues. The world was pretty small and you could mostly understand all details of the system you worked on. But it was more tedious for sure.

It was. I learned so much by reading books and computer magazines. Now we have layers of layers of cruft to wade through.
Post reply on HN