[Development] Using semicolons in JS (QML)
robin+qt at viroteck.net
Fri Sep 30 23:57:02 CEST 2016
On Fri, Sep 30, 2016, at 11:00 PM, Kai Koehne wrote:
> Interesting. Indeed, I wouldn't have thought it makes any measurable
> difference. IIRC we had a qml mimizer once, I guess this is still around?
tools/qmlmin in qtdeclarative
> It's certainly not that important to me that I will spend a day on
> writing a git hook that then nobody will use ;) But a lot of programmers
> (including me) tend to care about code style consistency. So I was making
> a suggestion that costs us nothing, but leads to a sllightly more
> consistent documentation and examples in then end. In the same way as I
> couldn't care less whether to use tabs or spaces, or what the right
> indentation level is, as long as we stick to one.
> (And yeah, I also enjoy bikeshedding sometimes, be it at the coffee
> machine or on a mailing list, even if not 'all Qt in bugs are fixed". And
> honestly speaking I do not see an issue with this.)
The problem is that these kinds of discussions do actually have a cost.
They take time and energy to read and digest, and time to reply to (yes,
it's voluntary, but occasionally something useful comes out of it,
although usually not in any way related to the original topic - I'd
count the above mention of qmlmin in this category for instance).
The whole principle of bikeshedding as I'd understand it is that it's
easy (and subjectively - somewhat fun) to do, but on the other hand
doesn't really get all that much useful accomplished. And it may not be
toxic every once in a while, but when you do it often enough, the noise
starts to drown out the signal, and you can end up killing off a medium
for any sort of reasonable conversations. It's a fine line to walk.
As an idea of cost: aside from reading this thread, I spent something
like 20 minutes mulling over this topic (and reading around on the
internet for resources and opinions) while writing this reply for
instance, time that I didn't even really realise I had spent until I was
about to click "send" on this mail. Multiply that by every participant,
and by every "low signal" thread, and you end up with potentially
gargantuan amounts of time being spent on more or less irrelevant
details, even if it is fun to do.
To the topic at hand, I personally tend to omit semicolons unless they
are clearly needed either to reduce ambiguity or for reasons of e.g.
multiple statements on a single line (already something I prefer to
outright avoid, however). I choose this for aesthetics, much like the
"omit braces on single line if" rule (which is also, coincidentally,
somewhat controversial and ignored from time to time)
In the wider community (both QML and JS in general), this isn't a
unified topic I'd say. You can find numerous advice going both ways, and
I think it's fairly safe to say that there will always be dissenting
voices everywhere, no matter what you choose.
So for yourself, my advice would be: pick one that you like and stick
For Qt, while I would like to see one or the other picked and followed
for consistency's sake, I'm not sure it would be a useful investment of
your time to try to enforce a particular semicolon-style without tooling
enforcement, as it seems like yet another Sisyphean task that will - at
best - burn a lot of your time and energy and end up back in exactly the
same situation, all for an effort which in practice has little
real-world gain. I think that is why Shawn replied the way he did.
More information about the Development