On Nov 28, 1:22 pm, Eivind Eklund <eekl... / gmail.com> wrote:
> On Nov 28, 2007 4:25 PM, William James <w_a_x_... / yahoo.com> wrote:
>
> > On Nov 28, 7:10 am, Lloyd Linklater <ll... / 2live4.com> wrote:
>
> > > William James wrote:
> > > > That C-code is hideous.  Let's compare it to something
> > > > that isn't insanely low-level.
>
> > > OOOOO!  I know this one!
>
> > > If you meant this as pascal, this is the code:
>
> > > function roll( n: integer ): integer;
> > > var i: integer;
> > > begin
> > >   for i := 1 to n do result := inc(result, random(6) + 1);
> > > end;
>
> > > There is no += in pascal.  If only...  :)  Your version where you init
> > > the result so you do not have to add may run faster but I golfed it a
> > > bit.  Still, it is far better than the C version.  I liked seeing it
> > > here too.  :)
>
> > Glad you liked it.  It strikes me as bizarre that so many Ruby
> > users who want more speed descend from the dizzying heights of
> > Ruby to the chthonic depths of ultra primitive C.  Why not use
> > Pascal?
>
> I would guess because more people know C than Pascal, and it is easier
> to link Ruby to C than to Pascal?
>
> Apart from that, having programmed both C and Pascal, I only see small
> differences in level.  Object Pascal aside, as far as I can remember
> from my Pascal programming days (15 years since I wrote my last line
> of Pascal - how time flies...), there's little abstraction available
> in Pascal that's not there in C - the most I can think of would be
> "with" and a nicer integration of the export/import module system.
>
> Care to enlighten me as to how you see these as being at very different levels?
>
> Eivind.

In C, in order to call by reference, you have to pass the address
of the variable to the function.

In C, you must use too many pointers.

In C, strings can't contain ASCII 0.

In C, there is no boolean type.

In Free Pascal, you have 1- and 2-dimensional dynamic arrays,
i.e., arrays that can be resized at runtime.

In Free Pascal, you have array slicing:
  average( scores[ 3..8 ] );
  write( name[ 5..20 ] );

In Pascal, you can have automatic buffer-overflow checking
if you want.

In Pascal, you have sets:
  if 'e' in good_chars then


"... the programming language C was designed to assist in
writing a small single-user operating system (UNIX) for a
real-time minicomputer (PDP 11), now thankfully obsolete.
For this purpose, its low level of abstraction and plethora
of machine-oriented features are entirely appropriate. For
all other purposes, they are a nuisance. The successful
propagation of the language can be explained by accidental,
commercial, historical, and political factors; it is hardly
due to any inherent quality as a tool for the reliable
creation of sophisticated programs." - C. A. R. Hoare,
1994.

One of the most famous C gurus, Kernighan, apparently
can't correct the bugs in his software because it's
written in C.  He has known of this bug in awk95 for
years:

BEGIN {
  FS = "@"
  $0 = "foo@bar"
  print $1
}

It prints "foo@bar", although it should print "foo".