Hacker News
16 days ago by kalleboo

I've been recently working with Classic Mac OS programming[0] and just that memory model (also using dealing with the lack of virtual memory using opaque handles to memory that need to be locked when used) is painful enough[1] - having to deal with segment addressing on top of that does not sound like fun. Thank god for the Motorola 68000!

[0]Made an AppleTalk chat client/server https://github.com/kalleboo/GlobalTalk-Chat

[1]The equivalent to HeapWalker I used was Metroweks ZoneRanger which was bundled with their compiler. It has a nice visualization of how fragmented the memory is https://bitbang.social/@kalleboo/116302075194704555

16 days ago by JdeBP

It wasn't really the processor architecture. Segmented addressing was actually fairly easy if the processor was used only in the way that protected mode was envisioned as working. As the headlined article observes, a lot of this stuff simply wasn't necessary in OS/2 1.x, even though that too had DLLs, callback window procedures, and the multiple tiny/small/medium/large/compact/huge memory models.

The differences were (a) that DOS+Windows was designed so that the same programs could run in both real mode, with overlaying, and 286 protected mode, with segmented virtual memory; and (b) that to really save on RAM DOS+Windows had ideas such as the data segments for DLLs being globally shared across all processes. These added all of the complications mentioned in the headlined article and more besides. It was the operating system, not the processor architecture.

16 days ago by kalleboo

I understood it as Windows developers had to manually deal with segment limitations since Windows supported running on pre-286 CPUs without protected mode (Wikipedia says Windows 1-3 all supported the 8088). OS/2 just made the 286 a minimum requirement so they could rely on a CPU with more modern features.

The 68k didn't come with an MMU like the 286 so MacOS couldn't rely on virtual memory like OS/2 did but at least the flat memory space meant you didn't have to juggle 64k segments

16 days ago by canucker2016

But like real-mode Windows, the Macintosh OS was designed with small amounts of RAM. 32K limits pop up in various APIs. Handle memory allocation.

Not as much of a strait jacket as Windows segmented-memory programming, but compared to Unix, it did feel constricting.

16 days ago by JdeBP

