Chips: October 18


I’m reading Eloquent JavaScript at the moment and I really like it so far. I’ve been programming in JavaScript for years, but the book makes me look from different angles at some parts of the language.

For example, I’ve been using the ternary operator for a long time, but I didn’t know where its name came from. The answer is really quite simple: A unary operator is an operator that operates on one operand (oh my, so many words starting with “opera”). That would be the minus sign (-) or the negation operator (!). A binary operator, like && or ??, works on two values. And since the ternary operator requires three values (and is the only ternary operator in the language), that’s how it got its name.

Sometimes we use patterns just because that’s how everyone does it, but it’s good to remind yourself of the underlying language features that make them work. For example, in React, we like to conditionally render a component like this: {someCondition && <SomeComponent>...}. This works, because the && operator returns the right-hand value if the left-hand value evaluates to true (in this case, it returns the JSX component which evaluates to a function). || works the same way, but it returns the right-hand value if the left-hand value evaluates to false.


I’ve been working on some projects at work that use TanStack Query, but I hadn’t understood why it’s useful at first. What it does is abstract the way we handle server state in the frontend (as opposed to something like Zustand, which helps managing client state).

Server state is inherently different from client state, because it’s asynchronous. Query tries to solve the complexity inherent to asynchronous state by providing APIs to simplify fetching, caching, synchronizing, and updating server state. Its coolest feature would have to be the cache, because it prevents unnecessary network calls by other consumers if we already have the data for a query.

A good advice I found on the web is to structure query keys hierarchically, because it helps with targeting the right queries to invalidate, and excessive invalidation removes the benefits of Query.


I tried out Laya this weekend after reading about it on heise. It’s a System One model like Jev, but it runs on your machine and inference is free. I’m looking forward to build something with it, because I haven’t built an AI app privately, yet.