In Le Ton Beau de Marot there's this section about...
# thinking-together
c
In Le Ton Beau de Marot there's this section about the revelatory nature of errors which I found fascinating. Apparently somebody accidentally said "Rosa only date shranks", instead of "Rosa only dated shrinks". That is, they applied to "make_past_tense()" function to "shrink" instead of "date"! Hofstadter mentions he has collected thousands of examples of errors like these (it's not clear if the "filing cabinet" he talks about is metaphorical or not). I think it might also be useful to collect programming errors in a similar way (maybe put on the wiki eventually). Patterns might start to emerge that are instructive to how people think about coding. These errors are quite precious because they become very rare once you have become fluent in the status quo. Most programming errors are of the type "failed to understand the full consequences of my code" or "failed to consider all possible inputs". These are the types of errors that pros make. I am more interested in the type of errors that beginners make, that might reveal friction between how they might naturally express themselves or understand, and how they are forced to by the language.
👍 1
❤️ 2
I have two examples from when I was learning to code. I learned to code in a language called DarkBASIC that is a BASIC for making games. I began by editing the examples that come with it. One of these is a 3D character that can be moved around with the arrow keys. The code used two helper functions which are specifically for a character walking on the x/z plane, rotating around the y-axis. The functions were NEWXVALUE() and NEWZVALUE() and were used like this;
Copy code
X# = NEWXVALUE(X#, A#, 1.5)
Which is equivalent to
X# = X# + cos(A#) * 1.5
I wanted to expand the example to include a second character controller by WASD. To do this I copypasted all the code, then went through and edited it. The second character I made to have the variables XX# and ZZ#. I could get it set up ok, because I understood the initialization lines like
Copy code
X# = 100
Z# = 100
I changed these to
Copy code
XX# = -100
ZZ# = -100
But when I came to edit
X# = NEWXVALUE(X#, A#, 1.5)
, I chaged it to
XX# = NEW*XX*VALUE(XX#, AA#, 1.5)
. That is, I had confused the 'X' inside the function name "NEWXVALUE" as equivalent to the 'X' in the variable name X#.
o
You will love some of the talks at the #PLHCISwimmer summer school. I will link once they put it up on YouTube. In particular Bjorn Hartman’s talk. He talks about how they scale tutoring and guidance. For example, say there is a grading system so you have a large number of student that submit code that should pass certain test cases and then they keep track of similar submissions and what transformations made them pass the tests and then use that to provide hints to people that are still stuck. There is a lot more but it’s basically how do you provide useful hints that will result in correct code
🍻 1
❤️ 2
c
The second example is that I didn't understand why a 2D nested for-loop had the closing tags 'backwards'. e.g instead of;
Copy code
FOR X# in 1 TO 10
FOR Y# in 1 TO 10

(do some stuff)

NEXT Y#
NEXT X#
I was writing;
Copy code
FOR X# in 1 TO 10
FOR Y# in 1 TO 10

(do some stuff)

NEXT X#  <---
NEXT Y#
which seemed much more natural to me. I just learnt to reverse them as a silly quirk of the language, it was only much later I realised that "there's no such thing as a 2d loop", and the inner loop "doesn't know" it's inside another loop. Such an error is impossible in Python or C, due to the syntax, but I wonder if the same underlying misunderstanding is there, or whether the syntax helps learners realise straight away my revelation.
m
I could probably fill a book (or more) with programming errors like these, made by myself😊. Training an AI with this knowledge and assisting you while coding.. that would be awesome and FoC I think😎
❤️ 1
k
@Maikel do so before you forget them! I encountered a fascinating one yesterday. A coworker tried to define a class method in Python with both
self
and
cls
args.
c
Python has quite a few around the boundary of what is convention and what is "really" part of the language. The use of _ is understood as just a character like any other that is by convention used to signify a "private" method or function, but in fact this naming affects the behaviour of
import *
which seemed like a real break of "the rules" to me.
💡 1
m
@Kartik Agaram maybe I will start doing that, registering the error and its correction in a format that in the near future hopefully can be used to train an AI. Are there already projects doing this (using an AI to give suggestions to coding errors) ?