`std::flip`

C++ as a quasi-functional language: what’s missing

  • Several commenters argue C++ is “close” to a usable functional language but still lacks:
    • Structural pattern matching (with proper sum types, not just std::variant).
    • Uniform function call syntax (treating a.foo(b) and foo(a, b) as interchangeable).
    • Simpler lambda syntax and generally less “symbol vomit”.
  • Others feel the language’s syntax and complexity make functional style unappealing, even if the features exist.

Uniform function call syntax debate

  • Papers proposing uniform call syntax were linked; some find the idea convenient, especially for piping/functional pipelines.
  • Strong opposition centers on already-complex name lookup and overload resolution; “making two forms nearly equivalent” is seen as dangerous for complexity and readability.
  • There is joking about ever-more-baroque syntax and fictitious “Kaiser lookup” rules.

Structural pattern matching and sum types

  • Pattern matching is widely desired but many insist it must come with first-class, nominal sum types (tagged unions).
  • std::variant is viewed as inadequate; some argue sum types are as fundamental as structs and should be language features, not just libraries.
  • Others note C++’s philosophy of “do it in a library if possible” plus backward compatibility makes a clean design hard, especially with constructors, destructors, RAII, and inheritance.

Complexity of flip and C++’s trajectory

  • Many are shocked at the 100+ line implementation of flip in C++ versus tiny Haskell/Python versions, seeing it as evidence that C++ has gone off the rails.
  • Defenders note that the C++ implementation is fully generic, incurs no runtime overhead, and leverages compile-time transformations; Python/Haskell versions trade simplicity for performance or limited arity.
  • Some argue C++ should stop adding features; others counter that complexity largely comes from preserving decades of backward compatibility.

Usefulness and risks of flip

  • Several commenters struggle to imagine non-toy uses for flip; others cite reversing relations (is_ancestor_of vs is_descendant_of) and adapting API argument order or currying schemes.
  • A geospatial example (latitude/longitude vs longitude/latitude) is criticized as a potential “footgun”; safer designs would use distinct types or structured data instead of relying on flip.

Meta reactions to the article

  • Multiple readers initially believed std::flip was real and were unsettled until reaching the reveal.
  • The thread is explicitly used as a “who read the article” filter.
  • Some suspect the article’s style or specific sentences of being AI-generated, though this is not resolved.