Weekly Notes 013 - Learning Python, Becoming Better at Algorithms & Data structures

Hello, welcome to my weekly notes. I hope you find something useful from my experience this week.

  • I blew up an algorithm test for a Software Engineering role this week. It was so bad that I purchased AlgoExpert, SystemExpert, started a fullstack developer nanodegree and started learning Python.

  • I'm running this little experiment where I put out random 30 minutes of my time to talk about Typescript. You'd want to try it if you're

    • Planning on learning Typescript
    • Learning Typescript[]
    • Migrating a codebase from JS to TS
    • Just want to have a random chat about Typescript
  • My experience with Python has been eye-opening. No semi-colon, parenthesis, etc. Everything just feels different coming from a JS world.

  • Unfortunately, none of the companies I'm interviewing for have reached back. This coming week feels like a great one already πŸ’ͺ🏼πŸ’ͺ🏼πŸ’ͺ🏼.

Stuff I'm reading

  • Writing better TypeScript - As someone who writes Typescript every day, this is straight off the most useful article I've read. In TS, your code is as correct as your defined types. It then makes sense to reduce defining types by hand. See, for instance, an example from avocado - an experimental design system I'm building

    import colors from "../colors";
    import borders from "../borders";
    import spacing from "../spacing";
    
    const buttonTheme = {
      variants: {
        primary: {
          default: colors.blue[500],
          hover: colors.blue[400],
        },
        error: {
          default: colors.red[400],
          hover: colors.red[300],
        },
        success: {
          default: colors.green[500],
          hover: colors.green[400],
        },
        warning: {
          default: colors.yellow[500],
          hover: colors.yellow[500],
        },
      },
      borders: {
        round: borders.full,
        curve: borders.sm,
      },
      size: {
        sm: `${spacing.small} ${spacing.medium}`,
        md: `${spacing.small} ${spacing.medium}`,
        lg: `${spacing.medium} ${spacing.large}`,
      },
    };
    
    // Instead of defining types by hand,
    // I leverage the typeof operator to export the object type
    // If I change this object tomorrow, I don't need to do anymore work
    export type ButtonTheme = typeof buttonTheme;
    export { buttonTheme };
    

    or this example

    type Options = {
      [K in
        | "noImplicitAny"
        | "strictNullChecks"
        | "strictFunctionTypes"]?: boolean;
    };
    
    // instead of
    //   type Options = {
    //       noImplicitAny?: boolean,
    //       strictNullChecks?: boolean,
    //       strictFunctionTypes?: boolean
    //   };
    
    • Instead of manually defining types, use techniques that ensures the type exactly matches the object in question.
  • Learning Rust and Go - This came right in time. Good engineers are not bound by languages. Stefan Baumgartner talks about his experience learning Rust and Go. This article helped me decide on learning Python.

  • Bulletproof Uniq with TypeScript generics (yay code reviews!) - A case of where code reviews can prevent a bug in production. No one has reviewed my code before. I think this is something I should work on. Please reach out if you'd like to help!

  • Building a type-checked URL router from scratch - Think of building a react-router with TS from scratch. This article is very deep and takes a lot of effort to understand. It's okay if you don't immediately get everything.

  • Getting Started with React Query and TypeScript - Two things I like about React query are the re-fetching strategy and caching. I built a huge part of whereAPI's frontend with it and it was a great experience.

  • Two approaches to win an argument as a software engineer - I agree with everything Nicholas says. In my previous life as a designer, almost every design decision had to be data-informed. It's easy to think of some solution, but if you can't communicate your thought process, it's a failed idea. Biggest lessons from this article; argue with data and argue with code.

  • I need to learn about TypeScript Template Literal Types - I learned about Typescript template literal types this week. Released with TS 4.1, it helps make your type definitions simpler and DRY. Take this for example

    type Position =
      | "top-left"
      | "top-center"
      | "top-right"
      | "middle-left"
      | "middle-center"
      | "middle-right"
      | "bottom-left"
      | "bottom-center"
      | "bottom-right";
    
    declare function setAlignment(value: Position): void;
    
    setAlignment("top-left"); // works!
    setAlignment("middle-right"); // works!
    setAlignment("top-middel"); // error!
    

    We can make things simpler with string literal types like so...

    type VerticalAlignment = "top" | "middle" | "bottom";
    type HorizontalAlignment = "left" | "center" | "right";
    
    declare function setAlignment(
      value: `${VerticalAlignment}-${HorizontalAlignment}`
    ): void;
    
    setAlignment("top-left"); // works!
    setAlignment("middle-right"); // works!
    setAlignment("top-middel"); // error!
    
  • From Rust to TypeScript - Rust is a low-level, systems programming language. I like to put it in the same category as C#, first because it's written in C & C++. Secondly, I really can't wrap my head around it. This article documents Alan's journey learning Rust from Typescript.

  • Using built-in utility types in TypeScript - Basarat writes about advanced utility types in Typescript. I've learned that using typescript constructs like these makes your codebase more solid and mature.

  • Coding Shorts: Structural Typing in TypeScript - If you're learning TS from a more structured C/C++ background, you'd be shocked at how the type system in TS differs. I learned a lot from this short and straightforward video.

  • The Service Now API and TypeScript Conditional Types - Conditional types in Typescript are so powerful. Instead of defining numerous types, we can include logic in type definitions.

Person of the week

I've decided to include a section of my weekly notes where I document engineers and creative people I want to learn from.

  • Linus - thesephist.com - Linus studies computer science at UC Berkeley. I got a lot of encouragement from reading his articles and work. One thing that's worth mentioning is the way he learns...

It's just incredible how helpful this kind of thinking is. He also has time to draw and do music on the side. Really inspiring.

I’ve written over 400k words about creative work, community, startups, and life on this blog, and about software and computing on my technical blog dotink.co. I’ve made 120+ side projects ranging from programming languages and compilers to 3D renderers, original studio albums, interactive learning environments, UI libraries, art projects, and a suite of personal productivity tools that power my life.

Other Resources

Music

Sharing my love for Afrobeats

  • Visuals for La La - 😍😍😍 The hugely anticipated visuals by Davido & CKay. These guys keep pushing the limits of Afrobeats.
  • EQUAL Africa - Spotify playlist of creative African women doing awesome stuff in Afrobeats. This one made my week.
  • Ngiyazifela - Something about this song makes me happy. I really can't place my hands around it... Listened to it all week.

That'll be all for this week. I'm so happy to have you. Wish you a great week ahead πŸ™πŸΌ.