Bystroushaak's blog / English section / Weekly updates / Weekly update 2019/09/08; Bugs and a lot of stress

Weekly update 2019/09/08; Bugs and a lot of stress

I've published my first update post last week and immediately thought how much should I propagate this. I mean .. this should be mostly for me, but the first post was longer, with a lot of information and screenshots, so should I post it to the lobste.rs or reddit? Or should I limit this just to a twitter / RSS?

Negative reactions (-6 score) on the lobste.rs provided enough data; no cross post to aggregator sites like reddit or lobste.rs. Just twitter, rss and patreon.

Which reminds me, I've got first patron. Thanks!

tinySelf progress

Oh god. I've spent something like 12 hours by debugging a bug, which wasn't there. I did some changes in interpreter, which were meant to make code more readable and easy to understand. I've added some tests, moved and rewritten some primitive code from python to tinySelf's stdlib.

Suddenly, blocks (equivalent of lambda / closures) stopped working. Naturally, I've thought that I've introduced the bug and literally turned the interpreter inside out. I've put in place debug messages, stepped through thousand of interpreter cycles in PyCharm's debbuger, I've even randomly tried to comment out blocks of code and see whether the behaviour will at least change. And all of this led nowhere.

I've fixed several other bugs found during debugging. I thought that bug may be in compiler, so I've added horribly hacked-together state-machine parser to prettify AST printouts, so instead of

Send(obj=Object(slots={test_while_100: Object(slots={i: IntNumber(0), i:: AssignmentPrimitive()}, code=[Send(obj=Block(code=[Send(obj=Send(obj=Self(), msg=Message(i)), msg=BinaryMessage(name=<, parameter=IntNumber(1)))]), msg=KeywordMessage(name=whileTrue:, parameters=[Block(code=[Send(obj=Self(), msg=KeywordMessage(name=i:, parameters=[Send(obj=Send(obj=Self(), msg=Message(i)), msg=BinaryMessage(name=+, parameter=IntNumber(1)))])), Send(obj=Self(), msg=Message(false))])])), Send(obj=Send(obj=Send(obj=Self(), msg=Message(i)), msg=Message(asString)), msg=Message(printLine))]), test_another: Object(slots={x: Nil(), x:: AssignmentPrimitive(), brekeke: Nil(), brekeke:: AssignmentPrimitive()}, code=[Send(obj=Self(), msg=KeywordMessage(name=x:, parameters=[IntNumber(0)])), Send(obj='another', msg=Message(printLine)), Send(obj=Self(), msg=Message(brekeke)), Send(obj=Block(code=[Send(obj=Send(obj=Self(), msg=Message(x)), msg=BinaryMessage(name=<, parameter=IntNumber(2)))]), msg=KeywordMessage(name=whileTrue:, parameters=[Block(code=[Send(obj=Self(), msg=KeywordMessage(name=x:, parameters=[Send(obj=Send(obj=Self(), msg=Message(x)), msg=BinaryMessage(name=+, parameter=IntNumber(1)))])), Send(obj=Self(), msg=Message(nil))])])), Send(obj=Send(obj=Send(obj=Self(), msg=Message(x)), msg=Message(asString)), msg=Message(printLine))]), test_while: Object(code=[Send(obj=Self(), msg=Message(test_while_100)), Send(obj=Self(), msg=Message(test_another))])}), msg=Message(test_while))

you get

