Hacker News new | past | comments | ask | show | jobs | submit login
Modula-2 GCC compiler front-end patches sent out for review (phoronix.com)
80 points by ingve on Oct 15, 2022 | hide | past | favorite | 39 comments



The first compilers I owned (bought with my own teenager cash!) were Personal Pascal and then Megamax Modula-2, for my Atari ST. I only learned C later, in high school. I had such fantasies of programming such fantastic interesting things that of course never got made.

I shelled out large chunks of hard earned chore cash (sorting bottles for bottle depot recycling, mowing lawn, etc.) to get these (second hand copies). Probably over $200 in today's $$ when accounting for inflation

"Today's Kids Will Never Know!"


Similar story for me. The first compiler I bought with my own money was Benchmark Modula-2 for the Amiga. There weren't any (that I was aware of) free compilers for the Amiga at the time and I couldn't afford the C compiler.

It was quite the adventure learning how to program an Amiga with, effectively, a pile of header files, but I had a great time.

The manual for Benchmark Modula-2 (which, IIRC, is all it came with) is in Archive.org.[0]

[0] https://archive.org/details/benchmark-modula-2-manual-1988/m...


Yeah the real problem with Modula 2 on the Atari (and I imagine this held for the Amiga as well) was that the OS syscalls were really built for C. And all the documentation was for C.

On the Atari, in GEM, there's just a boatload of C unions used for UI elements. And void pointers galore. So not friendly to Wirth style languages which have very strict static typing rules.

That and getting documentation in those days was also a nightmare. Everything was in books/manuals, and it's not like you could just get them from Amazon or even a local bookshop. And books were expensive. And it's not like my Modula 2 compiler manual had good documentation on the OS syscalls, etc. It didn't even include a real full set of bindings.

Somewhere out there there's an ST Format issue with a printed letter from my 14-year old Canadian rural-living self begging for help finding documentation on the Line A graphics calls for the ST.

Coupled with compiling with a floppy based system because hard drives were unaffordable. Challenges.

By the time I got my hands on a C compiler and decent documentation I had moved onto Linux on my 486. The 90s were very much a different era from the 80s!


That was a bit was helped me jumping from Turbo Pascal to Turbo C++ side of the fence back on those days, but on the Windows 3.x world.

It wasn't no longer like on MS-DOS where all language had the same capabilites accessing BIOS and MS-DOS interrupts, rather if Borland hadn't provided the external bindings to Windows APIs, someone had to write them.

Whereas using C++, alongside OWL, gave me the nice language features I came to love from Object Pascal, a framework similar in usage like Turbo Vision, with bounded checked strings, arrays, collection types, and all the Win16 was one #include away.


Doing a Computer Systems Engineering degree in the late 80's/early 90's, we were taught Modula 2 on Atari STs.


There is also a Modula-2 compiler based on LLVM.

https://github.com/redstar/m2lang


I wrote a fair amount of Modula-2 back in the mid 90'ties. Used the TopSpeed Modula-2 compiler and produced both DOS and OS/2 executables from the same source code.


I also used the TopSpeed Modula-2 compiler. I did some stuff like 3D wireframe animation.

At one point, I used the built-in assembler in MS-DOS's DEBUG.COM to write a Bresenham line drawing routine, targeting the frame buffer directly.

Then I took a hex dump of the code, and planted it as hex inline assembly code into a Modula-2 function. Rubeyes, it worked.

One project was an implementation of the Core War game. I made it nice with a split-pane window showing the dueling programs as a pair of step debugger windows showing a disassembled section of memory with the current instruction highlighted.

:)


I remember I was big into Modula-2 as well in the '90s. I started out with BASIC and then moved onto Modula-2 before fixating on C and C++. I think I really only picked it up because I found a free compiler (I don't remember which) and great tutorials (from Coronado, who later had C++ tutorials as well).

A great language that really got me thinking in a more structured fashion about programming.


Modula-2 haws not been "succeeded" by Modula-3; Modula-3 is a very cool different language. Don't let the numbers confuse you.


It is a bit more involved than that.

Mesa/Cedar people from Xerox went on to DEC Olivetti research labs, to create Modula-2+, using Modula-2+ as their baseline, and eventually their project grew into Modula-3.

Meanwhile on the Modula-2 world, many compilers added language extensions for OOP, GC, generics based on what going on with those projects.

So while Modula-3 isn't the direct descendant from Modula-2, they are kind of intertwined.


The whole Wirth language family tree is pretty complicated. Wirth himself designed Pascal (1970), Modula (1975), Modula-2 (1978), Oberon (1987), Oberon-2 (1991), and Oberon-07 (2007). Every iteration had many offshoots, surprisingly many were trying to build a business around their own version, most notably maybe Borland with TurboPascal/Delphi. Mesa/Cedar/Modula-3 is another interesting branch.

This is a topic that a book could be written about, tracing the 50 year old history


Indeed, by the way, Object Pascal was born at Apple as evolution from Clascal with collaboration from Nicklaus Wirth, although many think Borland did it, due to Turbo Pascal's popularity.


If I remember correctly, tracing GC and generics pretty similar to Modula-3 eventually got into the ISO standard for Modula-2 (as optional features), no?


Yes, the Wikipedia page lists their ISO numbers,

https://en.m.wikipedia.org/wiki/Modula-2


