views:

179

answers:

8

I've heard these terms thrown around describing languages before. like C is not quite a low level language, C++ is a mid level, and Python is a High level language. I understand that it has to do something with the way the code is compiled, and how it is written. But what I want to know is what defines a language into one of those 3 categories? Are these absolute categories, or just kinda a general idea programmers use to describe languages to each other?

+11  A: 

Yes, they're just general terms. It's to do with abstraction, and how close you are to what the computer's actually doing.

Here's a list of programming languages ranging from very low to very high level:

  • Assembly language is at the level of telling the processor what to do; you can't get much more low level than that.

  • C is a step up from assembler, because you get to specify what you want to do in slightly more abstract terms, but you're still fairly close to the metal.

  • C++ does everything that C can do but adds the capability to abstract things away into classes.

  • Java/C# do similar things to C++ in a way, but without the opportunity to do everything you can do in C (like pointer manipulation in Java's case [thanks Joe!]). They have garbage collection though, which you have to do manually in C++.

  • Python/Ruby are even higher level, and let you forget about a lot of the details that you would need to specify in something like Java or C#.

  • SQL is even higher level (it's declarative). Just say "Give me all the items in the table sorted by age" and it will work out the most efficient way to carry this out for you.

Skilldrick
What about lisp? I would put that even higher than SQL. Also C# has pointer manipulation (unsafe blocks).
Joe D
@Joe D I think that's debatable (lisp being higher-level than SQL I mean)...
Skilldrick
@Joe D I would put lisp at the same level as Python probably. You still have to use programming constructs like conditionals and functions to do stuff... Unless of course you're on an old fashioned LISP machine, in which case it's low level B-)
Brian Postow
where would you put Shakespeare? ; ) http://en.wikipedia.org/wiki/Shakespeare_%28programming_language%29
Narcolapser
@Brian: I agree, lisp is probably around the same level as python, if not slightly higher.@Narcolapser: Probably at the same level as assembly, for it's lack of expressiveness, in other words very simple programs are very long.
Joe D
@narcolasper I think that there's a totally different scale for "silly languages" they aren't high, or low, or anything inbetween, they're just silly. Shakespeare, OOK, Brainf*ck, INTERCAL, etc are all silly.
Brian Postow
@Brian I was actually going to put brainfuck in there between assembly and C :) (The 8 brainfuck operators map directly to C constructs, so in a way brainfuck is just a very limited subset of C, but I guess that doesn't make it lower level)
Skilldrick
@Brain I think propositional logic had a term for that. Reductio ad absurdum. or Reduced to absurdity. or in this case, abstracted to absurdity. xD
Narcolapser
+2  A: 

They aren't absolute. They are all relative to what other languages are being used in industry at the time. For example, there was a time when assembly was considered mid-level.

The 'level' is essentially a measure of how abstracted the programmer is from the actual hardware-based operations. In a low level language you might have to care about actual memory locations, whereas in a high-level you just create variables and let the OS handle memory.

A normal CPU processes either 32 or 64-bit instructions. In the simplest form, think of this as an 32 1's and 0's in a row - that's what the processor actually interprets and executes. Writing this directly (machine code) would be the 'lowest-level'.

Adam S
+1  A: 

Low level means closer to the machine, and therefore more difficult and more powerful. The higher level you get, the more removed from the machine and "English-like" you get, but you lose a lot of the power and functionality that comes with being able to control the minute details of the machine. Higher level languages also generally tend to protect you more and have much more precautions and checks in place, while lower level languages trust you, so to speak, and let you play around at your own risk.

froadie
English like isn't really a good metric, because then you get COBOL as a high level language...
Brian Postow
Definitions of power vary, for example is assembly more powerful than lisp? That depends on what you mean by power, if power means that all features of the machine are available then yes, assembly is more powerful. But, if it means that more can be expressed in fewer lines of code (in this case much, much fewer) then lisp is clearly more powerful.
Joe D
A: 

The term mid-level language is one I've never heard.

"Low" and "High" refer to how "close" to the machine you are in your programming. The lowest level would be machine (binary) code. Next (and still considered low) is assembler. The higher level languages involve more symbolism and constructs that are supposed to be closer to how humans normally think. C (and somewhat C++) has a reputation as being somewhat a hybrid low/high level because it has many constructs that are in high level languages, but also has instructions (e.g. shifts) that are low level languages but often not in higher level languages.

GreenMatt
Mid-level is usually C/C++ and maybe D.
Joe D
+1  A: 

In computer science, a low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture. The word "low" refers to the small or nonexistent amount of abstraction between the language and machine language; because of this, low-level languages are sometimes described as being "close to the hardware." A low-level language does not need a compiler or interpreter to run; the processor for which the language was written is able to run the code without using either of these.

By comparison, a high-level programming language isolates the execution semantics of a computer architecture from the specification of the program, making the process of developing a program simpler and more understandable.

Middle level languages stand in between the above two

Ankur Mukherjee
This is the most clear and concise answer I've seen so far.
baultista
@baultista: Yes, that's because it's from Wikipedia: http://en.wikipedia.org/wiki/Low-level_programming_language
Skilldrick
+2  A: 

Very low-level: Machine Code

Low level: Assembler, Forth

Mid level: C, C++, most system programming languages

Mid/High level: D, Go, garbage collected system programming languages

High level: Java, C#, most interpreted languages

Even Higher level: Lisp dialects

Highest level: SQL, declarative programming languages

If there is anything else to be added, tell me.

Joe D
You could probably put Go at the mid/high level as well.
Skilldrick
A: 

From low to high, you can categorize the languages as follows.

Machine Code --> Assembly Language --> Compiled Language --> Interpreted Language

Remember that these aren't absolute black and white definitions, but rather shades of gray. This is more of a guideline than a rule.

Think of machine code as a long string of 1s and 0s understood by the native platform. Consider this your baseline... the lowest "level" you can have.

Assembly language could be considered a symbolic representation of this. I believe there is a 1 to 1 mapping between assembly code instructions and machine code instructions. This is your low level language.

Java and C++, for example, are both compiled languages, but many would consider C++ to be a lower level language than Java because it exposes low level system access, while Java runs in a protected environment (the virtual machine). Remember that a compiled language is compiled (converted, if you will) to machine code before execution. C is also a compiled language, but would be considered lower level than both Java and C++.

For our sake, we will say that C and C++ are low level languages because they offer (relatively) little abstraction from the hardware and direct memory management. In actuality, they fall somewhere between low and mid, as you will see soon enough.

We will call Java and C# (.NET) mid level languages because they have automatic memory management (garbage collection), plenty of high-level abstractions (IE objects... yet C++ supports objects. Do you see why the scale is considered to be loosely defined?)

With an interpreted language, the interpreter resides in memory and reads the source code directly. These are high level languages. Python, Perl, Javascript, and PHP are all examples of high level languages.

baultista