this post was submitted on 11 May 2026
61 points (98.4% liked)

Programming

26901 readers
302 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] jtrek@startrek.website 49 points 1 day ago (12 children)

I use keyword arguments in Python to minimize this pain. Instead of


create_user("Bob", True, False)

it's


create_user(name="Bob", admin=True, send_email=False)

JavaScript makes that more cumbersome with the object thing , but it's better than nothing.

[–] eager_eagle@lemmy.world 20 points 1 day ago* (last edited 1 day ago) (6 children)

This! There's also a longstanding open issue on rust to allow a similar way to pass keyword/named arguments. IMO every modern language should have something like this. Makes all the difference when reading code.

Inlay hints from your editor are a good help, but this should be built into the language.

[–] FizzyOrange@programming.dev 9 points 1 day ago (1 children)

Rust doesn't need this as much because it has enums so you can just do create_user(user, Role::Admin, Notify::None).

[–] eager_eagle@lemmy.world 9 points 1 day ago (2 children)

you can have a better data structure in any language, but rarely someone will bother doing that for booleans

[–] FizzyOrange@programming.dev 1 points 21 hours ago

Yeah I do wonder if we need an easier way to declare these things because programmers are lazy and even in Rust I wouldn't always bother.

You can kind of do it in Typescript with strings:

function create_user(role: "admin" | "normal")

But of course the downside is they are strings at runtime. I'm sure it's possible though.

[–] Traister101@lemmy.today 3 points 1 day ago

Right cause the boolean isn't a named type. If you have two possible states that can be represented with a boolean, or an enum of the two possible states which embeds more info into the callsite

load more comments (4 replies)
load more comments (9 replies)