What I Read in March 2023

Posted on 4th of April 2023 | 558 words

Pretty technical month in my reading this time.

Liz Rice: Container Security

I got free copies of this book and the couple of next books from an event so I decided to read them through due to how close they are to my profession. While working as a plumber, container security tends to be a very common topic and also topic that I’m very interested in. Rice is pretty popular public figure in the “cloud native” world who I’ve seen to give great talks about wonderful topics in the past, which made me quite excited about this book.

Generally speaking book itself was good. It offered a nice and relatively brief overview of various techniques that are involved in container security and also giving a nice understanding of containers itself. Personally, I probably would’ve wanted it to be slightly more practical, but nonetheless, I think it’s a great tech book addition to many bookshelves.

Liz Rice: Learning eBPF

Another book from Rice. I’ve been big fan of eBPF for many years so I was quite excited about this one also. Timing of receiving this book was great since I was just about to give a talk on how me and my colleagues at my current employer have used eBPF based technologies in our day-to-day work at Isovalent’s (creators of eBPF) Cilium (Kubernetes CNI) Workshop that we were hosting in Berlin.

I have been already working quite a bit Linux Kernel and eBPF before so there wasn’t necessarily that much new stuff from the book but there were some and lots of refreshers so I really enjoyed it.

eBPF is also a topic quite dear to me, so I already have some posts about in the woodshed. So expect more in that front from me.

John Rosso et al: Production Kubernetes

This was the last book that I got for free and was quite interested about it too. Despite working with production Kubernetes for quite a few years already, I wanted to read this to see if I could learn some new stuff from it. Overall, I think it’s a great book if you happen to work with Kubernetes. For me, most of the stuff was something that I knew already from using Kubernetes for many year, but still I think it offers a great “introduction” to how to operate Kubernetes in production.

John Maeda: The Laws of Simplicity

I’ve had this book on my library for many years but I just haven’t been able to start reading. Especially in tech, simplicity is something that tends to by highly valued, and for a reason. While this book applied mainly to design of various products etc., Maeda himself comes from technical background, so lots of the stuff he writes, can be applied to computer science and programming. I think it was a great book!

E.M. Foster: The Machine Stops (reread)

I have read this sci-fi short-story for many times already and I love it every time. It’s a very psychedelic book to read in 2020s. Book itself was written in 1909, but somehow even back then Foster was able to depict a future where humans are addicted to technology. Very short book but great! I think I originally found it from some Jaron Lanier’s talk about social media so this book made my almost luddite stance towards tech even stronger.

Utah Is First US State to Limit Teen Social Media Access

Posted on 26th of March 2023 | 358 words

Utah has become the first US state to require social media firms get parental consent for children to use their apps and verify users are at least 18.

The bills will give parents full access to their children’s online accounts, including posts and private messages. The move comes amidst heightened concern over the impact of social media on children’s mental health. Under the measures enacted on Thursday, a parent or guardian’s explicit consent will be needed before children can create accounts on apps such Instagram, Facebook and TikTok.

I feel that most of us can agree that social media has had a very bad impact on our youth and adults alike. Mental health issues have risen linearly with the usage of social media. People’s attention span has decreased constantly due to the nature of the applications and how they grab your attention. Of course, what I’m referring here is Big Tech social media. So in many ways, banning social media would be a good idea.

But this is dangerous game US is playing. When you’re proposing something like this, the proposal can be easily applied to many other online communities that can be tremendously helpful for many. Great example for something like this is various LGBT communities online which might be the only safe haven for many, especially those living under strict regime or conservative surroundings. Can this sort of bill also ban those? Will teenagers using these sort of “social medias” be outed then?

Similar concerns are raised by Common Sense Media:

But Common Sense Media and other advocacy groups warned some parts of the new legislation could put children at risk.

Ari Z Cohn, a free speech lawyer for TechFreedom, said the bill posed “significant free speech problems”.

“There are so many children who might be in abusive households,” he told the BBC, “who might be LGBT, who could be cut-off from social media entirely.”

So time will tell how this will turn out. Personally I would be more comfortable to see more strict restrictions to be applied for these sort of companies, instead of giving the state/parents a right to go through their children’s messages.

Running staticcheck with eglot and gopls

Posted on 17th of March 2023 | 188 words

Another neat finding in Go’s language server. Basically, I wanted to include some sort of way to run some static analyser with my language server. I remember golanci-lint was long the “de facto” tool for this, but seems that staticcheck has grown a lot in popularity. So I wanted to integrate that with my gopls.

Naturally, the first step was installing the tool itself. Fortunately, that can be done super easily with just:

$ go install honnef.co/go/tools/cmd/staticcheck@latest

Next I needed to enable this somehow with gopls. Again fortunately, all the possible settings for gopls can be found here. Including the simple variable for staticcheck. To pass in this setting to eglot, I need to configure variable eglot-workspace-configuration, which basically allows you to configure LSP servers specifically for a given project and given LSP.

To pass in the setting to the gopls, we need to pass in a plist with the configurations we want:

(use-package eglot
  :custom
  (eglot-workspace-configuration '((:gopls . ((staticcheck . t))))))

;; OR

(setq-default eglot-workspace-configuration '((:gopls . ((staticcheck . t)))))

Naturally, you can pass any setting you desire that is available for the language server this way.

What I Read in February 2023

Posted on 6th of March 2023 | 597 words

Purely Functional Data Structures by Okasaki, Chris (reread)

I read this book when I was in my deep-deep functional programming phase couple of years back. Coming from imperative and OOP world, I already had a pretty good understanding of algorithms and data structures, but that knowledge was very much grounded in the imperative world. This book got recommended to me on how similarly useful data structures can be implemented in a purely functional way. I wanted to reread due to having some discussions with friends of mine about this same topic, so I wanted to refresh some memory about it.

Overall, I feel that it’s a very fun book to read and, compared to many other data structure books, it’s also quite fun to work with. It’s definitely niche on not so widely usable book compared to many other algorithm and data structure book, but definitely something that can give you a new view on certain problems.

The Buddha’s Teachings and Refuge by Thanissaro Bhikkhu

I have had long fascination towards Thai Forest Buddhism for many years now. Work of Thanissaro Bhikkhu was familiar to me in the form of his translations of numerous suttas. Quite recently I found out that he has also written many books on Buddha’s teaching, varying from fundamentals to interpreting Pali canon. So I wanted to wrap my head around those. Definitely recommend for anyone that cares about either Buddhist practice or just mindfulness in general.

All of his writing and talks are available at https://www.dhammatalks.org/index.html .

Insomniac City by Hayes, Bill

Every once in a while, I have some irregularities in my sleeping schedule. I got recommend this book due to its running theme of insomnia in it, so I during one of many of my sleepless nights, I decided to pick this up and start reading it. Book is about the authors, insomniacs himself, own life in New York and also the event what led to him moving there. Book covers many sleepless nights in New York City and how the author wanders around it finding stories. One of the main focal points in the book is also the author’s relation ship with the late Oliver Sacks . Very heartwarming story, definitely recommended.

Ten Arguments for Deleting Your Social Media Accounts Right Now by Lanier, Jaron and Digital Minimalism by Newport, Cal (both reread)

I decided to bundle both of these books here since they’re mainly about the same topic. Main reason on why I wanted to reread these was the recent events happening on Twitter. Despite I’m not part of any social medias (outside LinkedIn and that is also mainly due to requirements), I’m always quite interested on what’s happening around it. I thinks it’s mainly just hate towards those platforms so I just want to see them burn. Another big reason why I wanted to reread these was the fact that the popularity of Mastodon really started to get some traction. But I think this requires it’s own long form blog post about. So stay tuned on it.

No Longer Human by Dazai, Ozamu

For some reason, I’ve always had a weird fascination towards tragic human lives. Ozamu Dazai’s semi-autobiographical novel No Longer Human definitely tells the story of one. Very dark, grim and heavy book about mental illness and its effects on human nature. Don’t know if I can recommend this book for too many people. While it was very well written, the topics that it explores can be definitely be too much for many. But if you’re up to it, I think it’s worth a read

Generics-aware gopls in Emacs

Posted on 3rd of March 2023 | 473 words

I needed to write some funky Go code using relatively new Go generics in it, just to quickly notice that my LSP client in Emacs didn’t recognise those like you would expect. Fixing gopls was relatively straight-forward, since my issue seemed to be just an old version. So I just installed gopls while having Go 1.18+ installed. In my case, I had already generics-aware Go version installed but seemed like that I had installed my gopls version before the generics update, so I had to just reinstall it with:

$ go install golang.org/x/tools/gopls@latest

After that gopls was pleased, or at least my eglot didn’t complain about syntactical errors in my code. Pretty much immediately I realised that now my goimports was broken, so it didn’t organise my imports accordingly. I knew that gopls was able to do this stuff instead of using goimports, but I just never was eager to fix something that was already working. But since now it was broken, I decided to find a way to fix it.

What I did was just uninstall goimports from my machine and started relying on gopls for organising my imports. Previously, I had set my Emacs so that when I saved my files, it always ran goimports (when working on Go files, of course). Setting my eglot to do that was relatively simple, but then I noticed that it only formats my code, it doesn’t automatically import the libraries like how goimports does.

Like I mentioned earlier, gopls should be able to work exactly like goimports in this case, so I had to start digging on how I can make my eglot to do this. Basically, how gopls does this, is it uses source.organizeImports action for it. So I needed to run that somehow on save.

Fortunately, eglot exports all these code actions that the LSP can do with a neat function called eglot-code-actions. After some tinkering, I was able to call that before the save:

(use-package go-mode
  :ensure t
  :preface
  (defun tok/gofmt-before-save ()
    (interactive)
    (gofmt-before-save)
    ;; Run `eglot-code-actions' only in buffers where `eglot' is active.
    (when (functionp 'eglot-code-actions)
      (eglot-code-actions nil nil "source.organizeImports" t)))
  :hook (go-mode . (lambda ()
                     ;; Using depth -10 will put this before eglot's
                     ;; willSave notification so that the notification
                     ;; reports the actual contents that will be
                     ;; saved.
                     (add-hook 'before-save-hook 'tok/gofmt-before-save -10 t))))

I decided to use gofmt-before-save, which comes from go-mode here since I noticed that if you would just run eglot-format-buffer formatting doesn’t open a new buffer where it lists all the errors and instead prints them in the LSPs messages. You can probably dig them somehow from there and print in a new buffer, but I liked already the existing behaviour of running gofmt with go-mode so I decided to use that one.

Small fix, but a really good one. Happy generics-aware hacking.