Too late to edit, "... using Modula-2 as their baseline...".


Modula-2 is a great language! So happy to see this, I hope it gains traction


Wonder why Modula-2 never go mainstream? I see it has some nice features like concurrency.


Bad timing, basically. By the time Modula-2 appeared, Pascal was rather popular, and there were a lot of extensions to the official standard that mirrored the main features of Modula-2. I think it was UCSD Pascal that introduced "Units", and that was quickly taken up by other popular compilers.

Also, by that time OOP started to rear its seven heads, and Modula-2 didn't have an answer to that, whereas yet another Pascal extensions (e.g. by Apple or Borland) filled that role. ISO Pascal and late Turbo Pascal/Delphi are about as far apart as they're to Modula-2, but you still had the name and quite often transitioned by compiler release, not language standard.

Modula-3 and Oberon answered the OOP call, but the former wasn't officially Wirthian and the latter probably too minimalist and non-industrial.

Also, of course, the BCPL language family enjoyed a steady rise during that time, first C eating into the Pascal space and then C++ becoming the standard low-level OO language.


Probably is related to the fact that UNIX and Windows were intrisically C systems. While obviously you could program Modula-2 on both, it was a second-class citizen


On Windows, Turbo Pascal for Windows, followed by Delphi, were everywhere, in similar scale to Visual Basic.

But then Borland decided to go after enterprise market, and they never recovered from the damage.

Their products are still strong among the German market, though.

https://entwickler-konferenz.de


I'm not old enough to experience UNIX in mid 80/90s. By reading various stories and hear some anecdotes, seems that UNIX is a nice bandwagon for C.

Except classic MacOS, Pascal wasn't that popular for system programming.

The culture still survive until today. Try searching at OSDev forum or Github, and you'll see most kernel projects are done in C.


There was a standardized set of object-oriented extensions for Modula-2 adopted (maybe 25 or 30 years ago), but they never went anywhere (back then). Do any of the current implementations of Modula-2 implement them?


I think XDS did.


It's amazing to see Modula-2 still actively developed. Never programmed in it, but I have fond memories of Turbo Pascal ih high school. How does Modula-2 compare to the likes of C and Free Pascal today?


I guess Modula-2 is a fine language, but I think Modula-3 is better. There is a cross platform GUI toolkit (X11 and Win32) for Modula-3, for example: http://www.opencm3.net/doc/tutorial/ui/tutorial.html


Much better, a GC enabled systems programming language, with all the C and C++ like features when required to do low level stuff.


Yeah, Modula-3 had everything that the new kids like Java/C#/Go try to sell you years before, but I think Trestle would need some modernization before it could keep up visually with Qt/Gtk/etc (assuming that you can still "sell" that, as the kids these days really like their whitespacey Electron). It's a bit like Common Lisp's CLIM in that regard.

And, of course, in a land where Bell Labs won, upper-case keywords instead of glyphs are hard to sell.


Java designers officially mentioned Modula-3 as source of inspiration, sadly they forgot value types and AOT in the process and are still catching up on that front.

C# is finally there, since .NET Native and the improvements they keep doing since C# 7. Sadly WinDev keeps ignoring what comes out of DevDiv, they worship their COM with C++ implementations.

Go, well, plenty to catch up in regards to Modula-3 features.

While upper case keywords are a bit of a bummer, like on Visual Basic and most modern SQL tooling, there are options to automatically format keywords into uppercase.

Among all modern alternatives, I would say C# 11 and Swift are the closest to Modula-3, with a rich ecosystem in the backpack.

D and Nim could also be candidates, but they still miss much of the tooling to make them competitive in current times.


The problem with Modula-3 was that it had all that good stuff, but the official distribution was enormous (relative to machines of the day). If they had invented NPM too, they might have had a better chance.


CPAN was roughly contemporary, and about at the time when "downloading" became an option.

But on the general notion, I'd vehemently disagree. Not having stuff in your standard library but spread about is one of the worst things the languages in this generation copied from C++. Give me a good standard library. Maybe factor out the UI and definitely truly adjacent packages like Obliq.

Note that a huge library also didn't hurt Java too much. And there it was even worse, as you had to distribute most of it as a runtime, whereas a compiled language usually gets by with less (take this with a grain of salt, I don't remember how huge Modula-3's equivalent to MSVCRT was back then on Windows, for example).


At the time I'm thinking of, late 90's, python, which had a decent std library, was easily installable, but SRC m3 definitely wasn't - at least on a cheap student sized machine. I seem to recall that he successor projects like CM3 tried to produce pared down versions. All this of course pales into insignificance against the amount of crap something like Android Studio downloads today to build a trivial app. But at the time, I think it was a lot. The HD I went to uni with was only 40MB, for example.


The only reason I know about this language is because of Advanced Operating Systems


Modula-2! Seems like Algol-60 should be next.


Why not Algol 68? You can get a modern implementation here: https://jmvdveer.home.xs4all.nl/en.algol-68-genie.html


And of course there is a VSCode plugin for it as well.


The documentation for it is great too


GNU already has an Algol-60 implementation, albeit not as a GCC front-end:

https://www.gnu.org/software/marst/


If we're going backwards in time, Algol-W should be on the list (there's a transpiler called "awe", but no actual frontend for gcc/llvm/qbe).




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: