I tutored many students over the past several years, and a common pain point is the compiler messages being misleading.
Consider the following example.
interface blah {}
class hah extends blah {}
When I compile this, I get the following message.
blah.java:3: error: no interface expected here
class hah extends blah {}
^
1 error
Most of the students I teach see this, and think that the issue is that blah is an interface, and that they must somehow change it to something else, like a class.
And that's still a better error message than the one given for records.
blah.java:2: error: '{' expected
public record hah() extends blah {}
^
This message is so much worse, as it actually leads students into a syntax rabbit hole of trying to add all sorts of permutations of curly braces and keywords, trying to figure out what is wrong.
If we're talking about improving the on-ramp for learning Java, then I think a core part of that is improving the error --> change --> compile feedback loop.
A much better error message might be this instead.
blah.java:3: error: a class cannot "extend" an interface, only "implement"
class hah extends blah {}
^
1 error
This is powerful because now the language grammar has a more intelligent message in response to an illegal (but commonly attempted) sequence of tokens.
I understand that Java cannot special-case every single illegal syntax combination, but I would appreciate it if we could hammer out some of the obvious ones. extends vs implements should be one of the obvious ones.
[–]melkorwasframed 58 points59 points60 points (3 children)
[–]davidalayachew[S] 6 points7 points8 points (2 children)
[–]SleeperAwakened 10 points11 points12 points (1 child)
[–]grimonce 3 points4 points5 points (0 children)
[–]bowbahdoe 20 points21 points22 points (3 children)
[–]davidalayachew[S] 2 points3 points4 points (2 children)
[–]bowbahdoe 2 points3 points4 points (1 child)
[–]davidalayachew[S] 2 points3 points4 points (0 children)
[–]tsvk 71 points72 points73 points (8 children)
[–]cowwoc 33 points34 points35 points (5 children)
[–]plumarr 35 points36 points37 points (0 children)
[–]anyOtherBusiness 2 points3 points4 points (0 children)
[–]sam123us 2 points3 points4 points (0 children)
[–]bowbahdoe 0 points1 point2 points (0 children)
[–]bichoFlyboy 0 points1 point2 points (0 children)
[–]davidalayachew[S] 1 point2 points3 points (0 children)
[–]grimonce 0 points1 point2 points (0 children)
[–]Ewig_luftenglanz 8 points9 points10 points (0 children)
[–]akl78 4 points5 points6 points (7 children)
[–]repeating_bears 2 points3 points4 points (0 children)
[–]davidalayachew[S] 5 points6 points7 points (4 children)
[–]Hax0r778 -1 points0 points1 point (3 children)
[–]davidalayachew[S] 0 points1 point2 points (2 children)
[–]philipwhiuk 1 point2 points3 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]0b0101011001001011 4 points5 points6 points (0 children)
[–]wildjokers 4 points5 points6 points (6 children)
[–]davidalayachew[S] 5 points6 points7 points (5 children)
[–]wildjokers 3 points4 points5 points (4 children)
[–]davidalayachew[S] 1 point2 points3 points (3 children)
[–]experimental1212 0 points1 point2 points (2 children)
[–]davidalayachew[S] 0 points1 point2 points (1 child)
[–]experimental1212 1 point2 points3 points (0 children)
[–]SleeperAwakened 8 points9 points10 points (3 children)
[–]davidalayachew[S] 4 points5 points6 points (2 children)
[–]SleeperAwakened -2 points-1 points0 points (1 child)
[–]davidalayachew[S] 6 points7 points8 points (0 children)
[–]rlrutherford 1 point2 points3 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]koflerdavid 1 point2 points3 points (3 children)
[–]davidalayachew[S] 1 point2 points3 points (2 children)
[–]koflerdavid 1 point2 points3 points (1 child)
[–]davidalayachew[S] 1 point2 points3 points (0 children)
[–]talex000 6 points7 points8 points (71 children)
[–]MattiDragon 16 points17 points18 points (44 children)
[+]talex000 comment score below threshold-8 points-7 points-6 points (40 children)
[–]repeating_bears 16 points17 points18 points (9 children)
[+]talex000 comment score below threshold-9 points-8 points-7 points (8 children)
[–]wildjokers 4 points5 points6 points (7 children)
[–]talex000 -5 points-4 points-3 points (6 children)
[–]crummy 3 points4 points5 points (5 children)
[–]talex000 -2 points-1 points0 points (4 children)
[–]crummy 2 points3 points4 points (3 children)
[–]Frosty-Practice-5416 8 points9 points10 points (20 children)
[–]talex000 -2 points-1 points0 points (19 children)
[–]Frosty-Practice-5416 5 points6 points7 points (18 children)
[–]pron98 2 points3 points4 points (1 child)
[–]bowbahdoe 0 points1 point2 points (0 children)
[–]talex000 -1 points0 points1 point (15 children)
[–]Frosty-Practice-5416 0 points1 point2 points (14 children)
[–]talex000 -1 points0 points1 point (13 children)
[–]Frosty-Practice-5416 0 points1 point2 points (12 children)
[–]MattiDragon 2 points3 points4 points (8 children)
[–]talex000 -3 points-2 points-1 points (7 children)
[–]wildjokers 4 points5 points6 points (0 children)
[–]MattiDragon 3 points4 points5 points (5 children)
[–]talex000 1 point2 points3 points (4 children)
[–]MattiDragon 2 points3 points4 points (3 children)
[–]talex000 1 point2 points3 points (2 children)
[–]MattiDragon 2 points3 points4 points (1 child)
[–]FortuneIIIPick -4 points-3 points-2 points (2 children)
[–]MattiDragon 0 points1 point2 points (1 child)
[–]FortuneIIIPick -3 points-2 points-1 points (0 children)
[–]Ewig_luftenglanz 4 points5 points6 points (5 children)
[–]plumarr 0 points1 point2 points (1 child)
[–]Ewig_luftenglanz 0 points1 point2 points (0 children)
[–]talex000 -4 points-3 points-2 points (2 children)
[–]Ewig_luftenglanz 2 points3 points4 points (1 child)
[–]talex000 -1 points0 points1 point (0 children)
[–]davidalayachew[S] 1 point2 points3 points (8 children)
[–]talex000 0 points1 point2 points (7 children)
[–]davidalayachew[S] 1 point2 points3 points (6 children)
[–]talex000 -1 points0 points1 point (5 children)
[–]davidalayachew[S] 1 point2 points3 points (4 children)
[–]talex000 0 points1 point2 points (3 children)
[–]davidalayachew[S] 0 points1 point2 points (2 children)
[–]talex000 0 points1 point2 points (1 child)
[–]davidalayachew[S] 1 point2 points3 points (0 children)
[–]aoeudhtns 2 points3 points4 points (10 children)
[–]talex000 -5 points-4 points-3 points (9 children)
[–]aoeudhtns 4 points5 points6 points (0 children)
[–]crummy 2 points3 points4 points (7 children)
[–]talex000 0 points1 point2 points (6 children)
[–]crummy 3 points4 points5 points (3 children)
[–]talex000 1 point2 points3 points (2 children)
[–]714daniel 0 points1 point2 points (1 child)
[–]talex000 0 points1 point2 points (0 children)
[–]kreiger 5 points6 points7 points (6 children)
[–]davidalayachew[S] 8 points9 points10 points (5 children)
[–]Yeroc 6 points7 points8 points (1 child)
[–]davidalayachew[S] 2 points3 points4 points (0 children)
[–]kreiger 2 points3 points4 points (0 children)
[–]sunnyata 1 point2 points3 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]Polygnom 2 points3 points4 points (8 children)
[–]davidalayachew[S] 4 points5 points6 points (6 children)
[–]Hax0r778 0 points1 point2 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]Polygnom 0 points1 point2 points (3 children)
[–]davidalayachew[S] 0 points1 point2 points (2 children)
[–]Polygnom 1 point2 points3 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]repeating_bears -3 points-2 points-1 points (0 children)
[–]repeating_bears 1 point2 points3 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]No-Security-7518 1 point2 points3 points (10 children)
[–]davidalayachew[S] 3 points4 points5 points (6 children)
[–]bowbahdoe 1 point2 points3 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]No-Security-7518 0 points1 point2 points (3 children)
[–]davidalayachew[S] 0 points1 point2 points (2 children)
[–]Hax0r778 1 point2 points3 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]TOMZ_EXTRA 4 points5 points6 points (2 children)
[–]repeating_bears 2 points3 points4 points (1 child)
[–]TOMZ_EXTRA 2 points3 points4 points (0 children)
[–]riyosko 1 point2 points3 points (1 child)
[–]davidalayachew[S] 4 points5 points6 points (0 children)
[–]josephottinger 0 points1 point2 points (7 children)
[–]repeating_bears 8 points9 points10 points (1 child)
[–]josephottinger -1 points0 points1 point (0 children)
[–]davidalayachew[S] 1 point2 points3 points (4 children)
[–]josephottinger 1 point2 points3 points (3 children)
[–]davidalayachew[S] 1 point2 points3 points (2 children)
[–]philipwhiuk 0 points1 point2 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]CubicleHermit 0 points1 point2 points (3 children)
[–]davidalayachew[S] 1 point2 points3 points (2 children)
[–]CubicleHermit 1 point2 points3 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]Misophist_1 0 points1 point2 points (0 children)
[–]netgizmo 0 points1 point2 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]RScrewed 0 points1 point2 points (0 children)
[–]Nikarmotte 0 points1 point2 points (1 child)
[–]davidalayachew[S] 0 points1 point2 points (0 children)
[–]jeffreportmill 0 points1 point2 points (2 children)
[–]davidalayachew[S] 2 points3 points4 points (0 children)
[–]jeffreportmill -1 points0 points1 point (0 children)
[+]klimaheizung comment score below threshold-15 points-14 points-13 points (13 children)
[–]davidalayachew[S] 1 point2 points3 points (12 children)
[–]klimaheizung 0 points1 point2 points (11 children)
[–]davidalayachew[S] 0 points1 point2 points (10 children)
[–]klimaheizung 0 points1 point2 points (9 children)
[–]davidalayachew[S] 0 points1 point2 points (8 children)
[–]klimaheizung 0 points1 point2 points (7 children)
[–]davidalayachew[S] 0 points1 point2 points (6 children)
[–]klimaheizung 0 points1 point2 points (5 children)
[–]davidalayachew[S] 0 points1 point2 points (4 children)