[Development] Using semicolons in JS (QML)

Viktor Engelmann viktor.engelmann at qt.io
Tue Oct 4 15:51:29 CEST 2016


Am 30.09.2016 um 17:43 schrieb Shawn Rutledge:
> Back in Nokia times it was said that we shouldn't use semicolons,
> because it would speed up the parsing [...] 

As someone who has written countless parsers, I *highly* doubt that this
is actually true. Indenting with tabs was also believed to be *much*
slower than indenting with spaces (which makes absolutely no sense), and
that measurement result turned out to be caused by a bug in firebird. I
bet this is also just an urban legend. Someone probably thought "hey -
one less character to read - must be faster to load", but as André
pointed out, the error recovery will most likely cost more than what you
save. Unless if the behavior is baked into the LR(1) state-graph maybe.

Also I don't think it is good style to write code that doesn't conform
to the actual language, just because *most* parsers correctly *guess*
what you meant *most* of the time (except in those pathological
cases...). I think that you should *always* tell parsers *precisely*
what you mean and don't rely on it's guessing ability. For reference:
The Mariner 1 crash (which cost $80 million) was supposedly caused by an
error that could have been caught by static analysis at compile time,
but was just "guessed away" wrongly.

Anyhow, I believe that we have spent more time on this debate than will
ever be saved by omitting semicolons.

Viktor

-- 


Viktor Engelmann
Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
Viktor.Engelmann at qt.io
+49 151 26784521
http://qt.io

Geschäftsführer: Mika Pälsi, Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B
<http://qt.io>
<http://www.facebook.com/Qt> 	<http://www.twitter.com/qtproject>
<https://www.linkedin.com/company/the-qt-company/>
<https://plus.google.com/104580575722059274792>
<https://www.youtube.com/QtStudios>

Qt World Summit 2016 <http://qtworldsummit.com/>
Qt World Summit 2016 | Pier 27, San Francisco, CA
Experience Exponential Potential on October 18-20
www.qtworldsummit.com <http://www.qtworldsummit.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_logo_with_text_green_rgb_400x141.png
Type: image/png
Size: 16849 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_facebook.png
Type: image/png
Size: 1407 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_twitter.png
Type: image/png
Size: 1778 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_linkedin.png
Type: image/png
Size: 1532 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_googleplus.png
Type: image/png
Size: 1957 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_youtube.png
Type: image/png
Size: 1610 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qtworldsummit2016_banner.jpg
Type: image/jpeg
Size: 35183 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: viktor_engelmann.vcf
Type: text/x-vcard
Size: 271 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20161004/0a7e873c/attachment.vcf>


More information about the Development mailing list