joel@decwrl.UUCP (Joel McCormack) (01/31/85)
Modula-2 IS a good language for hacking, in fact, it was the combination of type-checking and low-level access that first got me interested in the language. David Sher's "problem" with dynamic arrarys is actually pretty easy. TYPE DynamicArray = POINTER TO ARRAY [0..0] (* [0..MaxInt] is also good *) OF CARDINAL (* or whatever *); Image = RECORD numberColumns: CARDINAL; numberRows : CARDINAL; image : DynamicArray; END; ... assume you have just filled in numberColumns and numberRows... WITH Image DO ALLOCATE (image, numberColumns*numberRows*TSIZE(CARDINAL)); END; ...accessing row, column, assuming 0-based... (* turn off range-checking if used [0..0] *) WITH Image DO image^[row*numberColumns + column] := ... END; Now, is that really significantly different from C? I would prefer to have support for dynamic arrays directly in the language, so that you wouldn't have to do your own array subscript calculations, and you could get range-checking as part of the normal indexing operation. But Modula-2 is certainly USABLE for this kind of thing. A real-life example is a Modula-2 program called StatPak by Richard Sincovec and Richard Wiener. This programs implements virtual arrays that can exist on disk, or in memory, and made use of the technique above. They also claimed that since they had modules to help get the organization of the program down, and type-checking to keep them from spending the rest of their lives debugging, they were able to include substantially more goodies running at a higher speed than the other statistical packages for micros. -- - Joel McCormack {ihnp4 decvax ucbvax allegra sequent utcsrgv}!decwrl!joel joel@decwrl.arpa
ee163acp@sdcc13.UUCP (DARIN JOHNSON) (02/01/85)
It appears the original author has shied away from modula-2 and will program in C forever from now on. This is silly, just because a language is not suited for a particular purpose is no reason to toss it out. Stop looking for a language that can do everything. Darin Johnson @UCSD (go ahead and flame, I've got my fire hat on)
sher@rochester.UUCP (David Sher) (02/03/85)
In article <142@sdcc13.UUCP> ee163acp@sdcc13.UUCP (DARIN JOHNSON) writes: > > It appears the original author has shied away from modula-2 and will > program in C forever from now on. This is silly, just because a > language is not suited for a particular purpose is no reason to toss it out. > Stop looking for a language that can do everything. > > Darin Johnson @UCSD (go ahead and flame, I've got my fire hat > on) Since it is me (David (original author) Sher) who is being castized here I figured I ought to respond. First I would like to thank the people who replyed (and the people who helped me in the hall ...). I now think that it is barely possible to do this though it would certainly be convinient to have streach arrays. However, I have found that one can use a style in C that is about as modular as modula2 by using .h files as mod2 uses definition modules .... Not quite as good but sufficient and being familiar with C I can program about 5 times as fast in it (lint does the strong typing for me (I like strong typing all my keys have dents in them)). About using different languages, I have used at various times: APL,BASIC,FORTRAN,PASCAL,LISP (various flavors),BLISS,C,SNOBOL, BCPL,MODULA2,PROLOG,MESA Also dec-20 assembly and I've probably forgot a few. They all are good at somethings and bad at others. Each of them fills an environmental niche to make a bad analogy to environmental biology. The problem with Modula 2 is that I think it is trying to fill the same niche as C. However C and lint and proper style seem to give you most of what Modula 2 gives and seems to be more flexible too. MESA also tries to fill a similar niche (admittedly on a different set of machines) but seems more flexible and is more pleasant to read than C. Thus I might consider choosing MESA rather than C if given the choice for doing vision hacking. I can not see any condition when I would choose Modula2 over C. By the way here is my list of languages and niches: APL Interactive numerical hacking, quick interactive hacks in general BASIC Quick hacks on micros FORTRAN Compiled numerical hacking. Super Portable code. PASCAL Good teaching language. Useful for simple programs. LISP AI programs, programs with strange flows of control such as programs that generate other programs and wierd things like that. BLISS Hardcore system programing on Dec operating systems. C Almost anything on a unix vax. It seems to be the only language with really good support. I use it for small system programs, vision programs, quick toys. SNOBOL Simple text processing. Any really good text processing was impossible on the version I worked on since the I/O thought it was hacking on cards. BCPL A neat small language for systems on small machines. It was one of the most pleasant looking and easy to learn and use languages I've come across. I haven't used it much though. MODULA 2 System programming but systems must do things that Wirth anticipated. PROLOG Another AI language. For programs that parse natural language or reason in certain ways this is a good language. MESA System programming language for XEROX machines. The version I worked on was retarded but never the less seemed like an ok language. Assembly Programs that need to access special features of the machine. Routines that are particularly critical and need to be optimized with tender loving care. On Dec-20's when combined with fortran can be a reasonable programming language (Fortran for flow control and assembly to do things). I expect flames but might not read them. -David Sher
ndiamond@watdaisy.UUCP (Norman Diamond) (02/10/85)
> > Since it is me who is being castized here I figured I ought to respond. > ---------- > I suppose it was probably just a typo ... Either that or an exafferation. :-) -- Norman Diamond UUCP: {decvax|utzoo|ihnp4|allegra|clyde}!watmath!watdaisy!ndiamond CSNET: ndiamond%watdaisy@waterloo.csnet ARPA: ndiamond%watdaisy%waterloo.csnet@csnet-relay.arpa "Opinions are those of the keyboard, and do not reflect on me or higher-ups."