Microsoft open sources GWBASIC

Fred Cisin cisin at xenosoft.com
Fri May 29 17:41:39 CDT 2020


On Fri, 29 May 2020, Paul Koning via cctalk wrote:
> Yes.  But the same is true for many languages.  Fortran is a 
> particularly good example, but there are plenty of portable languages 
> (Algol, Basic, LISP, Python, COBOL, Ada, RPG, ...).  Some more than C; 
> for example, C doesn't like one's complement machines (though it has 
> been ported to at least one) and things get somewhat interesting if the 
> machine doesn't have byte addressing.
>
> Since C aims to be a system implementation language, unlike Fortran or 
> Basic or Algol, it tends to expose, or at least let you see, machine 
> details.  That can get in the way of portability.  One small example is 
> that C thinks address 0 is a null pointer rather than a valid pointer. 
> On modern systems that is true (partly because C says so) but on a 
> PDP-11 it isn't.

Yes, a pointer to the PC Interrupt Vector Table could be problematic.

C lets you do a lot of things that some other languages will protect you 
from.  Accordingly, Allen Holub titled one of his books about C, "Enough 
Rope To Shoot Yourself In The Foot"
ISBN-10: 0070296898
ISBN-13: 978-0070296893


Run-time error checking can prevent some types of problems, but using it 
where it wasn't needed is a significant performance hit.
C encourages/forces YOU to write your own run-time error checking and put 
it in wherever it is needed.  And ONLY where it is needed.

Over-simplified example:
X=3;
. . .
. . . 
if (x==0) break;  /* is this needed? IFF x could become 0 */
Z = Y / X;  /* a problem IFF X could be zero without run-time checks */ 
C expects YOU to take responsibility for such things.


Also, example, if you are inconsistent about using bit patterns V numeric 
value on negative numbers, . . .
Numeric range bounds and variable sizes are not constrained, so must be 
considered in any porting that is done.  For example, adding one to 
integer 32767 or 2147483647 is dependent on number of bits and whether 
your system is using 2's complement, 1's complement, or some other binary 
notation for negative numbers.

C makes it EASY to do some totally inappropriate things.
For example, file size in MS-DOS is 32 bits.  But it is a SIGNED 32 bits! 
Resulting in file limits of -2,147,483,648 to 2,147,483,647   YES, in some 
versions of MS-DOS, you can step on the last four bytess of a directory 
entry, and it will report a negative file size.  Sadly, copying negative 
sized files to a disk does not increase the free space.
Similarly, MS-DOS limits FAT16 volumes to 2147483647 (due to SIGNED 32 
bit int?), whereas NT let you have 4,292,967,295 bytes in a FAT16 volume 
(UNSIGNED 32 bit int?)



"float" is often 32 bit IEEE floating point, but that is not hard coded 
into the language.
Making assumptions, such as that could be problematic.


More information about the cctalk mailing list