Professional Documents
Culture Documents
Java Vs Python
Java Vs Python
In java everything breaks down into objects. Each object has certain capability and
objects are reusable. While C is a procedural program ie. It will start
at the top and work its way down in a linear fashion. Although the code might re-
route to different points in the program, it’s still following a specified
sequence
Java is a semi interpreted language using the java virtual machine while C is a
compiled language.
Whenever you write a program—no matter what language, high or low level—it’s always
interpreted in some way by the processor. In other words, it has more
steps of translation it has to go through to run your program. An interpreted
program is like having a native speaker translate a text for you as you read it,
whereas a compiled program is like having the full text sent to you already
translated. The program has to be built by the compiler before they can run.
This means an extra step every time you make a change In your program. Interpreted
languages can run after any change without that extra step. Simply change
what you want and run it.
C vs Java: Memory
One big task that C programmers have to manage themselves is memory management.
When manipulating data in a C program, the developer needs to use calls like
‘malloc’ (memory allocation) and ‘free’ to outline whatever memory their program
will need to use. Java uses something called a garbage collector to delete
any objects that are no longer used. In other words, Java manages memory for you.
C vs Java: Portability
Portability of C is possible but with careful discipline while in case of java its
very easy.
C vs Java: Syntax
C: #include<stdio.h>
int main(void) {
printf("Hello\n");
return 0;
}
Java: public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello");
}
}
De-allocating memory:-
C: free
Java: Automatic garbage collector
C: #include <stdio.h>
Java: import java.io.File;
declaring constants
C: const and #define
Java: final
Unlike Java where the output of the program can show on any screen
(external or original), file etc. , program in C can only be
shown on the original screen using printf.