conv.

All stories
TechActive today · day 3

Steve Klabnik on Rust's resistance to fancy argument features

Programming language designer argues against adding named, optional, and default parameters to Rust, citing maintainability lessons from Ruby.

What to know

  • Klabnik argues Rust should avoid adding named, optional, and default parameters despite their convenience, citing how similar features in Ruby made it harder to discover what functions could do without documentation.
  • The core tradeoff: syntactic sugar can be concise and beautiful, but at the cost of explicitness and discoverability—functions with 23 optional parameters become 'god functions' that are hard to understand.
  • Community commenters propose middle-ground solutions: anonymous structs with defaults, overloading by argument shape, tooling-based fill-in of labels, and using newtypes to prevent positional-argument bugs.
  • Some disagree with Klabnik's blanket skepticism: several argue that modern tooling (language servers, IDE inlay hints) already solve the readability problem, and that optional arguments with Required Option types could be safely added.

The dispute Whether modern tooling adequately solves the readability problem Klabnik identifies, and thus whether Rust can safely add convenience features without the documentation burden he warns against. · positions read across 42 posts and comments

some voices

Rust should avoid fancy argument features entirely because they enable god functions and obscure APIs.

  • “I've wished for named a few times. Never needed optional, and personally hope they don't land.”

    junon · Lobsters ↗
many voices

Alternative syntax like anonymous structs with defaults could give Rust the convenience without the discoverability problems.

  • “IMO the optimal way would be for Rust to have optional structural types and then an anonymous struct literal with `..` to mean filling in defaults”

    mitsuhiko · Lobsters ↗
many voices

Modern tooling (language servers, IDE inlay hints) already solves the readability problem; optional arguments with required Option types could be safely added.

  • “language servers can handle labels for you. Gleam has labelled arguments, and I rarely write them. Instead I run the "fill labels" code action”

    lpil · Lobsters ↗
some voices

Named arguments alone (without optional/default) would be acceptable because they improve readability without enabling god functions.

  • “I think Rust could be okay with named parameters, but not optional or default ones.”

    ralfj · Lobsters ↗

“To be clear about it, there are several things bundled together here: flexible argument types, options hashes, defaults, and keyword-looking syntax. It's that whole style of API that shaped my skepticism, not argument labels by themselves.”

Steve Klabnik, Language designer · steveklabnik.com · Sep 20

Steve Klabnik Programming language designer, Rust community member

Steve Klabnik on Rust's resistance to fancy argument features
programming,rust

How it unfolded 3 developments, newest first · click a bar or a number to jump postscomments

