ncreed@ndsuvax.UUCP (Walter Reed) (04/02/88)
In article <2642@crash.cts.com> haitex@pnet01.cts.com (Wade Bickel) writes: >duncanj@umd5.umd.edu (James Duncan) writes: >> >>What about those people FORCED to use Pascal for academic reasons. >>Say your in a class and are permitted to use any computer but MUST >>program in Pascal! Gee sorry Prof., but real programmers use C. >>Sorry no-name generic student but real students program in Pascal or >>they don't get a real grade in my all too real class. I had the same problem in some of my classes... >> >>Pascal is the de facto academic language. With the emphasis on personal >>computers these days often students are allowed to use any PC, but due to >>grading standardization the students are required to program in Pascal. >> >> Jim Duncan > > You should see if your Prof. will allow you to use Modula-2. > Modula-2 is the successor language to PASCAL. Both were created by >Niklaus Wirth. M2 is the derivative of Modual{-1} and PASCAL. Modula was a >systems programming language. The result is a language which gives you all >the niceities of PASCAL (well, most of them :^>), and the low level access >PASCAL denied (which forced us to go to C, or assembly). > M2 is *VERY* similar to PASCAL, so for grading purposes it should not > be a burdon to the graders. I can't see any reason a Prof. in his >right mind would not encourage using M2, as it is a vibrant language, whereas >PASCAL is a dead one :^>. > Wade. There are two major beefs I have with modula-2. 1. Modula does not allow a variable number of parameters in function calls. 2. Bitwise operators are not available (at least not standard.) Minor beef: Begin end's required even when only one statment used. Here is an example of why these things bother me. Pascal: If (x = True) Then WriteLn('Error #',e,' in line #',l,' detected.'); Modula-2: IF (x = TRUE) THEN WriteString("Error #"); WriteCard(e); WriteString(" in line #"); WriteCard(l); WriteString(" detected."); END; M2 is too verbose. Now, Modula 2 could be fixed, and should be fixed. Not having a variable number of parameters makes compiler writing simpler, but makes writing programs harder, and more time consuming. It may make debugging easier though. Now, modula-2 and pascal are both missing bit-wise manipulators. What is needed: BAND bitwise and BOR bitwise or BXOR bitwise xor BSHL function to shift bits left (returns the shifted number) BSHR function to shift bits right That helps alot. I had to write a microproccessor simulator in modula-2, and the lack of bitwise operators made my life a living hell (along with the problem of not having a variable number of parameters.) Fix these design flaws and allow single statements to be written easier and the language may even be usable. Hell, I may even use it! Borland could fix modula-2 like they fixed pascal. Modula-2 should never be forced upon students, it's inhumane. -- /* Walter Reed UUCP : uunet!ndsuvax!ncreed Internet : ncreed%NDSUVAX.BITNET@CUNYVM.CUNY.EDU Ph 701-235-0774 Bitnet : ncreed@ndsuvax OR NU105451@NDSUVM1 ------------------- */
cs178abu@sdcc8.ucsd.EDU (John Schultz) (04/03/88)
In article <764@ndsuvax.UUCP> ncreed@ndsuvax.UUCP (Walter Reed) writes: >There are two major beefs I have with modula-2. >1. Modula does not allow a variable number of parameters in function calls. >2. Bitwise operators are not available (at least not standard.) >Minor beef: > Begin end's required even when only one statment used. Addressing 1: Register oriented AOT stack oriented as in C (although I heard that Lattice now has register optimization). This is much faster runtime, although more verbose for the user. Benchmark has C routines such as printf, etc., but you must first initialize the parameter array before calling printf (still pretty nice though). 2. Modula-2 has *ALWAYS* had bitwise operators. They are: + : inclusive OR * : AND / : exclusive OR These operators have special meaning only when applied to BITSET types. For example: CONST mask = BITSET(15); VAR rotation : CARDINAL; BEGIN rotation := 0; ... rotation := CARDINAL(BITSET(rotation+1)*mask); ... Here we can increment a value from 0 to 15 and back again without any bounds checking. In C we could do: rotation = (rotation + 1) & 0xf; or maybe rotation = ++rotation & 0xf; or maybe ++rotation &= 0xf; Much less typing, but the same result. The *only* time BEGINs are used in Modula-2 are for the start of program code for PROCEDUREs or main MODULES. Everything terminates with an END. This is an improvement over Pascal and C, as it stops possible errors before they can start. >Here is an example of why these things bother me. > >Pascal: > If (x = True) Then > WriteLn('Error #',e,' in line #',l,' detected.'); Why not: IF x THEN printf(); END; >M2 is too verbose. Yeah, well, everything you want is available in C. Now, if you want the MODULE construct, etc. native to M2, the 10000-30000 lines per minute compilation times, "instant" linking, then take another look at M2. > Shifting... FROM SYSTEM IMPORT SHIFT (* example code *) SHIFT(x,1) x is unsgned, logical SL SHIFT(x,1) x is sgned, artihmetic SL SHIFT(x,-1) ... SR It's all there. Remember M2 was created for the development of large, system level software (like operating systems). Other than for personal taste, and/or development speed/portability, you can do anything on the Amiga with any of the popular compiled languages available today. John
sarge@sting.Berkeley.EDU (Steven Sargent) (04/04/88)
> There are two major beefs I have with modula-2. > 1. Modula does not allow a variable number of parameters in function calls. > 2. Bitwise operators are not available (at least not standard.) > Begin end's required even when only one statment used. > Here is an example of why these things bother me. > If (x = True) Then > WriteLn('Error #',e,' in line #',l,' detected.'); [M2 example elided] > M2 is too verbose. Be careful here: writeln is NOT an example of a variadic procedure -- it's actually a funny macro, provided by the Pascal compiler. If you don't believe me, try to define a variadic procedure in Pascal. Can't do it. For further evidence, consider the syntax write('Error #', e:1); Try putting the ':' into one of your own procedure calls. Can't do it. [specifications of BAND, BSHL, &c. bitwise operators elided] 'Twould be nice. You can do some of these things with logical-ops on BITSETs, but BSH[LR] would be tough. Write 'em in assembly language, I guess, or C; I don't like the subroutine overhead but it usually wins over trying to do it in "pure" Pascal/M2. > Borland could fix modula-2 like they fixed pascal. Are you the same guy who was concerned about bitwise operators not being standard? > Modula-2 should never be forced upon students, it's inhumane. If you're going to teach a language with unsafe semantics and klutzy syntax, why not just go with C? Or even Pascal, since M2 is not clearly better than Pascal for rank beginners. > -- > /* Walter Reed UUCP : uunet!ndsuvax!ncreed > Internet : ncreed%NDSUVAX.BITNET@CUNYVM.CUNY.EDU > Ph 701-235-0774 Bitnet : ncreed@ndsuvax OR NU105451@NDSUVM1 > ------------------- */ Steven Sargent ARPA Internet: sarge@scam.berkeley.edu MILnet: sarge%scam.berkeley.edu@ucbvax.berkeley.edu TPCnet: {anywhere at all, really}!ucbvax!scam!sarge