It's self again
Tags: swift, softwaredevelopment
Published: 2020-04-05 21:44:35

---
title: It's self again
published: true
date: 2020-03-01 12:02:49 UTC
tags: swift,software development
canonical_url: https://zeitschlag.net/its-self-again/
---

Nearly two years ago, I wrote [a short piece about `self`](https://dev.to/zeitschlag/me-my-future-self-and-self-509c). Since then, a lot has changed: I got fired, found a new job, quit, and found another new job. I'm working from home now as employee of a fully distributed company. To reflect on that, I've started another German-speaking podcast called ["Allein zuhaus"](https://alleinzu.haus) (German for "Home Alone"). But basically, only little has changed: I'm still working as an iOS developer, mainly writing Swift-code these days. In the last months I noticed, that my "write always `self`"-approach started to crack.

<!--kg-card-begin: image-->

![](https://zeitschlag.net/content/images/2020/03/DraggedImage.jpeg)

<!--kg-card-end: image-->

And then, a few days ago, I read about `self` in a tweet:

> I cannot stand Swift that doesn't use `self.` in front of properties, methods, etc.  
> Why?  
> It's bearable in Xcode (where you have syntax highlighting), but it makes code review on GitHub, Bitbucket, etc, a huge pain (where there is no highlighting): "Where did this come from???" — [@kyleve on Twitter](https://twitter.com/kyleve/status/1229628934418862080)

I read this argument before, in the blogpost that inspired me to write the piece nearly two years ago. Suddenly, I realized, that I didn't write `self` a lot anymore, only in those occassions, where it was absolutely necessary. Cause, you know, syntax highlighting does the job. But this argument totally made sense to me. When reviewing code in the web browser, there's no syntax highlighting. One could say, that using `self` means more independence from tools.

But according to the answers to that tweet, implicit `self` still seems to be a highly controversial topic and so, I highly encourage you to read them. It seems to become pretty similar to the vim vs. emacs-fight.=

In July 2018, [I wrote](https://dev.to/zeitschlag/me-my-future-self-and-self-509c):

> [The aforementioned blogpost](http://thebugcode.github.io/when-to-self-in-swift-and-when-not-to-2/) argues, that not using `self` helps you finding memory leaks in closures. I don't think, that this is an issue of having/not having `self` everywhere in the first place, but more of an issue of paying attention.

Whenever I use a closure, I try to think about cycles — I've started to develop a habit out of this. And sure, sometimes I miss a thing, but but this is basically my way of dealing with it. I see the point, that using `self` only in closures — and other places, where the compiler needs it — it makes it easier to find cycles. But this hasn't been an issuet to me. Either I haven't had any problems with cycles ore I just oversaw them. Probably, but hopefully not, the latter.

When I change closure-code in the future, I might add retain-cycles, but this is, when my habit comes into play: "Oh, this is closure-code. I have to be super extra careful now."

I hope, that my future self and other developers will profit from using `self` again.