开发者

Is it required to have deep knowledge of lower levels to write efficient Java code? [closed]

开发者 https://www.devze.com 2023-02-09 05:03 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_开发百科 Closed 12 years ago.

All is in the title:

Is it required to have deep knowledge of lower levels to write efficient Java code ?


Not at all!

Java abstracts away pretty much all of the underlying levels, unlike C where you have direct access to hardware and memory or Assembly, where you're actually coding in terms of the actual registers and buffers.

To write efficient Java code, you just need to ensure the efficiency of whatever algorithms you're using: if you have an inefficient algorithm it will stay inefficient no matter what you program it in. Additionally, you have to make sure you're using the correct type of data structures. That's one reason why people code in assembly: it allows you to create some very flexible data structures. But for mainstream purposes, the classes found in java.util will be more than sufficient.

In modern machines, any cost caused by using a virtual machine is negligible, so again java doesn't have much of a disadvantage compared to assembly or c.

You can't mix Java and Assembly code anyway, so knowledge of the language wouldn't help, but what would help is knowledge of efficient algorithms (sorting, etc.) and data structures (linkedlists, trees, etc.)

0

精彩评论

暂无评论...
验证码 换一张
取 消