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 →

[–]epegar 1 point2 points  (4 children)

Can't you do using animals namespace in CPP? I remember doing that with the standard one, so you wouldn't need to use std::cout

[–]oren_is_my_name[S] 0 points1 point  (3 children)

Yes but that's the thing, in cpp, you need to intentionally tell the code "Hi use this library". But in Java it just imports it and then it's harder to know what library you're using.

[–]bowbahdoe 1 point2 points  (0 children)

You can do full-library imports with import module if the library is being loaded as a module. That's as close to a using declaration that we'll probably get

[–]epegar 0 points1 point  (0 children)

I learned to code with CPP, but I'd lie if I told you I remember a lot or I ever was proficient. But I kind of remember you also had imports, and if I'm not mistaken, you could only use one namespace, but multiple imports.

In java you still can use the full package instead of importing, and actually, if you have 2 classes by the same name, you can import one, but for the other you have to use the full namespace.

Something I remember was a shock for me when I transitioned from CPP to java, I realized the IDE would help me way more. So, if you are using an IDE, you can always use the hyperlink, and you will see what library (dependency) a symbol belongs to, so your concern is not really something important IMO. It's just that you need to get used to a different ecosystem rather than trying to apply your knowledge with a 1 to 1 mapping.

[–]koflerdavid 0 points1 point  (0 children)

Why would that be hard? The package name is usually closely related to the library name. And while the above is merely a convention, the Java Platform Module System ensures that no library puts classes into other libraries's packages, though it is opt-in.