What is a compiler? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is a compiler?

I started coding about 1 months ago but I still dont know what a compiler is. I know you dont need a compiler for Python but you do need it for Java, JavaScript,... Thx in advance

21st Jan 2017, 3:45 PM
Seighin V.H.
Seighin V.H. - avatar
3 Answers
+ 2
So first you don't need a compiler for Javascript. There is a difference in what are called "compiled" and "interpreted" languages. A compiler is essentially a program that converts code in one language to another. So in the case of Java, you compile it to Java-byte code. Now Java is interesting because it is actually both compiled and interpreted. Once you compile to Java-byte code, you then deploy it somewhere that also has a Java Virtual Machine (JVM) which is an interpreter. An interpreter is sort of like a compiler, but instead of compiling (aka translating) the whole thing at once, it usually translates it as it runs it (as needed, just in time). In the case of the JVM, it translates it to code that can run on the machine's hardware. There's a lot of computer science topics involved here beyond the scope of your question. But know that some languages are generally considered interpreted (eg Javascript and Python) because they are not compiled first while others (eg Java) are generally considered compiled because they make use of a program that translates it all at once.
21st Jan 2017, 3:56 PM
Lauren
+ 1
A compiler translates your human readable code in a machine language. The whole process takes place BEFORE your application is starting. There is another technique that will translate your code while its running, which is called interpreter. Java for example uses a compiler AND interpreter
21st Jan 2017, 3:52 PM
qobus
0
So a interpreter translates while it is runnunig and a compiler translates it before it starts. Thx
21st Jan 2017, 3:57 PM
Seighin V.H.
Seighin V.H. - avatar