Skip to content

Commit 7b480c1

Browse files
authored
checked for conciseness and clarity
1 parent 8a6c38e commit 7b480c1

File tree

1 file changed

+20
-29
lines changed

1 file changed

+20
-29
lines changed

posts/2021/12/error-message-style-guides.txt

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,27 @@ Error Message Style Guides of Various Languages
1414

1515
PyPy has been trying to produce good `SyntaxErrors`_ and `other`_ `errors`_ for
1616
a long time, and thankfully CPython has made an enormous push to `improve its
17-
SyntaxErrors in the last releases`_. These improvements are great but the process
18-
feels somewhat arbitrary sometimes. To see what other languages are doing I
19-
asked people on Twitter whether they know of error message style guides for
20-
other programming languages:
17+
SyntaxErrors in the last releases`_. These improvements are great, but the process
18+
feels somewhat arbitrary sometimes. To see what other languages are doing, I
19+
`asked people on Twitter`_ whether they know of error message style guides for
20+
other programming languages.
2121

2222
.. _`SyntaxErrors`: https://www.pypy.org/posts/2018/04/improving-syntaxerror-in-pypy-5733639208090522433.html
2323
.. _`other`: https://twitter.com/cfbolz/status/783313503230844929/photo/1
2424
.. _`errors`: https://twitter.com/pypyproject/status/999930324481081344
2525
.. _`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
2627

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>&mdash; 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
3229
end of the post), thank you everybody! All those sources are very interesting
3330
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
3532
particularly interesting.
3633

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

4439
Almost all guides stress the need for plain and simple English, as well as
4540
conciseness and clarity [Flix, Racket, Rust, Flow]. Flow suggests to put coding
@@ -61,28 +56,27 @@ found instead.'
6156

6257
The Rust guides says to avoid "Did you mean?" and questions in general, and
6358
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
6661
suggestions altogether because "Students will follow well‐meaning‐but‐wrong
6762
advice uncritically, if only because they have no reason to doubt the
6863
authoritative voice of the tool."
6964

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

7367
The Clang, Flow and Rust guides point out the importance of using precise
7468
source code spans to point to errors, which is especially important if the
7569
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
7771
the error [Flow].
7872

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

84-
Sources:
76+
.. _`full list`:
8577

78+
Sources
79+
-------
8680
* Rust: https://rustc-dev-guide.rust-lang.org/diagnostics.html
8781

8882
* Clang: https://clang.llvm.org/diagnostics.html
@@ -100,6 +94,3 @@ Sources:
10094
* Elm's error message catalog: https://github.com/elm/error-message-catalog
10195

10296
* Reason: https://reasonml.github.io/blog/2017/08/25/way-nicer-error-messages.html
103-
104-
105-

0 commit comments

Comments
 (0)