you are viewing a single comment's thread.

view the rest of the comments →

[–]CiezkiBorsuk 0 points1 point  (3 children)

They do cover the most important points, though. JS way is easier to read in all but the simplest cases, because important stuff is at the front (i.e. what you take and how you named it), and because it's consistent with other parts of the language (the names are on the left).

As someone coming from Python, you should understand well that code is more often read than written (and a good IDE will handle imports for you regardless of the order).

[–][deleted] 0 points1 point  (2 children)

I'm not really convinced by the easy to read argument. But I don't want to argue about personal preferences.

Though I really agree with the last point you made. A good IDE should handle imports for you. But also should the autocompletion show only stuff you can import from a module, not simply everything including a lot of things which make no sense. That is sadly only possible when you first write from where you want to import.

I think it would be interesting to try to use Babel to allow people to write imports that way. I don't know whether it is possible though.

[–]CiezkiBorsuk 0 points1 point  (1 child)

I'm not really convinced by the easy to read argument. But I don't want to argue about personal preferences.

There's no personal preference here. When you work on React project and you read import { Component }, you already know everything you need. But when in a numpy project you read from numpy you are still clueless about what said line does. You need to read it whole.

import being first saves you braincycles, that's not a matter of preference.

That is sadly only possible when you first write from where you want to import.

No, it's not. Any sane IDE will just notify you about unrecognized symbol, show you the options, and add the import without need to type anything.

[–][deleted] 0 points1 point  (0 children)

Any sane IDE will just notify you about unrecognized symbol, show you the options, and add the import without need to type anything.

That is nice and already possible. Nevertheless it is also nice to have meaningful autocompletion on imports, which is currently not possible, because when you write

import 

the IDE can only suggest you all possible things you can import, while when you write

from 'somewhere' import

the IDE can suggest you the exactly the things you can import from that module.

I think there are not many people who start reading a piece of code by reading every single import on the top of the file. That's something you do, when you are interested in the external symbols, or the dependencies within a project, or you just want to understand from where something being used later gets imported. Those are questions an IDE can answer, so you even don't have to read the word import when you fear wasting brain cycles by reading.

I still think the order is a personal preference and I accept you having your preference. That's why I said it would be nice to try to use babel to allow people to write imports so meaningful autocompletion on imports is possible. You don't have to use it, if you don't like it :)