For example in Modula-2 there's a 1000 lines, what will that convert to in C?
Terry
Program is Written in Modula-2 How Much Larger is it in C?
Moderator: Ras
-
- Posts: 16465
- Joined: Wed Aug 01, 2007 4:16 am
- Location: Canada
-
- Posts: 313
- Joined: Wed Mar 08, 2006 8:18 pm
Re: Program is Written in Modula-2 How Much Larger is it in
The question is too open.Terry McCracken wrote:For example in Modula-2 there's a 1000 lines, what will that convert to in C?
Terry
It depends a lot on the Modula-2 program itself. How it's written, whether it's pretty formated, etc.
And it depends on the kind of C code you write. Compact or very open.
Wirth's languages (Pascal, Modula-2, Algol-W) are very wordy. They do tend to encourage fairly open and readable programs at the expense of extra typing.
Just making a guess... I'd say that if you did a straight conversion, you would certainly save some bytes of source. { } instead of BEGIN END and that sort of thing. But not a lot because most of the program is likely to be the chess program rather than the language.
As for the style of programming causing a difference... That's really hard to say becuase it's going to depend a lot on the style you write while converting it.
Maybe a little smaller source code, but nothing truely substantial. Anything C can do can be done in Modula-2 & modern Pascal's, just with a few more bytes of source for the wordiness.
How you do it is likely to have nearly as much effect as the language.
Not very helpful, I'll admit. It's just too open of a question.
But it is interesting that you brought up this subject, because I've been looking at a chess program in Algol-W (Wirth's version of Algol, which he later morphed into Pascal).
There has been some talk about converting it to C, but Pascal might be easier. It uses nested procesures and regular C can't handle that.
-
- Posts: 1922
- Joined: Thu Mar 09, 2006 12:51 am
- Location: Earth
Re: Program is Written in Modula-2 How Much Larger is it in
Haha Terry, you already used both of your guesses.
I guessed before I knew whether to use the GUI or not. Who knows though. It's a shame we have to wait so long to get the answer!
I guessed before I knew whether to use the GUI or not. Who knows though. It's a shame we have to wait so long to get the answer!
-
- Posts: 1808
- Joined: Wed Mar 08, 2006 9:19 pm
- Location: Oslo, Norway
Re: Program is Written in Modula-2 How Much Larger is it in
No big difference, I would guess. Both languages are Algol ancestors and fairly similar, except for syntactic differences. The Modula-2 syntax is somewhat more verbose (but more readable), so I'd expect the C translation to be slightly shorter.Terry McCracken wrote:For example in Modula-2 there's a 1000 lines, what will that convert to in C?
In any case, a 1000 line program is very small; you would need a much bigger program to get a meaningful measure of the relative conciseness of different programming languages. C is optimized for conciseness at a microscopic level: The syntax is very terse, and makes it possible to write simple programs with a very small number of lines and characters. On the other hand, because of the lack of high-level abstractions, very complex programs in C will usually be very long (and frequently slow and buggy).
Tord
-
- Posts: 16465
- Joined: Wed Aug 01, 2007 4:16 am
- Location: Canada
Re: Program is Written in Modula-2 How Much Larger is it in
Thanks everyone for all your answers and patience! I really know next to nothing in the realm of programming.
-
- Posts: 16465
- Joined: Wed Aug 01, 2007 4:16 am
- Location: Canada
Re: Program is Written in Modula-2 How Much Larger is it in
Yep I did...what a Dumb$h!t I amZach Wegner wrote:Haha Terry, you already used both of your guesses.
I guessed before I knew whether to use the GUI or not. Who knows though. It's a shame we have to wait so long to get the answer!

Terry