Sumit Ghosh
4K posts

Sumit Ghosh
@summitkg
CTO and Co-Founder @ https://t.co/uvPmgt0xwW. CS @iitdelhi

The last thing you see before recursive self improvement goes hyperbolic



we end up looking over a LOT of PRs given how many we receive for opencode i can boil down a lot of mistakes into not understanding the idea of state and derived state the rule of thumb is you want to default to having as few pieces of state as possible and deriving values where you can for example if you have count and you want a value that represents double count i often see this 𝚕𝚎𝚝 𝚌𝚘𝚞𝚗𝚝 = 𝟶 𝚕𝚎𝚝 𝚍𝚘𝚞𝚋𝚕𝚎𝚍 = 𝟶 𝚏𝚞𝚗𝚌𝚝𝚒𝚘𝚗 𝚜𝚎𝚝𝙲𝚘𝚞𝚗𝚝(𝚟𝚊𝚕𝚞𝚎) { 𝚌𝚘𝚞𝚗𝚝 = 𝚟𝚊𝚕𝚞𝚎 𝚍𝚘𝚞𝚋𝚕𝚎𝚍 = 𝚟𝚊𝚕𝚞𝚎 *𝟸 } when you really want this 𝚕𝚎𝚝 𝚌𝚘𝚞𝚗𝚝 = 𝟶 𝚌𝚘𝚗𝚜𝚝 𝚍𝚘𝚞𝚋𝚕𝚎𝚍 = () => 𝚌𝚘𝚞𝚗𝚝 * 𝟸 reason being as things get more complicated it's really difficult to make sure changing one thing updates everything that depends on it it's actually very rare you need a new piece of state - to the point where whenever i see someone create it i immediately investigate if it's needed this is a trivial example but the root idea applies to everything from frontend to backend to database of course if you have performance issues you might want to precompute derived values but deriving state is a good default mindset

Who are you when no one is watching?