Peak 7 pieces in one hour at Sep 22, 1 PM; 45 pieces over 3 days (3 posts · 42 comments) Sep 21, 12 PM — 1 piece · 1 post — Hacker News 1Sep 21, 1 PM — quietSep 21, 2 PM — quietSep 21, 3 PM — quietSep 21, 4 PM — quietSep 21, 5 PM — quietSep 21, 6 PM — quietSep 21, 7 PM — quietSep 21, 8 PM — quietSep 21, 9 PM — quietSep 21, 10 PM — quietSep 21, 11 PM — 1 piece · 1 post — Lobsters 1Sep 22, 12 AM — quietSep 22, 1 AM — 1 piece · 1 comment — Lobsters 1Sep 22, 2 AM — 2 pieces · 2 comments — Lobsters 2Sep 22, 3 AM — 1 piece · 1 comment — Lobsters 1Sep 22, 4 AM — 1 piece · 1 comment — Lobsters 1Sep 22, 5 AM — quietSep 22, 6 AM — quietSep 22, 7 AM — 2 pieces · 2 comments — Lobsters 2Sep 22, 8 AM — 5 pieces · 5 comments — Lobsters 5Sep 22, 9 AM — 2 pieces · 2 comments — Lobsters 2Sep 22, 10 AM — 3 pieces · 3 comments — Lobsters 3Sep 22, 11 AM — 2 pieces · 2 comments — Lobsters 2Sep 22, 12 PM — 3 pieces · 3 comments — Lobsters 3Sep 22, 1 PM — 7 pieces · 1 post · 6 comments — Lobsters 6, Hacker News 1Sep 22, 2 PM — 1 piece · 1 comment — Lobsters 1Sep 22, 3 PM — 1 piece · 1 comment — Lobsters 1Sep 22, 4 PM — 1 piece · 1 comment — Lobsters 1Sep 22, 5 PM — 1 piece · 1 comment — Lobsters 1Sep 22, 6 PM — 1 piece · 1 comment — Lobsters 1Sep 22, 7 PM — quietSep 22, 8 PM — quietSep 22, 9 PM — 3 pieces · 3 comments — Lobsters 3Sep 22, 10 PM — quietSep 22, 11 PM — 2 pieces · 2 comments — Lobsters 2Yesterday, 12 AM — quietYesterday, 1 AM — 1 piece · 1 comment — Lobsters 1Yesterday, 2 AM — quietYesterday, 3 AM — quietYesterday, 4 AM — quietYesterday, 5 AM — quietYesterday, 6 AM — quietYesterday, 7 AM — quietYesterday, 8 AM — quietYesterday, 9 AM — quietYesterday, 10 AM — quietYesterday, 11 AM — quietYesterday, 12 PM — quietYesterday, 1 PM — quietYesterday, 2 PM — quietYesterday, 3 PM — quietYesterday, 4 PM — quietYesterday, 5 PM — quietYesterday, 6 PM — quietYesterday, 7 PM — quietYesterday, 8 PM — 3 pieces · 3 comments — Lobsters 3Yesterday, 9 PM — quietYesterday, 10 PM — quietYesterday, 11 PM — quietToday, 12 AM — quietToday, 1 AM — quietToday, 2 AM — quietToday, 3 AM — quiet 123
Sep 22yesterdaynow · 4:47 AM ET
  1. 3

    Commenters highlight tooling and alternative solutions to argument confusion

    Several commenters raised practical counterpoints: lpil noted that language servers like Gleam's can automatically fill labels; cceckman argued that IDE inlay hints already provide the readability benefits Klabnik seeks; pushcx suggested newtypes could prevent bugs from positional integer arguments.

    “language servers can handle labels for you. Gleam has labelled arguments, and I rarely write them. Instead I run the "fill labels" code action…”
    — lpil
    • I wonder how much of the "improved readability" would go away if review interfaces supported LSP inlay hints as something you could toggle on. I write Rust in my day job. When writing code, or reviewing in my editor, I am rarely confused by "which argument is this" because `rust-analyzer` tells me; in fact, it uses the same `parameter: ` syntax as…

      cceckmanprogramming,rust1d ago19▲view on Lobsters ↗
    2 more of the top 3 · 38 posts in this stretch
    • > The defaults for these are different: get is checked, split_at is unchecked. `split_at` is not unchecked, and “checked” and “unchecked” aren’t opposites here, because there are two types of checked. The three types are: checked non-panicking (returns `Option`), checked panicking (returns `T` or panics), and unchecked (returns `T` and is…

      chrismorganprogramming,rust1d ago10▲view on Lobsters ↗
    • Or newtypes. I haven't done graphics programming for a long while, but looking at this call I remember how easy it was to introduce bugs when function calls had positional arguments that were all the same integer type, even though one pair is position and another is dimension. If this wasn't in a generic graphics library but a desktop GUI library…

      pushcxprogramming,rust1d ago9▲view on Lobsters ↗
    all of them →
  2. 2

    Rust community discusses alternative approaches to optional arguments

    The essay sparked discussion on Lobsters with commenters proposing alternative language designs. Mitsuhiko suggested optional structural types with anonymous struct literals; ptrettner discussed function overloading by shape; and senekor proposed struct type inference at instantiation sites as middle grounds between convenience and clarity.

    “IMO the optimal way would be for Rust to have optional structural types and then an anonymous struct literal with `..` to mean filling in defaults…”
    — mitsuhiko
    • IMO the optimal way would be for Rust to have optional structural types and then an anonymous struct literal with `..` to mean filling in defaults: ```rust let cropped = image::imageops::crop_imm({ image: &img, x: 10, y: 20, width: 200, height: 100, .. // brings in the rest }); ``` //EDIT: I know that this precise syntax is probably impossible to…

      mitsuhikoprogramming,rust2d ago15▲view on Lobsters ↗
    2 more of the top 3 · 4 posts in this stretch
    • function overloading has tons of variations but I want to call out one axis I'm experiment with in my own (as-of-yet private) language: "function overloading by type" vs "function overloading by shape". And the experiment is how far you can get by only overload "by shape". Which means you overload by number of args and/or by the name of the named…

      ptrettnerprogramming,rust2d ago5▲view on Lobsters ↗
    • I often think anonymous structs / records would be nice in Rust. nitpick: the last line should probably be `..Default::default()`, to stay consistent with named structs. But I think a lot of the convenience here could already be achieved if the struct's name could be inferred at instantiation site. Imagine something like this: ```rs fn main() {…

      senekorprogramming,rust2d ago4▲view on Lobsters ↗
    all of them →
  3. 1

    Klabnik argues Rust should avoid fancy argument features despite convenience

    In the essay, Klabnik explains that his experience with Ruby's flexible argument syntax—particularly Rails methods like `redirect_to`—shaped his skepticism about Rust gaining similar features. He contends that while concise and beautiful, they obscure what a function can do and make good documentation essential rather than optional.

    “I used to love Ruby, and now I love Rust. And to be honest, redirect_to and friends are a huge reason why I am so against Rust gaining these sorts of fancy features: they can be really concise, and beautiful to a certain kind of eye, but it also makes it really, really hard to know what all you can do with a function.”
    — Steve Klabnik
  4. background

    Klabnik publishes essay on function argument design across languages — Steve Klabnik posted an essay titled 'Arguing about Arguments' examining how different programming languages handle function parameters and arguments. The piece analyzes named parameters, optional arguments, default arguments, and function overloading, using examples from Ruby, Python (FastAPI), and Java to illustrate the tradeoffs.

What people are saying 18 voices from 1 site · best of 42 · verbatim

Still unanswered
  • Could optional arguments required to use Option<T> type prevent the god-function problem Klabnik warns about?
  • Should language servers and IDE inlay hints be considered as solving the discoverability issue, making fancy argument features acceptable?
  • What is the practical difference between anonymous struct syntax with defaults and named optional arguments from a maintenance perspective?