4 ms·
I thought Java was on a much lower level than Python. Why is C more low-level?
by Kiro 13y ago
I thought Java was on a much lower level than Python. Why is C more low-level?
- alecdbrooks 13y agoWell, did you read the article? It describes manual memory management, which is probably the most obvious reason C is lower level. It also talks about how strings are stored directly as arrays of characters as opposed to objects wrapping character arrays. Finally, C pointers are closer to how the computer operates (they're basically memory addresses) than anything in Python or Java. What constitutes a "low level language" is a matter of perspective, however. From the perspective of writing binary instructions by hand, all three languages are "high level." ;)
- AnimalMuppet 13y agoHeh. My mother did in fact program in binary (well, octal), back in the 1950s. Even assembly is a "high level" language from that perspective.
- crpatino 13y agoManual memory management, mostly. Also, since C is a simpler language, its building blocks map more closely with what actually happens on hardware level (or they used to... back in the 1970's). Then, there's the fact that you do not have direct access to native OS primitives from Java (i.e. system call vs stdlib function), but it has to do more with the run-time environment than the language itself.
- Toenex 13y agoThe Java language is designed to be compiled to a Java Virtual Machine (JVM) which is a software implementation of a computer that doesn't exist (easy there existential freaks, I'm trying to keep this brief). The VM abstracts away the hardware differences between platforms, in theory allowing the Java language greater freedoms. Simple things like endian-ness are no longer a language issue as the VM says all machines are big endian. Compare this to C where the code is compiled to a native format that is very much tied to the hardware/OS platform.
- kyllo 13y agoPython (as most commonly implemented) is also compiled to bytecode that gets executed by a virtual machine. So it's at the same "level" as Java, really.
- kyllo 13y agoJava and Python are on the same level in relation to the hardware. They both get compiled to bytecode instructions that get executed by a virtual machine (basically a software program that is pretending to be a processor). The source code for that virtual machine is written in C or C++. In order to execute Java code or Python code, the machine must have the VM installed. But it doesn't matter what type of processor you are running the code on, just as long as it has the VM installed. A C/C++ compiler takes your source code and then compiles & assembles it to binary machine instructions that are executed directly by the processor. It is not necessary to have a C/C++ compiler installed on a machine in order to execute that binary. But the code must have been compiled to the machine language that type of chip understands. That's why you can't take a program that was compiled for an Intel chip and then go run it on an ARM chip. The different chip won't understand the instructions. So you have to compile the C source separately for each type of target chip. That's why C is considered more low-level than Java and Python. The output of the compiler is executed directly by your processor hardware, instead of by a VM.
- pjmlp 13y ago> The output of the compiler is executed directly by your processor hardware, instead of by a VM. You mean like RoboVM, Aonix Perc and Excelsior JET? Just to name three possible native code compilers for Java.
- kyllo 13y agoYeah, and there are also C/C++ compilers that target JVM bytecode. I am aware of the difference between a language and an implementation.
- pjmlp 13y agoThat is not what I could infer from your statement.
- kyllo 13y agoThat's because I was responding at a level of detail appropriate for the parent comment: I thought Java was on a much lower level than Python. Why is C more low-level? At that level of understanding, I think it is just fine to assume that Java means Oracle JVM, Python means CPython, and C/C++ means gcc (or your choice of C-to-native compiler). Yes there are many alternative implementations of these languages, but for the most part those are pretty obscure and a beginner does not need to know or care about them just yet.