Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Similar point to this is wildcard imports in Java.

Previously I prefer import bla.* because it's shorter and neater, but as the code grows, more naming conflict and more difficult to find where's where, I prefer explicit import. I can configure my IDE to collapse the import lines anyway.



The big problem doesn't exist in Java, as it's being compiled, and all classes used are fully qualified in the bytecode.

In source-based languages, if a library adds some class, you'll get into some trouble. In Java, this will also happen at source level, but results in not being able to compile.


Yeah, most code styles in JVM code bases I've worked in (Kotlin and Scala included) prohibit wildcard imports, reviewing PRs is a lot harder when you're playing "Where did the function/class come from".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: