AI summary by TwinMind

JavaScript imports kinda suck...

Theo - t3․gg

5m 9s

JavaScript Import Syntax Problem

  • JavaScript imports have fundamental design flaw affecting developer experience
  • Current syntax: import { useState } from 'react' requires specifying source before imported items
  • Problem: IDE/language server cannot provide autocomplete until full import path typed
  • Developer must correctly guess import name before getting editor assistance
  • Misspellings like useStats only caught after typing entire statement
  • Results in frustrating trial-and-error development experience

Proposed Solution vs Reality

  • Better syntax would be: from react import useState (source first, then items)
  • This syntax not possible in JavaScript - ECMAScript import syntax already decided long ago
  • Too late to change existing standard
  • Current design prioritizes code readability over developer tooling experience

Superior Import Patterns in Other Languages

Elixir

  • Syntax: import Module, only: [function: arity]
  • Example: import Enum, only: [duplicate: 2]
  • Allows IDE autocomplete as you type
  • Can specify exact function signatures needed

C#

  • Syntax: using System.IO
  • Clear module.submodule pattern
  • Excellent autocomplete support
  • Must use separate statements for multiple imports

Java

  • Syntax: import package.class.name
  • Similar to C# approach
  • Became standard pattern for many languages
  • Clear hierarchical structure

Python

  • Syntax: from X import Y
  • Exactly matches proposed JavaScript improvement
  • Makes development pleasant and intuitive
  • Aligns with language goal of being fun to write

Scala

  • Syntax: import example(specificThing) or import example._ for everything
  • Parentheses optional for importing everything
  • Clean, functional approach

Rust

  • Uses double colon syntax: crate::module::item
  • Bracket syntax for multiple imports: use std::{io, fs}
  • Supports wildcard imports (concerning for compile times)
  • Complex but powerful nested import system

PHP

  • Syntax: use My\Full\Class\Name as Another
  • Simple aliasing system
  • Direct binding of imports to local names

Language Design Philosophy

  • Many languages prioritize developer experience over pure syntax aesthetics
  • Editor experience crucial for language adoption and productivity
  • Code is written and interacted with, not just read
  • Future JavaScript features should consider tooling implications
  • ECMAScript maintainers should prioritize developer experience in future decisions

TwinMind

Get summaries like this for your own meetings

TwinMind takes notes in the background during meetings, lectures, and calls, then writes the summary for you.

Free plan to get started

No bot joins your calls

Phone, desktop & Chrome apps

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome