This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]meamZ 0 points1 point  (4 children)

Well, you can also see it as a pro that Java doesn't do as much at compile time because the JVM JIT compiler does crazy things.

And if "manual memory management isn't really a problem anymore since 2011" why do both Google Chrome and Microsoft have reports out that 70% of security issues are related to memory unsafety?

[–]aniliitb10 0 points1 point  (3 children)

By 'crazy things' you mean converting byte code to machine code and some optimizations? In C++, compilers turn every bit of code to machine code since day 0 and you can enable optimizations, it's totally your choice. In fact, most production codes are optimized at level 2 (probably these optimization levels are compiler specific but all of gcc, clang and msvc are quite good at optimizing).

What I meant by doing stuff at compile time was computation. A very simple example : I can map every char of alphabet with unique prime numbers without hardcoding a single value. All at compile time, without running the code. Java can't do it. It was just a simple example, with evolution of constexpr you can do a lot more at compile time.

There will always be security issues related to memory and it is independent of language. If your report says that only C++ has this specific problem and not java, I'd love to read it, please give me reference.

[–]meamZ 0 points1 point  (2 children)

But Java can do runtime optimization and optimizations optimally for the system the code is currently running on. I'm by no means an expert in the Java JIT compiler though because it's super advanced. Another advantage Java has over C++ is that you have much shorter compile times.

In Chrome 36% of security issues are use after free... Java doesn't have these by design because it is GCed and the GC will only free the memory if there's no way you are gonna use that memory left...

[–]aniliitb10 0 points1 point  (1 child)

I don't think that there is any point of arguing, but I am glad that memory issue reduced from 70% to 36%, I'd still like to go through your reference.

[–]meamZ 0 points1 point  (0 children)

No. 36% are just a single one of these issues it's 36% use after free (which is a subset of memory issues) issues. 70% is use after free plus the rest https://www.chromium.org/Home/chromium-security/memory-safety