There are a few I’m aware of:
- Rust-style
use(multiple imports per statement, renaming items usingas) - Java-style
import(single import per statement, no renaming (afaik)) - Zig-style
let xlib =(imports as assignments) - C-style
(no importing, just pastes the code of the named file)
I like Rust’s style. It’s simple and it does everything you need. As much as I love Elixir, which I write at my day job, it has alias, import, use, and require, which each import things different, and it can get a bit confusing.
In order or preference, out of the ones I’m familiar with:
- Java. Very simple. Diff friendly. Import names match the filesystem.
- Rust. Also good - you can do it diff friendly though nobody does. Slightly confusing distinction between module hierarchy and filesystem.
- Python. Pretty bad. Conflates third party packages with local files, almost nobody actually understands relative imports, even more confusing distinction between module hierarchy and filesystem. Module imports can have side effects. Unnecessarily different syntax between
import...andfrom .... import.... - C/C++. Obviously this is the worst.
Well, I have been using python for a long time and was ready to disagree with you but damn, it really do be like that.
I think C# handles this pretty well. You include namespaces with whatever granularity you need, down to a single class (or interface or whatever) and can alias them.
using MyProject.Domian.Entities; //the whole module using Routes = MyProject.Api.Contract.Routes.Http; //an aliased single classI bet Java had this too, C# us still mostly Java: Microsoft Edition.
c# is delphi with some realized mfc lofty goals.
first, microsoft liked delphi and hired the guy who created delphi to create c#
second if you read an mfc book from the 90s that talks about history and goals, 6ou can see they wanted the .net framework
Java doesnt have aliases. You can do glob imports of a particular package (IE all the classes) and you can statically glob import all the static functions in a class but uh yeah that’s it
There is a hidden detail that’s worth mentioning about C and C++ style includes: Because compilation and linking are two separate steps, the definitions (included from header files) and the compiled object code that implements those definitions can be kept strictly separate such that you could have two different implementations of the same definitions that are switched in at linker time, for example as a way to provide mock implementations of a specific compilation unit for a unit test, by modifying which object file is passed to the linker.
In some languages this is harder to do as it would require some fiddling with the classpath (in Java for example) or designing with dependency injection in mind from the beginning (inversion of control).
I’m not saying it’s a killer feature, but it’s something worth noting nonetheless.
I like being able to import multiple things from a given package/module on the same line. Aliasing is also very useful.
I’m not educated enough to have an opinion that goes beyond what I like to type. I find C style to be the nicest.
Zig and Rust are good. Java is painful.
But the best for me is Clojure:
(require [my.module :refer [func1 func2]] [Some.lib :as lib])I don’t know, but my least favourite has to be Python with its
fromsyntax.e.g.,
# fine import os.path # what?? from os import pathI suspect most developers have a “favorite language” and are just going to respond with “the import style my favorite language uses”.
Go’s:
import "foo" // foo.X import b "bar" // b.X import _ "baz" // X // or, the same but less verbose: import ( "foo" b "bar" _ "baz" )It’s clean, clear, has renaming, allows multiple or One Big import statement, and þere’s still only one keyword.



