r/ProgrammingLanguages • • Sep 21 '26

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.

58 Upvotes

299 comments sorted by

View all comments

Show parent comment

6

u/snugar_i Sep 22 '26

Fair enough. I meant sum types that aren't a pain to write or use. Most languages have something that is supposed to emulate them, but usually it requires a lot of boilerplate.

In Rust I can do

enum Foo {
    Bar,
    Baz(u32),
}

In Java I have to write

sealed interface Foo {
    final class Bar implements Foo {
    }

    record Baz(
            int x
    ) implements Foo {
    }
}

And in Python

class Bar:
    pass


@dataclass
class Baz:
    x: int


type Foo = Bar | Baz

It's just much more work than product types

2

u/UdPropheticCatgirl Sep 22 '26

Fair enough, but I feel that requiring this much ceremony for sum types is basically exclusive to Java and Object Pascal, (and to some extent Ada), every other language is much saner and more concise in line with rust.

3

u/snugar_i Sep 23 '26

Most are getting better I guess, but Kotlin is as bad as Java, and Scala 2 wasn't that much better (Scala 3 is OK though). These + Python are unfortunately all I use, so from my point of view, the situation is not ideal :-)

2

u/UdPropheticCatgirl Sep 23 '26

Most are getting better I guess, but Kotlin is as bad as Java, and Scala 2 wasn't that much better (Scala 3 is OK though). These + Python are unfortunately all I use, so from my point of view, the situation is not ideal :-)

I guess that my ultimate issue is that I fundamentally don't see that much of a difference between this syntax:

data Expr a where
  LitInt  :: Int      -> Expr Int
  LitBool :: Bool     -> Expr Bool 
  Add     :: Expr Int -> Expr Int  -> Expr Int
  Equal   :: Expr Int -> Expr Int  -> Expr Bool

and this:

sealed interface Expr<A> {
	static record LitInt(Integer literal)                     implements Expr<Integer> {}
	static record LitBool(Boolean literal)                    implements Expr<Boolean> {}
	static record Add(Expr<Integer> lhs, Expr<Integer> rhs)   implements Expr<Integer> {}
	static record Equal(Expr<Integer> lhs, Expr<Integer> rhs) implements Expr<Boolean> {}
}

or

sealed trait Expr[A]

object Expr {
	case class LitInt(Int literal)                         extends Expr[Int]
	case class LitBool(Boolean literal)                    extends Expr[Boolean]
	case class Add(Expr[Int] literal, Expr[Int] literal)   extends Expr[Int]
	case class Equal(Expr[Int] literal, Expr[Int] literal) extends Expr[Boolean]
}

or this:

enum Expr[A]:
	case LitInt(Int literal)                         extends Expr[Int]
	case LitBool(Bool literal)                       extends Expr[Boolean]
	case Add(Expr[Int] literal, Expr[Int] literal)   extends Expr[Int]
	case Equal(Expr[Int] literal, Expr[Int] literal) extends Expr[Bool]

Sure, Java is more keyword-heavy (and doesn't have nice type refinement in pattern matching, but neither do a lot of languages, including Rust... so that's its own separate problem), but I type fast enough that I couldn't really care less :-). I also use Java at work and am pretty happy with it.

Kotlin and Python are probably actually the weakest of the ones you mentioned when it comes to ergonomics for this kind of thing. But no one accuses Kotlin of being particularly well thought out or well designed, and Python is dynamic, so it's kind of its own different world.

2

u/snugar_i Sep 23 '26

Well, I guess GADTs are ugly everywhere. But regular ADT sum types are much nicer in Rust and Scala 3 than in Java/Kotlin/Python.

But no one accuses Kotlin of being particularly well thought out or well designed

Good point :-)

1

u/drBearhands Sep 24 '26

Same with Dart

1

u/koflerdavid Sep 23 '26

The Java one could be made to look much shorter by adjusting the formatting. The advantage of Java's design is that all features which make up its ADT were introduced with perfectly valid intended uses apart from ADTs. The disadvantage is of course that there are a lot of moving parts that have to work together.

2

u/snugar_i Sep 23 '26

And that can be either a good thing or a bad thing, depending on who you ask :-) It's nice that it can do other things as well, but it makes it much harder to read a piece of code and just know "this is a sum type"