Yes, outwith the idea of Family API programs (which couldn't use Presentation Manager and whatnot anyway) OS/2 1.x did target the 286 as a minimum. But that doesn't mean that DOS+Windows didn't use the features.

It did. It was bi-modal. There were at one point switches to the WIN command to tell it whether to come up in real mode or 286 protected mode. In the latter it definitely did use the features of protected mode.

It was the bi-modal nature that was the problem. Essentially, they had to design a whole layer that simulated when in real mode all of the load-on-demand stuff that the processor architecture supplied for free in 286 protected mode, and make it so that the thing would all work either way with no changes to applications.

15 days ago by pseudohadamard

I actually found programming on the Mac a lot more painful due to the +/-32K max displacement for BRA/BSR, in MPW you had to manually shuffle blocks of code around to get them into the 32K jump range while in Windows the tools took care of it for you.

14 days ago by duskwuff

Early editions of Inside Macintosh implied that code segments couldn't exceed 32 KB, so you'd never run into that situation. (It's not clear whether this was an enforced limitation or just a recommendation.) Instead, developers were expected to divide their applications into multiple CODE segments, using jump table entries in the A5 world to branch between segments.

Later in the operating system's lifecycle, applications typically used a single code segment and a custom loader to apply relocations, allowing them to use JSR within that segment.

16 days ago by jdw64

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

16 days ago by vjvjvjvjghv

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.

15 days ago by icedchai

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

16 days ago by jchw

As someone who grew up coding after it was mostly 32-bit, I can't say this with certainty, but my gut feeling is that paradoxically you would have and it would've made you stronger.

16 days ago by cogman10

I think it'd be mixed.

I think the knowledge of underlying hardware is useful and good to know.

But also that sort of knowledge got dated pretty quickly in the early computer era. Further, the capabilities of things like optimizing compilers quickly got to a point where they'd outpace most hand written assembly. Today, it's basically just floating point operations where you can still do better than a compiler.

In the early days, you'd have the correct impression that the C compilers spat out utter garbage which was a lot slower than what you could hand craft. As optimization techniques got better and better, the work you did because the compiler was dumb ultimately would have gotten in the way.

16 days ago by hnthrowaway0315

Exactly. I'd argue that all those programming Gods and Gods because they went through that period. Whatever didn't kill them made them stronger. We should replicate that experience by deliberately writing in low level C and assembly for a few years.

16 days ago by FpUser

>"by deliberately writing in low level C and assembly for a few years"

Ha. kid's stuff. I started with punching machine codes straight into memory

16 days ago by kev009

Attention spans were longer.

16 days ago by GordonS

I've been wondering about this lately. As a kid, I spent hour upon hour learning about computing: typing in Basic code from a magazine into a Commodore 64, playing with music on an Atari STe, learning my way around a DOS command line, dabbling with 3D modelling... just so much stuff that my own kids would never have the patience for.

I wonder if it's just that kids today (gods that makes me sound old!) are constantly surrounded by entertaining things to do - gaming, TV/films, music, social media.

16 days ago by jdw64

I think that's actually a pretty accurate observation. I'm not a cognitive science expert, so I don't know the details, but there have been articles about 'popcorn brain' due to sustained attention issues, right? Personally, I use LLMs for coding quite often (in my environment, I'm often forced to use them). Compared to the past, when I use an LLM, the answers come immediately, so it seems harder to focus deeply than before. The generation younger than me, which is more focused on Shorts, probably has it even worse

16 days ago by trumpdong

I think it's an adaptation. Instead of living in a world with limited valuable information we're now living at the end of a firehose of never-ending near-useless information which has to be filtered at high speed.

16 days ago by Braini

Thats correct - and I notice that on myself. There are just much more things reachable at any point in time compared to our youth it takes real effort to focus.

16 days ago by hnthrowaway0315

I have been shielding my 6 years old son from electronics, except 40 minutes of TV twice a week. I have no idea how to grow his patience and perseverance, though. He is like me, who doesn't have a lot of patience to begin with, so I can't really guide him through some of the situations. We have been taking him to some activities as well as reading to him but nothing really sticks.

I just hope eventually he loves reading and learns in a more traditional way instead of from laptops and pads.

16 days ago by hnthrowaway0315

I have been wondering how to train my 6-year old son and myself to increase my attention span.

Some rules are obvious -- cutoff mobiles and pads completely (he doesn't have access to them so it's for me), sit in the library and study from books (I believe this is even possible for programming topics as I can write on paper). Basically, cutting off everything electronics definitely helps -- even putting my phone in the bag improves productivity significantly.

But the problem is, my son is unruly. If I put him in the library, most likely he runs around and messes things up, which ends up we leave early without doing anything.

16 days ago by toast0

> But the problem is, my son is unruly. If I put him in the library, most likely he runs around and messes things up, which ends up we leave early without doing anything.

Some potential ideas to explore. Take what you want, leave what you don't.

a) if you're training for attention span, make sure the target is appropriate and also within reach of your child.

b) have a plan for the visit: when I helped at a school library, classes for kids in your kid's age group would come in, the librarian would read them a story, then the kids would look for a book, check out at the desk and read (or look at the book anyway) quietly until the end of the visit. I think we'd get about 40 minutes for a visit. Most days, at least some of the kids would be getting ansy before it was time to go.

c) Plan around your kid's activity needs. Some kids will do long still antention tasks better after doing some amount of physical activity. Some kids will do these kinds of things better after a meal. Some will do it better in the morning or the afternoon. Many kids will have a harder time if the library visit was a surprise. You know your kid, try to have your library visits when they're likely to work well. If he likes story time, try to visit when there's a story time available.

