开发者

Low, mid, high level language, what's the difference?

开发者 https://www.devze.com 2023-01-11 12:09 出处:网络
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 som

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开发者_StackOverflow 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 a general idea programmers use to describe languages to each other?


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:

  • Machine Code could probably be considered the lowest level programming language.

  • Assembly language is at the level of telling the processor what to do. There is still a conversion step towards machine code.

  • 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.


low level = long development time + very fast executable file

high level = shorter development time + slower executable file

mid level is between the two


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.


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


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'.


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.


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.


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.


C is middle level language BECOZ we can use code in assembly language only slight difference pointer make it powerful (if pointer remove in c then it will consider in low level) It's portable feature make middle lavel so we can say it is middle level language.


it is all relative... the "level" reflect the amount of abstraction.


Once you add a spectrum of levels of a programming language you add nuance to the definition. Clearly machine code and assembly are machine-dependent. C and C++ in theory are machine independent but in truth that is not universal. In C things like alignment NEED to be taken into account and you can always manage the stack in C and in the C subset of C++) via a pointer and a single initialised variable - if you are crazy enough - so that (x86) the rsp is never used. So C, yes it is middle level. Everything else is high level some super high level.


Low level languages are very close to machine language that may be binary or RTL. Hard to write and very quick to execute. It can interacts with the hardwares and high level programming language is very easy to write but can be executed after compilation.

0

精彩评论

暂无评论...
验证码 换一张
取 消