News for hackers. Stuff that matters.
Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by kragen on Wednesday April 16, 2025 @03:21PM (#43709301)
I used the p-System on a Heathkit H-89.

I think the overall approach of future-proofing your software by compiling it to a simple, portable virtual machine is valid. Since the p-System, in addition to the JVM and Zork Z-machine mentioned in this post, we've seen Smalltalk-80, PostScript, Open Firmware aka OpenBoot, Glulx, the ASS/400, the Open Software Foundation's ANDF (the architecture-neutral distribution format), Google's NaCl and pNaCl, Microsoft's CIL, JS as a compilation target, WebAssembly, uxn, and the revival of old video game consoles in emulation as a stable software target.

A problem with this approach is that most of these portable platform layers are still far too unstable for reliable archival; even video game emulators face a constant struggle to maintain compatibility as they are updated to keep up with whatever platform they're running on. Platforms like the JVM, which make more concessions to efficiency than MAME, have even more difficulty, so the JVM's slogan of "write once, run anywhere" was widely mocked as "write once, debug everywhere". But it's a good aspiration. I'd like to see it realized in a practical way.

My memory of the p-System is that it was almost unusably slow, a problem made worse by its filesystem being so simple it didn't support fragmentation, so sometimes you had to defragment your floppy disk in order to write new files onto it. It's true that its UI was screen-oriented, as wduquette said, and it was driven by a Lotus-1-2-3-like menu system, which enhanced its usability quite a lot.

Being a pure bytecode interpreter was a serious handicap, especially on the sub-1-MIPS machines we were running it on. EUMEL managed to make a go of it. I never got a chance to use EUMEL on an actual Z80, but I hear it was usably fast; I suspect the EUMEL virtual-machine instruction set (which included string operations) and operating environment went a long way towards compensating for the slowness of bytecode interpretation, much as Numpy does on CPython today.

I suspect you could have done a better job with a bytecode more like Dalvik, designed for efficient JIT compilation by leaving less work for the JIT compiler. But Deutsch and Schiffman didn't publish the first JIT-compilation paper until a few years after the p-System was released. (Schiffman told me a self-deprecating joke about this which I guess I can't really repeat.)

Long Tien Nguyen and Alan Kay published a paper on designing a very simple virtual machine for such digital preservation 10 years ago: https://tinlizzie.org/VPRIPapers/tr2015004_cuneiform.pdf

