Write code that prioritizes readability and clarity over minor optimizations or clever shortcuts. When faced with choices between concise but obscure code and more explicit but readable code, choose readability.

Key principles:

Example of applying this principle:

// Less clear - uses unnecessary !! operator
if (!!requireEsm) {
  // ...
}

// More clear - direct boolean check
if (requireEsm) {
  // ...
}

// Less clear - complex nested logic
ptr->setModuleRegistry(([&]() -> kj::Own<void> {
  KJ_IF_SOME(newModuleRegistry, options.newModuleRegistry) {
    return JSG_WITHIN_CONTEXT_SCOPE(js, context, [&](jsg::Lock& js) {
      return newModuleRegistry.attachToIsolate(js, compilationObserver);
    });
  }
  return ModuleRegistryImpl<TypeWrapper>::install(isolate, context, compilationObserver);
})());

// More clear - explicit else clause for readability
ptr->setModuleRegistry(([&]() -> kj::Own<void> {
  KJ_IF_SOME(newModuleRegistry, options.newModuleRegistry) {
    return JSG_WITHIN_CONTEXT_SCOPE(js, context, [&](jsg::Lock& js) {
      return newModuleRegistry.attachToIsolate(js, compilationObserver);
    });
  } else {
    return ModuleRegistryImpl<TypeWrapper>::install(isolate, context, compilationObserver);
  }
})());

Remember: code is read far more often than it’s written. Optimize for the reader, not the writer.