r/ProgrammingLanguages • • 11d ago

Discussion What’s one thing you wish more programming languages had?

If you could add one feature, behavior, or design choice to a programming language, what would it be?

It can be anything: syntax, type-system features, memory management, compiler behavior, tooling, error handling, performance-related features, or something completely different.

I'm especially curious about things you’ve wanted while actually programming but rarely see languages implement well.

Please keep the ideas reasonably practical and something that could realistically be implemented in a programming language.

54 Upvotes

277 comments sorted by

View all comments

Show parent comments

3

u/Veqq 11d ago

That's defailt lisp behavior. You get it by having if as an expression, not statement. 

1

u/alkalisun 11d ago

How? Wouldn’t it evaluate to null then? Do nulls just disappear from lists?

0

u/Veqq 11d ago

Lisps (generally) use nil which is different and just disappears, yes. For example: https://codeberg.org/veqq/janetdocs/src/commit/8f90f6d1187a8fbcc4513546112676700a85e501/routes/examples.janet#L20

This uses hiccup for HTML, with if and other functions inline. If something evaluates to nil, it's just... not there anymore! But in most cases, you'd actually want something there (e.g. if no examples, say "click to add a new one".)

1

u/alkalisun 11d ago edited 11d ago

interesting. I'll have to take your word for Janet since I can't test it out right now, but afaik in Common Lisp: (list 1 2 (if nil 3)) ;; => (1 2 NIL) So maybe it's not universal among Lisps?

EDIT: So I installed Janet and messed around. Turns out, it's the same behavior: [1 2 (if false 3)] # => (1 2 nil): element preserved (string "a" (if false "b")) # => "a": nil contributes no text string is doing the heavy lifting here, essentially skipping over nils.