gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Portability Considerations


From: Benjamin Kowarsch
Subject: Re: Portability Considerations
Date: Sat, 16 Mar 2024 19:03:34 +0900



On Sat, 16 Mar 2024 at 15:36, Alice Osako wrote:
As for PIM, now that I have a better idea of its history and
limitations, I am entirely willing to write Wirth's book - in all
editions - off as a legacy standard. It is no more relevant to new code
in Modula-2 than K&R C or Ada-83 would be for new code in those
languages. I can understand that it is very important for compiler
support, or to someone maintaining existing PIM code, but for something
written today it seems like a peculiar thing to be concerned about. Am I
wrong in thinking this way?

Well, ISO is as much a legacy standard as PIM.

As far as the core language is concerned there are only a few things in ISO that improved over PIM, notably

* delimiters for pragmas separate from those for comments
* support for structured constants other than sets, called structured value constructors
* making the control variable of a FOR loop explicitly undefined outside of the loop's body
* making unsafe type transfer explicit by introducing a CAST function to module SYSTEM

and that's about it. Pretty much all other modifications to the core language made things worse.

The bigger issue with PIM was the absence of a standard library. But although ISO provides a standard library, it is over-engineered. It is overly complex and thus difficult to teach and cumbersome to use. Even so, it doesn't cover much of the functionality needed in our day and age. Yet, if you have to supply your own library anyway, then you might as well write one for PIM, or portably for PIM and ISO.

In any event, writing portably usually leads to cleaner code and fewer bugs, regardless of the language used. This is so because writing portable code typically requires the use of abstraction layers and design the API from a functional point of view.

There is also the aspect of reputation. You put your code into a public repository with some kind of open source license and eventually somebody may use it with a different compiler and/or different dialect. Some of the troublespots I have mentioned have the nasty property of being syntactically compatible but semantically incompatible. This means, if somebody uses the code on a different compiler, for a different dialect or a different target, it may seem to work, until it doesn't. And whose reputation do you think is on the line then? The one who tweaked it to compile on a different compiler/dialect/target or the original author?

regards
benjamin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]