Modula-2 Didn’t Make the Cut

As the title says, I’m pretty much done with Modula-2. It had promise, and was even fun to convert a few programs from PL/I and FORTRAN. But in the end, it just didn’t cut it for me.

Why? In a word, I/O. More specifically, the input/output for Modula-2, at least the CP/M Z80 version I had, was just too primitive to use.

What I have discovered while running and modifying some of my old Engineering programs in FORTRAN (and into PL/I or C) is that in many cases the actual calculation code pales in comparison to the input/output code. Many of the engineering programs produce a LOT of output, and it really needs to be readable to be of any use.

FORTRAN was my first computer language, and it was also the primary scientific / engineering language of my first professional jobs. Some of those programs produced fan-fold paper outputs that were several INCHES thick. Having a readable output format was critical.

What I’ve discovered lately is that PL/I is actually a better language for formatting output, at least when the FORTRAN compiler does not support the ‘T’ format (tab). PL/I has a tab (Column(x)) so it’s quicker and nicer to use for those programs.

Also, getting input from keyboard (console) or file in either FORTRAN or PL/I is not only quite easy, it’s easy to format, thus allowing for very concise readable input files.

Not so Modula-2. The input libraries are quite rudimentary. For example, reading real numbers is done by a routine that reads a full line, then parses ONE number from that line. To do anything else requires rewriting the library.

As a result, a simple input data file such as ‘-23.2 10.0 -44.8’ becomes one number per line. Now imaging a file with 5-10 real numbers per line and you have an unreadable input file.

Likewise the output was pretty much ‘unformatted’. You could apply some formatting, but not much. As a result, programs produced rather messy ouput. It’s fine for a simple program, but not for anything of substance.

It’s funny, because I remember the original criticism of Pascal, which is the pre-cursor language to Modula-2 by the same dude. Formal Pascal had no input or output as part of the original language spec, because it was supposed to be a ‘pure academic’ language. It wasn’t until Borland created Turbo Pascal and added a complete set of I/O routines that Pascal became a force in the 1980s.

Funny that I’m facing a similar situation in 2020 with Modula-2 on my Z80.

Windows XP Professional – unsung hero O/S

I’ve been writing of my adventures with a Z80 singleboard computer (kit supplied by CPUVille) for some time now. I’ve also mentioned how I had to ditch the flakey USB-serial connections and return to ‘real’ RS232 connections using an old Toshiba laptop.

What I may not have mentioned is the O/S on that Toshiba. It came with Windows XP Professional, and is still running that operating system all these decades later. It simply works.

I originally kept the Toshiba because it was the last laptop I owned that had a dedicated DB-9 Serial port connection on the back. Everything I’ve owned since removed the printer (DB-25) and serial (DB-9) connectors in favor of USB ports. While USB is great for almost everything, it is not always great for serial communications. Frankly, the USB-serial chips in the cables rely on flaky drivers that don’t always work.

I kept the Toshiba with it’s serial port to run Fuji controller software, which talked via serial connection (RS232-RS485) to my two Fuji glassblowing controllers (PXR3 series). The software from Fuji ran on Windows 95 thru XP, but not on newer versions. As a result, the Toshiba remained the ‘Fuji controller laptop’ complete with Win XP ever since.

The thing is, it still ‘just works’. After many years on a shelf, I installed the battery (it was stored separate), found the charger and plugged it in. After pressing ‘power on’, it simply worked. I found an RS232 cable (DB-9 ends) and plugged it into the Z80 singleboard. I downloaded a decent terminal program (Teraterm) and again, things just worked. Not only that, but they have continued to work ever since.

The laptop has a network adapter (not wifi) so I plugged it in, and was immediately able to access my shared data folders so I can edit on my main development PC (Windows 7) and access the files on the Toshiba to sent via Teraterm to the Z80. All quite easy and slick.

Using modern windows ‘Remote Desktop Connection’ (RDP), I am able to fully operate the Toshiba via a remote RDP window on my devel PC. Windows XP supported RDP, and it hasn’t changed in all this time – or at least, it’s backward compatible to XP.

The reason I was thinking about this recently is that a couple of days ago we caught a show on Knowledge Network about the 1990’s. This episode was all about tech in the 90s, and was a real trip down memory lane for me. In the 90s I was teaching C programming at SAIT in Calgary in the evening (Continuing Education courses) as well as full-time consulting in the daytime. I worked on some of the first computers to get Windows 95 when it came out. I remember programming for Windows 95. I was ‘there’ when Win 95 led to Win98, then Win ME (millenium edition), or “meh” (or mill-enema edition) as we often said. Win ME was a horrible, rushed OS that could not die fast enough. But Windows XP – that was beautiful, at the time. It simply worked. Most of the driver glitches had been tamed, and the PC slot and USB ports worked. The PC slot was quite cool for the time – I had a TV card (turned the laptop into a real TV) and a Wifi card, and several others. They were expensive but cool. And now they are long-gone history.

Still, it’s nice to be using something for a specific purpose and have it still work perfectly after all these years.

And the New Thing is… Modula-2

I know. Modula-2 is not new. In fact, it’s pretty much another ‘dead language’ in computing.

Modula-2 was Nicholas Wirth’s second foray into computer programming languages, the first being the much more successful PASCAL.

So why learn (and write) Modula-2 instead of Pascal? Well, it’s simple. I hate Pascal.

I’ve hated Pascal ever since the Borland Turbo-Pascal came out and everyone in the programming community was shoving it down my throat in the mid-1980s. I was, at the time, working at a consulting firm writing and maintaining FORTRAN programs on IBM, VAX, CRAY and several other machines. I was hearing rumblings from the Unix community about this ‘thing’ called C, but was at that time still several years from venturing into C myself.

But this Turbo-Pascal was everywhere in the micro-computing community. You simply could not escape it. Worse, to me it seemed a dumb language; full of ‘:=’ and other arcane structural things that made little sense to a FORTRAN programmer.

I didn’t want to learn it, but the constant barrage of Pascal stuff was deafening.

Eventually I moved on to C programming, and Borland’s Turbo-C was wonderful for micro-computers. I went on to start my own consulting practice where C programming became my bread and butter for many years. After that I branched out to C++ and then Java, but I managed the entire time to ‘omit’ Pascal.

Now I’m back playing with Z80 computers and interested in learning ‘stuff’ for the fun of it. While looking around for the next ‘programming thing’ after FORTRAN (F77), PL/I and C for my Z80, I discovered a really great working Modula-2 compiler. It was complete. There was full documentation. There were (a very few) example programs. I was set.

The cool thing about the Modula-2 docs is there’s even a big section comparing differences between Modula-2 and Pascal. Funny, I still don’t miss Pascal.

But now Modula-2 is the ‘this week and/or month’ language, so on I go. I’ve already managed to covert one fairly simply PL/I program, and just today I managed to get it to read from, and write to files. Next I’ll try some more sophisticated programs just to see how it compares to the other languages I’ve been enjoying.

I do love PL/I

After some weeks playing with old FORTRAN programs and converting them into PL/I on my Z80 singleboard (SB) computer (kit from CPUVille), I can say without reservation that I quite love PL/I.

The language is now dead, and that’s a shame. It certainly is one of the true ‘structured programming’ languages of the 20th century, and definitely fit in with the horrid old ‘waterfall project development’ life cycle. However, the language itself is quite lovely.

I took many of my old Engineering FORTRAN programs from the ’80s and had them running in F77 on the Z80 SB. They worked almost exactly as they had in the 80s, though quite a bit slower (Z80 vs. CDC Cyber or Honeywell Multics). The speed difference between Z80 and a modern Intel I7 PC using the same F77 compiler was astounding.

But it wasn’t until I converted them to PL/I that I found the PL/I programs, while about the same speed of compile/link/execute were just… nicer. From an aesthetic standpoint, the structure of the PL/I programs was clean and … nice. But the things that set PL/I apart from F77 were the file IO, and the outputs. File IO in FORTRAN works, but was messy. File IO in PL/I was simple and clean. The F77 documentation for Z80 wasn’t any help either. I ended up reaching out to online forums for assistance getting F77 file IO to read CP/M named files. Once I got the ‘trick’, it was easy. But in PL/I, the documentation was clear, easy to follow, and correct.

Even with both IO systems working, the output was where PL/I really shone. Fortran has several format specifiers for real number output, but PL/I outshines Fortran on every level.

The output from my FORTRAN programs was … nice. The same output from my PL/I programs was beautiful. Now in full disclosure, the F77 compiler would not accept the ‘T’ (or Tab) format specifier, so I had to resort to counting spaces. The PL/I formatted output accepted ‘Column(x)’ and made it so much easier.

I found no fundamental difference in double precision implementations in the two compilers, and both were easy to use once you learned how.

However, I still really enjoyed writing the PL/I programs. It was just a lot of fun and very satisfying.

Now on to new things…