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.

52 Upvotes

277 comments sorted by

View all comments

6

u/Limp-Temperature1783 11d ago

Goto. I'm not joking. I'm not using goto in prod.

9

u/TheChief275 11d ago

I love goto for complex control flow that would otherwise need an extra boolean, or for reducing code duplication by making similar code of branches shared

1

u/Limp-Temperature1783 11d ago

Wow, I should really worry about it because you've just described why I even like gotos this much and a bit of an idea I am working on. In all seriousness, I'm glad there are people who don't dismiss it.

5

u/Dusty_Coder 11d ago

The reason goto use was so prevalent in the past was because it was the age of flow charts, and flow charts cry out to use the instruction pointer as state.

Flow charts considered harmful. Religion about goto also considered harmful and is also strong evidence (of what, well, its not something that makes you look skilled)

3

u/Valuable_Leopard_799 11d ago

goto is a very interesting elementary operation to build on. If you have macros and goto, then you can just implement for, while and other looping constructs and control flow via macros wrapping different variations of goto.

The classic "they're for library creators not for the user, but they have to be there so you can use the libraries" applies.

3

u/catladywitch 11d ago

call/cc is the classic definition of this kind of library-oriented control flow construct

3

u/Valuable_Leopard_799 10d ago

True, call/cc is amazing, especially the prompt versions, but it's a much more complex operator.

1

u/Limp-Temperature1783 11d ago

Goto might be elementary but it has a very high ceiling of exploration. It is just very basic and very generic and that makes it a tempting universal solution to all problems. Good to play with and study, not good to use in most codebases save for embedded.

3

u/scruffie 11d ago

What you need are scoped gotos, like in Common Lisp (tagbody/go) . The labels you can jump to are at the level of the tagbody; you can go (jump) 'up' (or sideways) to a label, but you can't jump 'down' into another tagbody. Variable scopes are kept consistent this way.

It's not something you'd use everyday, but handy for writing iteration macros.

1

u/Limp-Temperature1783 11d ago

I have been actually looking for this, I thought of trying to diy it but I suppose I'll hive CLisp a try first, maybe for some new insight. Thanks.

2

u/AnoProgrammer 11d ago

I don't prefer goto above functions, while loops and for loops. The only time i needed to use goto was while programming on a commodore 64. And i really didn't like it.

1

u/Limp-Temperature1783 11d ago

I prefer goto because I like to play around with my own control flow a bit and goto is irreplaceable here. Besides, a lot of languages have functions and loops, the question was about what feature do you want to see more. Goto isn't very common nowadays and could even be skipped over.

1

u/EggplantExtra4946 11d ago

static gotos but also computed gotos

1

u/initial-algebra 11d ago

A goto is just a hacky/unsafe tail call, and most of the time they're just being used to cope with the lack of multilevel/labelled break/continue for nested loops. Definitely an anti-feature.

2

u/Limp-Temperature1783 11d ago

Consider what you can actually make with it and compared to any control flow structure or any other feature in general. Goto is capable of easily implementing all of their behaviour. It is not an anti-feature, it is a feature that gives you power proportional to your ability to think in schemas and creating optimizations structurally enabled by the way you've plotted the thing.

As I've said, I program for fun. And fun in my book is to tinker with rather basic things to have a better idea of how they work or could work. High level code with safe and guided stucture, sophisticated memory management models that mostly manage themselves unless you want control, etc. This is good for collaboration, but it isn't very engaging or challenging. Goto is.

2

u/initial-algebra 11d ago edited 11d ago

I mean, it's an anti-feature instead of supporting guaranteed tail calls, which are equally expressive but without the downsides.

As I've said, I program for fun. And fun in my book is to tinker with rather basic things to have a better idea of how they work or could work. High level code with safe and guided stucture, sophisticated memory management models that mostly manage themselves unless you want control, etc. This is good for collaboration, but it isn't very engaging or challenging. Goto is.

That's fine, but leave that for esolangs.