Hasty Briefsbeta

What Dynamic Typing Is For

10 hours ago
  • #web-services
  • #dynamic-vs-static-typing
  • #software-development
  • Unplanned Obsolescence blog focuses on writing maintainable, long-lasting software, often favoring dynamically-typed languages.
  • Dynamically-typed languages like JavaScript encode less information, making it harder to understand code without digging into implementation details.
  • Example authentication middleware in JavaScript shows readability but lacks clarity on edge cases like missing tokens.
  • Equivalent Rust code is more explicit with types and edge case handling, improving maintainability.
  • Static typing (e.g., Java, Rust) is generally better for long-term maintainability compared to dynamic typing (e.g., JavaScript, Python).
  • Web services often interact with multiple DSLs (e.g., HTML, CSS, SQL), increasing complexity.
  • Attempts to abstract DSLs into general-purpose languages (e.g., JSX, CSS-in-JS) often result in clunkier syntax and reduced maintainability.
  • Alternative approach: Use strong API boundaries between DSLs (e.g., templates for HTML, raw SQL for queries) to retain clarity and debuggability.
  • Debugging is easier when logic is pushed into declarative DSLs (e.g., SQL, HTML) rather than imperative server code.
  • Dynamic typing encourages minimal server code, leaning on DSLs, while static typing adds boilerplate for marginal safety gains.
  • Proposal: Compilers should understand DSLs (e.g., SQL, HTML) to provide type safety without sacrificing expressiveness.