🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #190

<None>

#190
From: sl8nl
Date: Sat, 25 Jul 1992 05:34
104 lines
3550 bytes
>>pity about the pascal code generation ( pascal is EASIER to optimize than
>>C, but no one (at least main-line compilers) seems to do it!!).compare
>>output of your favorite pascal compiler with the same ( functionally ) code
>>from MSC 6.0 (7.0??) or even watcom 9.0 ( with '486 code optimization ) and
>>you will see what I mean..
>>

Stony Brook compares quite favorably against these.  In fact, most of the code
is so compact, that even I, an code-optimizing freak :), had problems finding
things to optimize.

> I still like Turbo Pascal 6.0 better.  As I already optimize my code,
> I don't need any compiler to do so.  (So I don't get flamed): This does

I hand optimize my code, too, Mark.  Sometimes I use Stony Brook to turn
out assembly code so I don't have to write it.  Usually, it gets written
in straight assembly first, then thrown in to Pascal's inline assembly.
I generally don't like linking in .OBJ files.  Stony Brook handles them
wonderfully, but Turbo Pascal pukes on anything but procedure and 
function calls.

> (i.e. that arrays have to be constant).  As far as I can tell, this

The arrays don't have to be constant.  For instance:

type
  BArray = array[0..0] of Byte;

var
  B : ^BArray;
  NumElements : Integer;

begin
  Write('How many elements in the byte array: ');
  ReadLn(NumElements);
  GetMem(B,NumElements*SizeOf(Byte));
end;

This way, I can access B^[42] and B^[64000] quite easily...but I'll bet you
knew that and was referring to something else.

> is the only thing that separates C from Pascal.  On a final note,
> Pascal does have easier string handling and an ability to handle boolean
> functions.
> 
> This is one nice thing about TP:
> 
> function BoolTest(x,y:byte): boolean;
> begin
>  ...
> end;
> 
> begin
>  if BoolTest(10,40) then InsertAnotherSpiffyProcedureNameHereIfYouWant;
> end.

It does have easier string handling (hey, you C people, try doing this:
MyString := MyString + 'Hello' + MyString + ' Big String';  without using
C++ to generate a string operation class.), but C handles Boolean stuff
nicely, since the type casting isn't as strict.  For instance, the 
equivalent C procedure would have been:

char BoolTest(x,y)
unsigned char x,y;
{
  ...
}

main()
{
  if(BoolTest(10,40)) then InsertAnotherSpiffyProcedureNameHereIfYouWant;
}

One advantage of this is doing:

int IsThisTrue=1;

if(IsThisTrue) { ... }

In Pascal you'd have to typecast it:

const IsThisTrue : Integer = 1;

if Boolean(IsThisTrue) then begin ... end;


Don't get me wrong, Mark, I prefer Turbo Pascal over any of Borland's C
products: faster compile time, faster code, and smaller code.  But I wish
that Pascal were a bit less strict on its type casting.  I have a list of
what I'd want in the "perfect" language:

  C type casting.
  Pascal objects (C's multiple inheritance stinks!)
  The ability to perform ESP with the programmer.
  The ability to outguess the programmer on his/her next action.

OK, so it's far fetched.  I did like the game library idea:

  MakeGame(SPACE_GAME, WITH_LOTS_OF_WEAPONS, WITH_LOTS_OF_ALIENS ...

well, you get the drift.

Take care,
Josh
Technical Details
Message-ID: <1992Jul24.233412.57494@cc.usu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!cc.usu.edu!sl8nl
References: <l1hmxkp@lynx.unm.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!cc.usu.edu!sl8nl
From: sl8nl@cc.usu.edu
Newsgroups: rec.games.programmer
Subject: <None>
Message-ID: <1992Jul24.233412.57494@cc.usu.edu>
Date: 24 Jul 92 23:34:12 MDT
References: <l1hmxkp@lynx.unm.edu>
Organization: Utah State University
Lines: 105