Send(
  obj=Object(
    slots={
      test_while_100: Object(
        slots={
          i: IntNumber(0),
          i:: AssignmentPrimitive()
        },
        code=[
          Send(
            obj=Block(
              code=[
                Send(
                  obj=Send(
                    obj=Self(),
                    msg=Message(i)
                  ),
                  msg=BinaryMessage(
                    name=<,
                    parameter=IntNumber(1)
                  )
                )
              ]
            ),
            msg=KeywordMessage(
              name=whileTrue:,
              parameters=[
                Block(
                  code=[
                    Send(
                      obj=Self(),
                      msg=KeywordMessage(
                        name=i:,
                        parameters=[
                          Send(
                            obj=Send(
                              obj=Self(),
                              msg=Message(i)
                            ),
                            msg=BinaryMessage(
                              name=+,
                              parameter=IntNumber(1)
                            )
                          )
                        ]
                      )
                    ),
                    Send(
                      obj=Self(),
                      msg=Message(false)
                    )
                  ]
                )
              ]
            )
          ),
          Send(
            obj=Send(
              obj=Send(
                obj=Self(),
                msg=Message(i)
              ),
              msg=Message(asString)
            ),
            msg=Message(printLine)
          )
        ]
      ),
      test_another: Object(
        slots={
          x: Nil(),
          x:: AssignmentPrimitive(),
          brekeke: Nil(),
          brekeke:: AssignmentPrimitive()
        },
        code=[
          Send(
            obj=Self(),
            msg=KeywordMessage(
              name=x:,
              parameters=[
                IntNumber(0)
              ]
            )
          ),
          Send(
            obj='another',
            msg=Message(printLine)
          ),
          Send(
            obj=Self(),
            msg=Message(brekeke)
          ),
          Send(
            obj=Block(
              code=[
                Send(
                  obj=Send(
                    obj=Self(),
                    msg=Message(x)
                  ),
                  msg=BinaryMessage(
                    name=<,
                    parameter=IntNumber(2)
                  )
                )
              ]
            ),
            msg=KeywordMessage(
              name=whileTrue:,
              parameters=[
                Block(
                  code=[
                    Send(
                      obj=Self(),
                      msg=KeywordMessage(
                        name=x:,
                        parameters=[
                          Send(
                            obj=Send(
                              obj=Self(),
                              msg=Message(x)
                            ),
                            msg=BinaryMessage(
                              name=+,
                              parameter=IntNumber(1)
                            )
                          )
                        ]
                      )
                    ),
                    Send(
                      obj=Self(),
                      msg=Message(nil)
                    )
                  ]
                )
              ]
            )
          ),
          Send(
            obj=Send(
              obj=Send(
                obj=Self(),
                msg=Message(x)
              ),
              msg=Message(asString)
            ),
            msg=Message(printLine)
          )
        ]
      ),
      test_while: Object(
        code=[
          Send(
            obj=Self(),
            msg=Message(test_while_100)
          ),
          Send(
            obj=Self(),
            msg=Message(test_another)
          )
        ]
      )
    }
  ),
  msg=Message(test_while)
)

This works only in the python emulation mode, because I didn't feel like converting it to valid rpython at the moment.

This proved, that AST is indeed correct and the bug have to be indeed somewhere else. I've suspected the compiler, even thought that I've found the bug, only to find out next morning, that no, I've been just too tired and got confused. I've thought that it may be hidden in the finalization of the CodeContext object, but nope.

Note: Yeah, I really should rewrite the AST objects to output indented representation instead of this post processing hack. I've created #122 to remember this.

At the moment, I think that it is bug in the architecture of the interpreter, and not the code itself. I think that it only manifested itself because I've moved something into the standard library, a little piece of code which expected behavior that should work, but was always wrong by design.

I'll probably write a postmortem analysis, because this bug is really something.

Articles read during the week

I've promised myself that I'll log every article that I'll read in a week. Here is a raw list:

Conclusions

I do tend to spend too much time by reading stuff which in retrospective looks dull.

I've decided to try to stop reading articles on the internet for a week. I am really curious about what it will do to my productivity and whether it will have any impact on the speed of progress of reading books.

Book reading progress

I've been really busy, because the company where I work is trying to migrate parts of its infrastructure to the OpenShift and I've had to port some old services to new system. There were deadlines, hidden bugs and all kinds of problems. I've managed to port everything late in the Friday, but it really was stressful and it had a huge impact on my life.

This has resulted in almost non-existent progress through all "technical" books. On the other hand, I've had an urge to read more sci-fi, so I've picked up Crux and also Use of weapons and also Matter and switched them in the ebook reader randomly and in short periods, because I didn't really felt captivated by any of them.

Only book I've made some progress into is John Van Neumann, which I enjoy very much.

Oh, and I've randomly ordered three books from amazon, even though I really shouldn't (I have something like fourty physical books waiting in queue):

Youtube

I really enjoyed Joe Rogan's talk with John Carmack:

and I've got really interested in this guy:

.. when I saw the speed of his progress. I've even asked him for some tips about editing speed, and he replied:

Hi Bystroushaak! For editing speed, my best tip is to always try to learn more about the features of your editor and trying to integrate them in your daily workflow. I bet your editor has at least one keyboard shortcut that you don’t know about, for example :) For faster programming in general, I made a commute talk video about that a while back: https://youtu.be/8sl9ph1gm08

I am currently trying to finish transition from Sublime / VS Code to PyCharm, so I get the first tip. I've obtained the book Effective pycharm and I am consciously and methodically trying to learn everything PyCharm has to offer. But I've found tips in the video more insightful. Maybe I should also try to make live coding videos to see whether it can improve my focus on the code and the speed of implementing new stuff? I think it could work like a kind of par programming, which is exhausting, but effective.

Anyway, I've decided to watch some of his videos and pay attention on how he writes code and implements new stuff, maybe I'll learn something new there.

Random stuff

I am experimenting with nicotine and theobromine, and I am writing a blog on topic of various cognition enhancing drugs.

I think that I shall probably create some kind of notion template for this weekly updates, if I really want to do them each week. It should contain sections for tinySelf, book reading progress, blog writing progress and random interesting stuff.


Yes, my English is probably horrible, but this kind of blog post doesn't qualify for (paid) grammar corrections. If you want to change this, subscribe to my patreon.


Relevant discussion

Become a Patron