d) don't expect that you can both go to the library and work independently. You're going to the library with him, and he's going to need you to help him out for much of the time. But you might be able to find him a book together, then find you a book together, then sit down and read for a bit together.

e) if all you can get done is finding a book, no big deal. You can read at home too.

If a lion can figure out how to behave in the library, so can your kid ;) https://www.michelleknudsen.com/library_lion_77788.htm

16 days ago by unleaded

It's easy when it's the only way to get things done. Think about how nobody who was learning programming before 2023 was seriously thinking "This would be so much easier if the computer wrote it all for me".

16 days ago by userbinator

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

15 days ago by pjmlp

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

15 days ago by Joker_vD

> 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!

16 days ago by rramadass

Good informative article.

Win16 programming was an important formative phase in my career. There is a lot of wisdom in old solutions to thorny problems and knowing them often clues you to how one may adapt them to today's problem. For example, when CPU+GPU programming appeared i immediately imagined CPU memory accessed with "near" pointers and GPU memory accessed with "far" pointers with a switch to a pseudo-segment register.

It also conditioned a programmer to learn about various complexities involved and be careful in their programming i.e. it taught you discipline. You understood your compiler, OS and hardware better and how to write code keeping them all in mind. For example, i often say my study of embedded programming started with Win16!

Another bit of cleverness was "Thunking" between 16-bit and 32-bit code. Here is Raymond Chen on how it worked there and Why can’t you thunk between 32-bit and 64-bit Windows? - https://devblogs.microsoft.com/oldnewthing/20081020-00/?p=20...

16 days ago by boutell

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 recently released Mosaic browser without an actual internet connection. I figured sure, no problem. I'll use curl or some other tool in the shell account to do the actual fetching of URLs, transfer styles over zmodem, and simulate all the tcp/ip calls in the DLL.

I couldn't even get started. The reason is that I couldn't understand how the different Windows applications could all share memory allocated at runtime in the winsock.dll.

I asked a highly experienced ex Microsoft person, and he just said what are you talking about. There's no API to allocate shared memory.

So I gave up. 6 months later someone else did it.

Around then I realized the truth: Windows 3.1 had no memory protection at all. Specifically all global variables in DLLs were shared by default. The hard part wasn't sharing memory among users of a DLL. If anything, the hard part was having good discipline to avoid sharing it.

Since I'd only used multiuser Unix in school, and I knew Windows supported multitasking (even if only the cooperative kind), I just couldn't wrap my head around the idea that I'm multitasking operating system could exist without memory protection.

16 days ago by leeter

> Windows 3.1 had no memory protection at all

All of the below is... IIRC

Win16, even in protected mode, in general didn't unless you opted out of the shared VDM. This was to preserve compatibility with how non-protected mode code worked. That said 32bit code or code that specifically marked itself as protected mode got it's own memory space.

> I just couldn't wrap my head around the idea that I'm multitasking operating system could exist without memory protection

NGL... I was shocked when I found out that MacOS before 10... really didn't have much protections at all.

15 days ago by pjmlp

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...

16 days ago by summa_tech

Pretty good detail in this article! But what really surprises me is how some ideas just keep coming back.

When I wrote a binary translator, I ended up having to keep a translated return stack to optimize RET opcodes. That put me in exactly the same position as the Win16 kernel with regard to having to patch pointers (in case of Win16, just the segment part) on stack.

Of course I did not have the benefit of my guests calling a lock function, so I ended up having to run a garbage collection operation to determine which pointers are in use & take exceptions on now-invalidated segments. Lots of extra work that Windows didn't need: it's nice to be king :-)

16 days ago by unleaded

Thank god for the 386.

16 days ago by chiph

> Exports are used for application code which is externally called.

This was the magic moment for me, learning Windows 3.0 programming. The idea that my program is no longer master of it's world, but instead is just something that gets loaded and called by Windows.

Daily Digest

Get a daily email with the the top stories from Hacker News. No spam, unsubscribe at any time.