[Development] Using semicolons in JS (QML)

Mitch Curtis mitch.curtis at qt.io
Sun Oct 2 20:04:29 CEST 2016


> -----Original Message-----
> From: Development [mailto:development-bounces+mitch.curtis=qt.io at qt-
> project.org] On Behalf Of Robin Burchell
> Sent: Friday, 30 September 2016 11:57 PM
> To: development at qt-project.org
> Subject: Re: [Development] Using semicolons in JS (QML)
> 
> 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 with it.

I know that you said "for yourself", but since you are essentially taking the same stance with Qt code, wouldn't it be better to consider the points put forth so far and make a decision, so that it's one less opportunity for inconsistency? Then you can justify the 20 minutes you chose to spend researching the subject (although, if you had to research it, you probably learned something new anyway, so I wouldn't say it was wasted time). :D

> 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.

QML auto tests are an example of where this would actually have a real-word gain. Some files use them, some don't, and if you're used to always using them, but prefer to follow what has already been done in a particular file for consistency, it means having to make a conscious effort to not type them (and sometimes remove the ones you typed out of habit). If we could agree on using semicolons everywhere, it would become habit, and I wouldn't waste that small amount of mental energy on it. qtdeclarative.git has a fair few QML auto tests, along with qtquickcontrols.git/qtquickcontrols2.git. It does add up.

> I think that is why Shawn replied the way he did.
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list