definition of a highlevel language?

Discussion in 'Python' started by notnorwegian@yahoo.se, May 26, 2008.

  1. Guest

    (might not be the right forum for this but...)

    what is the definition of a highlevel-language?

    well there isnt one specifically and wikipedia and the like gives just
    a very general description obv you can say it abstracts away lowlever
    operations.


    yes but how?

    a function like map takes a function and applies it to a list for
    example.
    this abstracts away a common procedure like iterate through a list and
    for every position do a computation.
    so it is a higherorderfunction. is this how higher-level-languages are
    built?


    so are they fundamentally differently built or is it just a lot of
    lowlevel operations built on top of each other?


    haskell is considered a very highlevellanguage but can you do
    systemsprogramming with it(yes maybe it is very unpractical i dont
    know but can you)?


    is lambda calculus a more abstract and efficient way of modeling a
    computer? meaning you start at a higher level of abstraction and can
    work up to even higher even faster?


    how did lispmachines work? was the basic system programmed in LISP?
    , May 26, 2008
    #1
    1. Advertising

  2. Guest

    There is no solid definition of "high level" that one can
    unambiguously use to classify programming languages into "high level"
    and "not high level," or "low level."

    My personal definition is something along the lines of: a high-level
    language is one which lets you solve problems without worrying about
    "accidental complexity." By "accidental complexity," I mean such
    things as manual memory management, needing to explicitly close files,
    etc.

    Of course, I consider Python to be "high level." It's garbage
    collected, so, no manual memory management (most of the time --
    sometimes the GC needs help); if I want to iterate through a sequence,
    I don't have to do crap like

    max = len (seq);
    for (int i = 0; i < max; ++i) {
    do something with seq;
    }

    I just do:

    for item in seq:
    do something with item

    Another piece of evidence that points to Python's high-level status is
    that if you take a look at some "pretty close to actual programming-
    language looking pseudocode," then translate it into Python, typically
    the Python code is not much longer than the pseudocode itself. On the
    other hand, translating pseudocode to C or Java often results 50-100%
    more lines of code than there were lines of pseudocode.
    , May 26, 2008
    #2
    1. Advertising

  3. Zentrader Guest

    On May 26, 11:34 am, wrote:
    > what is the definition of a highlevel-language?


    It is relative. A low-level language is lower/closer to the
    computer's binary code. C/C++ is a high-level language compared to
    assembly. Python is high-level vs. C/C++. Python is low-level
    compared to "spreadsheet programming", although some spreadsheets like
    Gnumeric can use Python extensions.
    Zentrader, May 26, 2008
    #3
  4. Guest

    On May 26, 2:34 pm, wrote:

    I wanted to address some other points I failed to mention in my first
    response.

    > so are they fundamentally differently built or is it just a lot of
    > lowlevel operations built on top of each other?


    Partly. A high-level language is essentially one that gives you high-
    level operations, like "apply the function f to each element of the
    sequence seq, and return [f(seq[0]), f(seq[1]), ... f(seq[n])].

    But, it's more than that. (You use Haskell as your example, but I'll
    use Python because I know it roughly a million percent better than
    Haskell... hehe.) In Python, you have support from the language to
    treat functions as first-class objects; in C, you explicitly cannot do
    this -- to map an arbitrary function over a sequence, you're
    restricted to accessing the function through a pointer. On the
    surface, it's the same operation, but that extra level of indirection
    can really bog one's mind down. Think about how difficult it is for a
    human to interpret the declaration of a function pointer in C, for
    instance.

    > haskell is considered a very highlevellanguage but can you do
    > systemsprogramming with it(yes maybe it is very unpractical i dont
    > know but can you)?



    > is lambda calculus a more abstract and efficient way of modeling a
    > computer?


    Lambda calculus doesn't model computers. It models *computation*.
    That is, given a Turing machine, there's a set of functions in the
    lambda calculus, which, when suitably combined, will yield the exact
    same result as the original Turing machine. That doesn't in any way
    imply that Turing machines work by interpreting lambda calculus.

    > how did lispmachines work? was the basic system programmed in LISP?


    Yes, the whole kit and kaboodle, all the way down to the microcode was
    programmed in LISP. In principle, there's no reason we couldn't have
    Haskell machines or Python machines. It's just that nobody's been
    crazy enough to do it, that I know of. :)
    , May 26, 2008
    #4
  5. Guest

    On 26 Maj, 20:57, wrote:
    > On May 26, 2:34 pm, wrote:
    >
    > I wanted to address some other points I failed to mention in my first
    > response.
    >
    > > so are they fundamentally differently built or is it just a lot of
    > > lowlevel operations built on top of each other?

    >
    > Partly. A high-level language is essentially one that gives you high-
    > level operations, like "apply the function f to each element of the
    > sequence seq, and return [f(seq[0]), f(seq[1]), ... f(seq[n])].
    >
    > But, it's more than that. (You use Haskell as your example, but I'll
    > use Python because I know it roughly a million percent better than
    > Haskell... hehe.) In Python, you have support from the language to
    > treat functions as first-class objects; in C, you explicitly cannot do
    > this -- to map an arbitrary function over a sequence, you're
    > restricted to accessing the function through a pointer. On the
    > surface, it's the same operation, but that extra level of indirection
    > can really bog one's mind down. Think about how difficult it is for a
    > human to interpret the declaration of a function pointer in C, for
    > instance.
    >
    > > haskell is considered a very highlevellanguage but can you do
    > > systemsprogramming with it(yes maybe it is very unpractical i dont
    > > know but can you)?
    > > is lambda calculus a more abstract and efficient way of modeling a
    > > computer?

    >
    > Lambda calculus doesn't model computers. It models *computation*.
    > That is, given a Turing machine, there's a set of functions in the
    > lambda calculus, which, when suitably combined, will yield the exact
    > same result as the original Turing machine. That doesn't in any way
    > imply that Turing machines work by interpreting lambda calculus.
    >
    > > how did lispmachines work? was the basic system programmed in LISP?

    >
    > Yes, the whole kit and kaboodle, all the way down to the microcode was
    > programmed in LISP. In principle, there's no reason we couldn't have
    > Haskell machines or Python machines. It's just that nobody's been
    > crazy enough to do it, that I know of. :)



    what is crazy about it?

    in the same way programming webapps in C would be annoying because you
    have to do a lot of lowlevel tasks it is dumb to program computer ina
    highlevellanguage because you dont have direct access to lowlevel
    tasks meaning you cant program it very efficiently, ie make it fast?
    , May 26, 2008
    #5
  6. Dan Upton Guest

    On Mon, May 26, 2008 at 2:50 PM, Patrick Mullen <> wrote:
    > It basically works like this
    >
    > low level to high level
    >
    > machine code
    > assembly -> translates to machine code
    > c -> compiles to assembly and machine code
    > python -> commands interpreted by a vm running on c
    >


    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, because
    for instance you might have a comparison between something like Java
    and C++ where the individual statement doesn't do any more or less
    work (say, creating a new instance of an object), but if you take into
    account all of the JVM instructions for intepreting or JITing the
    bytecode you'd get a lot higher ratio of assembly instructions to
    source statements.
    Dan Upton, May 26, 2008
    #6
  7. Guest

    On May 26, 3:02 pm, wrote:

    > what is crazy about it?


    To make, say, a Python machine fast, you'd have to optimize the hell
    out of the architecture, probably all the way down to the microcode
    level. Thus, a hypothetical hardware-based Python machine would look
    very little like other, more conventional chips like x86 or ARM, for
    instance. In fact, I suspect it'd look a lot like the CPython virtual
    machine on an instruction level.
    , May 26, 2008
    #7
  8. Guest

    On May 26, 3:03 pm, "Dan Upton" <> 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 );
    }

    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.)
    , May 26, 2008
    #8
  9. inhahe Guest

    I like to think of a language that would combine low-level and high-level
    features to be used at the programmer's whim. C--, High Level Assembly, and
    C++ with in-line assembly are examples, but none of them come as high-level
    as Python. Other possible examples might be ctypes, numpy, array.array, and
    I heard a rumor that Python 3.0 might have optional type declarations. My
    ideal language would be like a version of C++ (including in-line asm), or
    C-- with classes, that's compiled, but supports Python abstractions and
    features wherever possible (including doing away with {}'s and ;'s).

    >
    > what is crazy about it?
    >
    > in the same way programming webapps in C would be annoying because you
    > have to do a lot of lowlevel tasks it is dumb to program computer ina
    > highlevellanguage because you dont have direct access to lowlevel
    > tasks meaning you cant program it very efficiently, ie make it fast?
    inhahe, May 26, 2008
    #9
  10. Dan Upton Guest

    On Mon, May 26, 2008 at 3:22 PM, <> wrote:
    > On May 26, 3:02 pm, wrote:
    >
    >> what is crazy about it?

    >
    > To make, say, a Python machine fast, you'd have to optimize the hell
    > out of the architecture, probably all the way down to the microcode
    > level. Thus, a hypothetical hardware-based Python machine would look
    > very little like other, more conventional chips like x86 or ARM, for
    > instance. In fact, I suspect it'd look a lot like the CPython virtual
    > machine on an instruction level.


    I don't know if it would necessarily look like the CPython VM, except
    for the decode stage (this being said without any knowledge of the
    CPython implementation, but with more than I ever thought I'd know
    about processor architecture/microarchitecture)--I guess it depends on
    if you'd have to treat Python bytecode instructions as CISC and then
    would want to convert them to micro-ops to execute. I don't know
    about the LISP machine, but I know that many if not all of the
    attempted implementations of Java machines really just ran Java
    bytecode as its native instruction set. (I assume they did some
    optimizations though to actually use registers rather than treating it
    as a stack machine, or maybe they just had a register stack.)

    The point about them looking very little like x86/ARM/etc chips is the
    important part though--IIRC, part of the failure of Java machines was
    lousy support for preexisting code, due to the optimizations for Java
    bytecode, and I expect the same would be true of a Python
    bytecode-optimized processor.
    Dan Upton, May 26, 2008
    #10
  11. Guest

    guess what im after is:


    > max = len (seq);
    > for (int i = 0; i < max; ++i) {
    > do something with seq;
    >
    > }


    >
    > for item in seq:
    > do something with item


    is the first example here a layer between machine and the second
    example?

    is it machine -> low-level -> highlevel
    or is it machine -> highlevel

    ?
    , May 26, 2008
    #11
  12. Guest

    On May 26, 3:56 pm, wrote:

    > is the first example here a layer between machine and the second
    > example?


    My first example was intended to be C, or at least close to it. The
    second example is Python. I consider the C snippet to be low-level,
    while the corresponding Python is high-level. There are simply fewer
    extraneous details for me to worry about at the Python level, and
    that's why I prefer to work with Python over C when practical.
    , May 26, 2008
    #12
  13. inhahe Guest

    > is it machine -> low-level -> highlevel
    > or is it machine -> highlevel
    >
    > ?


    yeah, machine is the lowest level, c is higher than machine. there isn't
    much that is lower level than c that isn't machine code. (assembler is just
    mnemonics for machine code, for the most part). it's machine ->
    low-level -> high level
    inhahe, May 26, 2008
    #13
  14. Guest

    On 26 Maj, 22:16, wrote:
    > On May 26, 3:56 pm, wrote:
    >
    > > is the first example here a layer between machine and the second
    > > example?

    >
    > My first example was intended to be C, or at least close to it. The
    > second example is Python. I consider the C snippet to be low-level,
    > while the corresponding Python is high-level. There are simply fewer
    > extraneous details for me to worry about at the Python level, and
    > that's why I prefer to work with Python over C when practical.


    i know one is C and one i spython, iwas talking more at a conceptual
    level and i know cpython is written in C.

    what im asking is can a highlevellanguage be written directly on top
    of the machine or a highlevellanguage is always written on top of a
    lowlevellanguage?

    i eman do they have basic operators that are more abstract in their
    nature?
    , May 26, 2008
    #14
  15. MRAB Guest

    On May 26, 8:43 pm, "inhahe" <> wrote:
    > I like to think of a language that would combine low-level and high-level
    > features to be used at the programmer's whim. C--, High Level Assembly, and
    > C++ with in-line assembly are examples, but none of them come as high-level
    > as Python. Other possible examples might be ctypes, numpy, array.array, and
    > I heard a rumor that Python 3.0 might have optional type declarations. My
    > ideal language would be like a version of C++ (including in-line asm), or
    > C-- with classes, that's compiled, but supports Python abstractions and
    > features wherever possible (including doing away with {}'s and ;'s).
    >

    [snip]
    The problem with in-line asm is that it's processor-specific; I think
    that going lower level than C would be a mistake, except in very
    special cases.
    MRAB, May 26, 2008
    #15
  16. On Mon, 26 May 2008 13:51:46 -0700, notnorwegian wrote:

    > what im asking is can a highlevellanguage be written directly on top
    > of the machine or a highlevellanguage is always written on top of a
    > lowlevellanguage?


    What do you mean by "directly on top of the machine"? How do you want to
    implement a language without using *another* language? At the very lowest
    level there's machine language. And of course it is possible to implement
    high level languages in machine language. That's a lot of work and not
    very portable of course.

    Ciao,
    Marc 'BlackJack' Rintsch
    Marc 'BlackJack' Rintsch, May 26, 2008
    #16
  17. On May 26, 4:51 pm, wrote:

    > On 26 Maj, 22:16, wrote:
    >
    > > On May 26, 3:56 pm, wrote:

    >
    > > > is the first example here a layer between machine and the second
    > > > example?

    >
    > > My first example was intended to be C, or at least close to it.  The
    > > second example is Python.  I consider the C snippet to be low-level,
    > > while the corresponding Python is high-level.  There are simply fewer
    > > extraneous details for me to worry about at the Python level, and
    > > that's why I prefer to work with Python over C when practical.

    >
    > i know one is C and one i spython, iwas talking more at a conceptual
    > level and i know cpython is written in C.
    >
    > what im asking is can a highlevellanguage be written directly on top
    > of the machine or a highlevellanguage is always written on top of a
    > lowlevellanguage?


    In principle it can be written directly on top of the machine. In
    practice it doesn't, for the same reasons we don't build spaceships by
    directly gluing molecules together. Civilization as we know it would
    be impossible without hierarchical levels of abstraction.

    George
    George Sakkis, May 26, 2008
    #17
  18. Avowkind Guest

    On May 27, 6:34 am, wrote:
    > (might not be the right forum for this but...)
    >
    > what is the definition of a highlevel-language?
    >
    > well there isnt one specifically and wikipedia and the like gives just
    > a very general description obv you can say it abstracts away lowlever
    > operations.
    >
    > yes but how?
    >
    > a function like map takes a function and applies it to a list for
    > example.
    > this abstracts away a common procedure like iterate through a list and
    > for every position do a computation.
    > so it is a higherorderfunction. is this how higher-level-languages are
    > built?
    >
    > so are they fundamentally differently built or is it just a lot of
    > lowlevel operations built on top of each other?
    >
    > haskell is considered a very highlevellanguage but can you do
    > systemsprogramming with it(yes maybe it is very unpractical i dont
    > know but can you)?
    >
    > is lambda calculus a more abstract and efficient way of modeling a
    > computer? meaning you start at a higher level of abstraction and can
    > work up to even higher even faster?
    >
    > how did lispmachines work? was the basic system programmed in LISP?



    A lot of the previous comments have been about levels of abstraction
    of the programming langauge - which may be the answer you want.
    Another way of looking at it is that we want to be able to move from
    the language of the solution domain - e.g. computers, bits and bytes
    to the language of the problem domain.

    When we think about 'level' we don't just want to look at how basic
    statements work. we also need to think about whether the language is
    capable of simply and clearly expressing the problem.

    If your problem domain is mathematics then mathcad and its ilk are
    near perfect high level programming languages as the programs look
    just like the problems.

    if your problem domain is controlling a water works then you may tend
    to write your problem like this:

    if the water level is over 10 metres then start pump
    if the water level is below 5 metres then stop pump

    which in python might turn out to be

    if water_level > 10:
    pump.start()
    if water_level < 5:
    pump.stop()

    which is fairly close.
    of course with the addition of some brackets C++ could be this clear
    too. The key though is the abstraction given by the pump class and
    implicitly by object oriented design.


    In this pattern Form designers, visual web page layout tools and their
    ilk are very high level - but only if your problem is that you need to
    design a lot of business forms or web pages. Some problems are best
    described visually, some in text, some in mathematics.

    Andrew.
    Avowkind, May 27, 2008
    #18
  19. On May 26, 3:34 pm, wrote:
    >
    > what is the definition of a highlevel-language?
    >

    There's no formal definition of high level language. Thus, the
    following are true:

    1) You can safely treat it as buzzword
    2) You can't formally define a level hierarchy of languages
    3) You can't formally classify any language as high, low, etc. level
    4) Language theory literature ignore this term, so it's also
    irrelevant
    5) You can use it to vaguely criticize a language that you don't like
    as being too high/low level :)
    6) You shouldn't try to label a language as high level or low level
    or something else without a context
    7) You probably should ignore this term

    Now we have a problem. How can we define the "easiness" of a
    language ?

    I think a good way to do this is simply list the language
    architecture/paradigms and philosophy and let the listener decide by
    himself if it's an "easy" language or not.

    For a great example, see the description of python at:

    http://www.python.org/about/
    Henrique Dante de Almeida, May 28, 2008
    #19
  20. Stef Mientki Guest

    Avowkind wrote:
    > On May 27, 6:34 am, wrote:
    >
    >> (might not be the right forum for this but...)
    >>
    >> what is the definition of a highlevel-language?
    >>
    >> well there isnt one specifically and wikipedia and the like gives just
    >> a very general description obv you can say it abstracts away lowlever
    >> operations.
    >>
    >> yes but how?
    >>
    >> a function like map takes a function and applies it to a list for
    >> example.
    >> this abstracts away a common procedure like iterate through a list and
    >> for every position do a computation.
    >> so it is a higherorderfunction. is this how higher-level-languages are
    >> built?
    >>
    >> so are they fundamentally differently built or is it just a lot of
    >> lowlevel operations built on top of each other?
    >>
    >> haskell is considered a very highlevellanguage but can you do
    >> systemsprogramming with it(yes maybe it is very unpractical i dont
    >> know but can you)?
    >>
    >> is lambda calculus a more abstract and efficient way of modeling a
    >> computer? meaning you start at a higher level of abstraction and can
    >> work up to even higher even faster?
    >>
    >> how did lispmachines work? was the basic system programmed in LISP?
    >>

    >
    >
    > A lot of the previous comments have been about levels of abstraction
    > of the programming langauge - which may be the answer you want.
    > Another way of looking at it is that we want to be able to move from
    > the language of the solution domain - e.g. computers, bits and bytes
    > to the language of the problem domain.
    >
    > When we think about 'level' we don't just want to look at how basic
    > statements work. we also need to think about whether the language is
    > capable of simply and clearly expressing the problem.
    >
    > If your problem domain is mathematics then mathcad and its ilk are
    > near perfect high level programming languages as the programs look
    > just like the problems.
    >
    >

    Andrew, that's very good description, and I totally agree !
    > if your problem domain is controlling a water works then you may tend
    > to write your problem like this:
    >
    > if the water level is over 10 metres then start pump
    > if the water level is below 5 metres then stop pump
    >

    I would go one step beyond that, and state the problem as:
    "keep the reservoir full, but not too full"
    > which in python might turn out to be
    >
    > if water_level > 10:
    > pump.start()
    > if water_level < 5:
    > pump.stop()
    >
    > which is fairly close.
    >

    And now the solution is less close ;-)
    And it becomes even less close,
    if we extend your solution somewhat more to a real world implementation,
    something like this:

    control = True
    while control :
    if water_level > 10:
    pump.start()
    if water_level < 5:
    pump.stop()


    And if you would propose this solution to a control system engineer,
    he/she would say: "this solution works very bad" or even "this solution
    won't work"
    A solution that would work, should incorporate at least a hysteresis and
    could look like this:

    control = True
    State = False
    while control :
    if State and ( water_level > 10 ) :
    pump.start()
    State = not ( State )
    elif not ( State ) and ( water_level < 5 ) :
    pump.stop()
    State = not ( State )

    and now what's the resemblance to the orginal problem :
    "keep the reservoir full, but not too full"
    ;-)

    So an adequate high level language,
    should do exactly like a control engineer would do (btw I'm not a
    control engineer):
    1- asking what do you mean by "full"
    2- not asking what's the other level,
    but asking what's the intended use: how often and how many water is
    added or used,
    what are the costs of the pump, etc etc
    after which
    the control engineer
    or
    the high level language
    can calculate the optimal hysteresis.
    > of course with the addition of some brackets C++ could be this clear
    > too. The key though is the abstraction given by the pump class and
    > implicitly by object oriented design.
    >
    >
    > In this pattern Form designers, visual web page layout tools and their
    > ilk are very high level - but only if your problem is that you need to
    > design a lot of business forms or web pages. Some problems are best
    > described visually, some in text, some in mathematics.
    >

    I agree that some problems are better described in one or the other form,
    but it's not the major issue.
    e.g. Flowcharts are a perfect high level solution for problems in many
    domains.
    But flowcharts, just like computer languages, visual design languages
    and math,
    are only valuable in the hands of domain experts.

    What the major issue is,
    that makes a computer language or a design environment in general,
    really high level,
    is the availability of the domain expertise.

    Therefor the only high level language I'm aware of is ...
    .... LabView

    Labview offers a lot of domain expertise in almost any domain,
    so anyone
    with just a little knowledge of the problem domain,
    and
    with just a little programming experience or math knowledge,
    can solve any problem in every domain with Labview.
    Possibly I'm exaggerating a bit ;-)


    cheers,
    Stef

    > Andrew.
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
    Stef Mientki, May 28, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jianli Shen
    Replies:
    1
    Views:
    557
    Victor Bazarov
    Mar 13, 2005
  2. Ark
    Replies:
    1
    Views:
    398
    Chris Torek
    Aug 7, 2004
  3. Jon Slaughter
    Replies:
    4
    Views:
    422
    Jon Slaughter
    Oct 26, 2005
  4. Tomás Ó hÉilidhe
    Replies:
    10
    Views:
    501
    Tomás Ó hÉilidhe
    Nov 28, 2007
  5. Pierre Yves
    Replies:
    2
    Views:
    468
    Pierre Yves
    Jan 10, 2008
Loading...

Share This Page