definition of a highlevel language?
miller.paul.w at gmail.com
miller.paul.w at gmail.com
Mon May 26 15:28:22 EDT 2008
On May 26, 3:03 pm, "Dan Upton" <up... at virginia.edu> wrote:
> Alternately, you can think of a pseudo-continuum from low level to
> high level, sort of as a function from language lines to assembly
> instructions... for instance, I seem to recall reading somewhere that
> made the example of BASIC being higher level than C because one
> statement in BASIC translated to, on average, 5 assembly instructions,
> whereas a C statement translated to, on average, 2.5 assembly
> instructions. Of course, maybe that's not the best metric ....
That might be a reasonable place to start. But, remember the example
I gave for C/Python where
int max = len (seq);
for (int i=0; i < max; ++i) {
somefunc ( seq[i] );
}
in C was more or less equivalent to
for item in seq:
somefunc (item)
in Python? Not only does the C code take up one more line, but it has
a lot of additional cruft with declaring variables, making sure the
iteration doesn't go out of bounds, and all that fiddly stuff you
don't have to worry about in Python.
Perhaps a better measure would be "how many language elements do I
need to express what I want to express." In this case, I count around
10-11 in the C code, versus 5-6 in the Python code. Thus, I'd say for
this particular case of iterating a sequence, Python is twice as
expressive as C. (This is even giving C a little credit, because I
just assumed there was this function "len" that returned the size of
whatever sequence-thing. In reality, you'd need to put more
boilerplate in to make something like that work.)
More information about the Python-list
mailing list