This Week I Learned (2020-03-08)

  1. Python’s @property feature – similar to PHP’s magic getters and setters in that it allows you to add logic that is implemented when code from outside the class accesses or writes to a variable. Better though, because it can be controlled on a per-variable basis rather than having one clunky method that has to manage all variables for the entire class.
  2. A better way to do number input in HTML – I’ve long been frustrated by the limitations of <input type="number">. I’ve even had to resort to using textfields with JavaScript onkeypress handlers to enforce fairly basic input restrictions such as requiring the user to enter a positive integer. It really seems like opportunities were missed in the HTML5 spec to make a number input that was more usable for both developers and end users, but it’s nice to see that now the alternatives are more widely supported.
  3. WebAuthn public key-based authentication is the future of authentication, and the password era is (hopefully) ending. I really hope this will be widely adopted – even in 2019 I have received an email from a website with my password in plain text “just in case you’ve forgotten”! One complication of the new approach is that authentication will be device-dependent, so apps will need to allow users to manage the devices which can authenticate to their account.
  4. How Bitbucket moved 80% of their DB load to replicas – I love the clever use of write-ahead log sequence numbers to ensure that each user is always talking to a replica which has their latest changes, and Django framework middleware to keep this all out of sight and out of mind for developers.
  5. JavaScript libraries are almost never updated on existing sites – an interesting analysis by Cloudflare, but probably not a surprise. I’m as guilty as everyone else, and it all comes down to testing – without comprehensive automated tests for your front-end, it’s never going to feel “safe” to drop in a new version of a library.