Hasty Briefsbeta

Bilingual

BQN: What Is a Primitive?

4 days ago
  • #array-programming
  • #primitives
  • #programming-language-design
  • The article discusses the philosophy behind selecting primitives in BQN, arguing against the view that APL-like languages are merely symbolic replacements for common tasks.
  • Symbols are disadvantageous for nuanced concepts as they lack the expressive flexibility of words, which can clarify relations and differences through naming conventions.
  • Syntactic role in BQN influences primitive design: words allow flexible roles via letter casing and underscores, whereas primitives have fixed roles, affecting usability in different contexts.
  • Primitive design is framed as discovery rather than invention, where discovered functions (like arithmetic operations) are universal and consistent across implementations, unlike invented ones that reflect individual biases.
  • The collection of primitives in a language is engineered, but BQN aims to assign symbols to primitive-like functions and words to less primitive-like ones, balancing between APL's symbol-heavy and Python's word-heavy approaches.
  • Engineering is acceptable when it enhances accessibility of underlying primitives, such as combining functions like Range or Rank, though these are seen as somewhat unfortunate for convenience.
  • High-quality primitives exhibit properties like simplicity, consistency, and independence, often interlinked, and they tend to enable algebraic manipulation, fewer edge cases, and cross-domain applicability.
  • Arithmetic functions (e.g., +, -, ×) serve as exemplar primitives, universally symbolized across languages due to their indispensable and structured nature in mathematics and programming.
  • Primitives obey mathematical rules (e.g., subtraction undoes addition), facilitating algebraic manipulation and safe code optimization, with symbols aiding in recognition and manipulation due to lower cognitive overhead.
  • BQN emphasizes primitives in arithmetic, functions, and arrays—key computational types—while excluding namespace primitives, as namespaces are for organization, not computation, and arrays' immutability supports primitive definitions.
  • Compared to utilities in popular languages, BQN's primitives are designed for simplicity, consistency, and composability, reinforcing benefits like reduced edge cases and enabling powerful algebraic refactoring and code optimization.