Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site unm-cvax.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!cornell!uw-beaver!tektronix!hplabs!hao!seismo!cmcl2!lanl-a!unm-cvax!janney
From: janney@unm-cvax.UUCP
Newsgroups: net.lang.mod2
Subject: Modula-2 vs. C
Message-ID: <1093@unm-cvax.UUCP>
Date: Tue, 7-Aug-84 03:35:05 EDT
Article-I.D.: unm-cvax.1093
Posted: Tue Aug  7 03:35:05 1984
Date-Received: Sun, 12-Aug-84 01:28:35 EDT
Organization: Univ. of New Mexico, Albuquerque
Lines: 56

I doubt if we will get a "long and fruitless debate" over Pascal vs.
Modula-2.  Modula-2 is too clearly an improvement over Pascal.  Even
the "advantages" of Pascal can be considered disadvantages, as they
make the language larger and more difficult to implement.  Let's talk
about a more interesting comparison:  Modula-2 vs. C.  I'll make some
initial comments to get things going.

Advantages of Modula-2

	Clean, consistent support for the notion of data types and data
	structures.  This is probably the biggest advantage.  Type
	declarations are clear and readable even for complicated types,
	whereas even simple declarations in C take some getting used to.
	Arrays and records are passed to procedures in the same way.
	You don't have to worry about how to declare NULL.

	Many aspects of program correctness can be checked by the
	compiler, thus eliminating whole classes of errors.  The
	separation of definition and implementation modules makes
	it easy to do checking across files.  This, and the whole
	concept of modules, should be most valuable in very large
	projects.

Advantages of C

	Unquestionably, the greatest advantage of C is its unification
	of pointers and arrays, and the ability to do address
	arithmetic in a simple and well-defined way.  Properly used,
	this flexibility can greatly simplify many programs.  It
	allows a natural, useful implementation of strings without
	further extension of the language.

	Global data, in particular arrays, can be initialised at load
	time--in Modula-2, all initialization must be done with executable
	code.  This is particularly useful in table-driven software
	like the output of yacc or lex.

	Having a built-in, standard (well, mostly standard) preprocessor
	can be really nice.  It's nice to be able to give a complicated
	expression a symbolic name without incurring the overhead of a
	function call.  On the other hand, file inclusion wouldn't be
	too useful in Modula-2: that's what the modules are for.

	A really nifty for loop, and the ability to break out of any
	kind of loop.

Some differences that are arguable are runtime array bounds checking,
sets vs. explicit bit manipulation, and of course syntax.  I claim that
the "ease of typing" argument is a bogey-man: when I edit a Pascal program,
I have vi set up so that when I type ^B I get begin, ^E end, ^P procedure,
and so on.  This should be possible with any good screen editor.

Hoping to see some more discussion,

Jim Janney
{{ucbvax,gatech}!unmvax, {purdue,lbl-csam,ihnp4!cmcl2}!lanl-a}!unm-cvax!janney