You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.. _`improve its SyntaxErrors in the last releases`: https://docs.python.org/3/whatsnew/3.10.html#better-error-messages
26
+
.. _`asked people on Twitter`: https://twitter.com/cfbolz/status/1466033151315173384
26
27
27
-
.. raw:: html
28
-
29
-
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Is there any programming language that has a style guide for its error messages? <a href="https://twitter.com/ShriramKMurthi?ref_src=twsrc%5Etfw">@ShriramKMurthi</a>, do I remember correctly that Pyret has one?</p>— Carl Friedrich Bolz-Tereick (@cfbolz) <a href="https://twitter.com/cfbolz/status/1466033151315173384?ref_src=twsrc%5Etfw">December 1, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
30
-
31
-
Wonderfully, people answered me with lots of helpful links (full list at the
28
+
Wonderfully, people answered me with lots of helpful links (`full list`_ at the
32
29
end of the post), thank you everybody! All those sources are very interesting
33
30
and contain many great points, I recommend reading them directly! In the
34
-
following I'm, going to try to summarize some common themes or topics that I found
31
+
following, I'll try to summarize some common themes or topics that I found
35
32
particularly interesting.
36
33
37
-
Several guides point out a 80/20 rule: 80% of the time an error message is
38
-
read, the developers knows that message well and knows exactly what to do. For
39
-
this use case it's important that the message is short. On the other end of the
40
-
spectrum, 20% of the time a developer gets a message that they have never seen
41
-
before and are confused and so the message needs to contain enough information
42
-
to allow them to find out what is going on [Flix, Flow].
34
+
Several guides (such as Flix and Flow) point out a 80/20 rule: 80% of the time an error message is
35
+
read, the developer knows that message well and knows exactly what to do. For
36
+
this use case it's important that the message is short. On the other hand, 20% of the time this same message will have to be understood by a developer who has never seen it before and is confused, and so the message needs to contain enough information
37
+
to allow them to find out what is going on.
43
38
44
39
Almost all guides stress the need for plain and simple English, as well as
45
40
conciseness and clarity [Flix, Racket, Rust, Flow]. Flow suggests to put coding
@@ -61,28 +56,27 @@ found instead.'
61
56
62
57
The Rust guides says to avoid "Did you mean?" and questions in general, and
63
58
wants the compiler to instead be explicit why something was suggested. The
64
-
example the Rust guide gives is: '"Compare "did you mean: Foo" vs. "there is a
65
-
struct with a similar name: Foo"."'. Racket goes further and forbids
59
+
example the Rust guide gives is: 'Compare "did you mean: Foo" vs. "there is a
60
+
struct with a similar name: Foo".' Racket goes further and forbids
66
61
suggestions altogether because "Students will follow well‐meaning‐but‐wrong
67
62
advice uncritically, if only because they have no reason to doubt the
68
63
authoritative voice of the tool."
69
64
70
-
The Rust guide suggests to put all identifiers into backticks, the Flow goes
71
-
further and uses Markdown for the error message.
65
+
The Rust guide suggests to put all identifiers into backticks, Flow formats the error messages using full Markdown.
72
66
73
67
The Clang, Flow and Rust guides point out the importance of using precise
74
68
source code spans to point to errors, which is especially important if the
75
69
compiler information is used in the context of an IDE to show a red squiggly
76
-
underline. The spans should be as small as possible to point out the source of
70
+
underline or some other highlighting. The spans should be as small as possible to point out the source of
77
71
the error [Flow].
78
72
79
-
I don't really have a conclusion! I wonder whether it would makes sense for
80
-
Python to adopt a (probably minimal, to get started) subset of some of these
81
-
ideas as guidelines for its own errors.
82
-
73
+
I am quite impressed how advanced and well-thought out the approaches are. I wonder whether it would makes sense for
74
+
Python to adopt a (probably minimal, to get started) subset of these ideas as guidelines for its own errors.
0 commit comments