.net - Why Java is secure compared with other programming languages? - Stack Overflow
java or python?
Which language is best for cyber security?
What does Java do better than Python?
Videos
There are many reasons why Java is a safe language, and it's definitely safer than some languages, but I think it's a stretch to say that it's safer than all other languages.
Java has a variety of safety features in place:
Automatic null-checking of references, bounds-checking of arrays, verification of casts, etc. to prevent the program from making type errors. Compare this to C or C++, where these same errors (with a few exceptions) cause undefined behavior.
Verification of bytecode prior to execution. This makes it impossible for the program to jump to an undefined instruction, or to try to perform an operation on a nonexistent object, or to make a type error at the instruction level, etc. Compare this to C or assembly, where the program can jump to bad instructions, or try reading nonexistent parameters to functions (think
va_args), etc.)Runtime security checks when loading in new code. The use of
SecurityManagerandClassLoadermake it easy for the Java runtime to prevent arbitrary code from executing on the computer by mediating access to system resources and preventing the program from loading or generating arbitrary code at runtime. Compare this to C or C++, which can read and write arbitrary values, issue arbitrary system calls, generate and execute arbitrary code, etc.Library-level safety of certain features. For example,
Stringis immutable andfinal, so a function that receives aStringcan verify the string and not have to worry about another thread changing its value.
This isn't a complete list of Java's safety features, but it should give you a sense of some of the design considerations in Java that are not present in other languages.
Hope this helps!
You mention you read some where but can you please re-read it because I guess when it was written the author would be comparing the JAVA with C++ / Fortran / C etc.
Also there is an old post you can read about the testability of security in http://www.veracode.com/blog/2010/06/which-tastes-better-for-security-java-or-net/
you can see both are same almost....
is there a good reason to have java as your first language over languages like python or js?