🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1193

Re: Cheap implementations of languages (Re: Pointers and poor implementations (was: Re: JLG's flogging ...))

#1193
From: Sean Fagan
Date: Wed, 11 Apr 1990 08:20
65 lines
3589 bytes
In article <14317@lambda.UUCP> jlg@lambda.UUCP (Jim Giles) writes:
>The fact is that C is not simpler to implement
>than the other procedural languages in general use.  In some ways it
>is harder to implement.  

I beg to differ.  One of the reasons C is easier to deal with is the lack of
the various keywords and semantic "gotchas" that other languages have.

>  a)  Lexical scanning and parsing.

Not a problem, really, for either language.  In fact, for any sane language
(i.e., anything other than PL/I 8-)), this isn't too difficult.

>  b)  Symbol table manipulation.

Same thing.  This is pretty easy.  Once you differentiate between local and
global, going the extra step for nested levels is fairly simple.

>     In C, references are explicitly pointers
>     and are allowed to be aliased.  In Fortran, the references
>     are implicit and aliasing is NOT permitted.  This means
>     that C procedures contain a lot of spurious dependencies
>     in the intermediate code that Fortran intermediate code
>     doesn't have.

This does not make the implementation any more difficult; it makes
implementing it *well* a bit more difficult.  But, then, the kinds of
optimization needed to improve the code are fairly easy.

>  b) Structs, Unions, dynamic memory, pointers, recursive procedures ....
>
>     C has em, Fortran doesn't.  Fortran is easier to implement
>     on all of these counts.

Really?  What happened to EQUIVALENCEs?  Sounds like unions to me.  Pretty
disgusting, actually.  COMMON blocks are also disgusting.

struct's and union's are very easy to implement:  you just reuse your symbol
table stuff, mentioned above, and voila!  Dynamic memory is a feature of the
pointers (the compiler most likely knows nothing about malloc et al).
I don't understand your point about recursive procedures.  There is no
difference, on most modern machines, between a function calling itself and a
function calling another procedure.  In FORTRAN *or* C.  The major
exceptions tend to be machines designed by Seymour Cray, but that argument
really belongs in comp.arch 8-).

There are a lot of strange things in fortran.  Wish I had any of my books on
it so I could write some code to really confuse people, but, off the top of
my head, I can think of one:  the various parameters to open or close.
Unix's model is *much* cleaner, and it's pretty ugly.

Implementing a simple C compiler, which still is largely ANSI compliant
really is not that difficult.  Say, a semester project for an undergrad.
Implementing a FORTRAN compiler which is also ANSI compliant is considerably
more difficult (note that FORTRAN doesn't make a distinction between
language and library, so you have to write all of the routines, while you
don't in C), call it 2-4 for the same student.

-- 
-----------------+
Sean Eric Fagan  | "It's a pity the universe doesn't use [a] segmented 
seanf@sco.COM    |  architecture with a protected mode."
uunet!sco!seanf  |         -- Rich Cook, _Wizard's Bane_
(408) 458-1422   | Any opinions expressed are my own, not my employers'.
Technical Details
Message-ID: <5610@scolex.sco.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!sco!seanf
References: <YAT2FR7ggpc2@ficc.uu.net> <14317@lambda.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!sco!seanf
From: seanf@sco.COM (Sean Fagan)
Newsgroups: comp.lang.misc
Subject: Re: Cheap implementations of languages (Re: Pointers and poor implementations (was: Re: JLG's flogging ...))
Message-ID: <5610@scolex.sco.COM>
Date: 11 Apr 90 08:20:18 GMT
References: <YAT2FR7ggpc2@ficc.uu.net> <14317@lambda.UUCP>
Sender: news@sco.COM
Reply-To: seanf@sco.COM (Sean Fagan)
Organization: The Santa Cruz Operation, Inc.
Lines: 65