I think these ideas point the way to achieving the kind of future-proofness that the p-System was shooting for.

Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by mbessey on Wednesday April 16, 2025 @03:38PM (#43709488)
Performance of the p-System is definitely an issue on the Apple II, especially in the "OS" interface and editor, which is all interpreted. But running applications built on it wasn't half-bad.

It's also important to remember that to a large extent, Apple Pascal on the Apple II and other late 1970s home computers wasn't competing with sophisticated native-code compiler suites, but with interpreted BASIC and with assembly language.

Pascal was vastly more-productive than writing in Assembler, and much faster in execution than Apple BASIC. It even had reasonable support for integrating assembly routines for places where you really needed the speed.

The p-System was A LOT more usable on the HP Motorola 68k workstations I used it on. Those were more than adequately fast for the sort of software we were writing for them in 1985.

Thanks for the link to cuneiform, I think I read that paper once, long ago. Will definitely check it out.

Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by kragen on Wednesday April 16, 2025 @03:53PM (#43709630)
The interpreted BASIC on most home computers was Microsoft BASIC-80, which, as I remember it, was also painfully slow. There were lots of programs in it, and it was good enough for some games, but for the most part "real software" for those computers was written in assembly language. Even Turbo Pascal was written in assembly language, not Pascal.

I think now we know how to do better.

Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by TheOtherHobbes on Wednesday April 16, 2025 @05:20PM (#43710527)
Computers are more like an assembly of subsystems than a single thing, and you can just about get away with agnostic byte code as long as you ignore most of the subsystems.

So cross-platform byte code is sort of viable on mid-80s text terminal systems with limited memory and addressing. But as soon as you start adding graphics cards, video acceleration, sound, and AI accelerators, you need to add abstraction layers which will be limited and inefficient and limited compared to the hardware.

And if the hardware isn't available you can either say 'This won't run at all' or emulate it in software, which will be even slower.

Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by kragen on Wednesday April 16, 2025 @05:49PM (#43710784)
There's some truth to that, but I think you're overstating the case. The vast majority of software we run on a day-to-day basis doesn't use any of the stuff you mentioned, so nothing is stopping it from moving to platform-agnostic bytecode, except that that bytecode doesn't exist yet.

For example, 2-D graphics acceleration hardware (whether in the form of character generators or in the form of blitters and line drawing) was really important for usability up to the 01990s. This is a major reason the X-Windows protocol is so big and complicated: it needed a way to expose the acceleration capabilities of the hardware to applications so they could draw with it. This was, as you said, "limited and inefficient and limited compared to the hardware". But basically, as CPUs got faster, we gave up on all that stuff around the turn of the millennium, and now most 2-D applications really just want to fill up pixel buffers and swap the displayed buffer between screen refreshes. It's a very, very simple interface (you might say "inefficient abstraction layer").

Something similar happened with sound. In the 80s and 90s our sound cards did square and sawtooth waves, LFSR noise generation, envelopes, FM synthesis, wavetable synthesis, etc. Different sound cards had different instruments! Now all I want to do with my sound card is send it a sequence of samples, maybe get back a sequence of samples from the microphone, maybe choose from among multiple outputs. Another very, very simple interface.

3-D games do still use 3-D acceleration, of course. That's not a simple interface. They also depend pretty heavily on SIMD instructions. The same is true of video codecs.

But my SSH client, my mail server, my IRC client, my text editor, my compiler, my filesystem, my Game of Life simulator, my system logger, my Sudoku game, my circuit design program (KiCad), my PDF viewer, my audio editor (Audacity), and so on — those aren't using "graphics cards, video acceleration, sound, and AI accelerators", except through the very, very simple interfaces we're talking about above. Most of them don't even use floating-point math! They could easily be in platform-agnostic bytecode because they already do ignore most of the subsystems in my computer.

Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by wahern on Wednesday April 16, 2025 @08:29PM (#43711812)
> This is a major reason the X-Windows protocol is so big and complicated

X was trying to, in a sense, remote hardware acceleration. Wayland doesn't bother at all, clients render their windows locally and share (or send) a pre-rendered graphic. But if you use across the network an older X app, such as one that uses server-side fonts, etc, the experience is often much smoother, IME, as compared to the Wayland-universe alternatives.[1] Once upon a time even web browsers, like ancient versions of Netscape, were shockingly responsive over the network, even with mixed text and graphics; almost indistinguishable from local (and this at a time when X11 on a 486 was a smoother experience than Windows). The popular toolkits now render the window on the client even when using X, so those capabilities are largely unused today.

[1] In that case, the composition and rendering of all the widgets, text, and images within a window is truly local, i.e. on your local X server.

Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by ahefner on Wednesday April 16, 2025 @05:57PM (#43710846)
Not ideal, but MS-DOS seems to me like the most practical universal software platform. DOSBOX isn't going anywhere.
Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by kragen on Wednesday April 16, 2025 @06:13PM (#43710941)
It is of some practical use, but there are a lot of slightly incompatible versions of the IBM PC and of MS-DOG, so it doesn't offer the kind of strong reproducibility that I'm looking for.
Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by 3036e4 on Wednesday April 16, 2025 @06:12PM (#43710935)
A DOS-executable is far more write-once-run-anywhere now than Java ever was, and the best thing is that no one is going to ever deprecate any API in DOS. There is no software rot in a dead OS.
Re:The UCSD p-System, Apple Pascal, and a dream of cross-pla... by kragen on Wednesday April 16, 2025 @06:14PM (#43710948)
You're damning it with faint praise, though.