r/Compilers • • Jul 20 '26

From Library Patterns to Language Features: An Overlooked Rule of Language Evolution?

For decades, programmers have solved new problems by creating abstractions in libraries before languages officially supported them.

Some of these patterns eventually became language features. inline is one example. _Generic is another.

But many important abstractions still live only as library conventions.

Large C projects are good examples. GObject/GTK built their own object model. Linux VFS has its own object-oriented design. Many projects repeatedly create similar patterns in different ways.

This makes me wonder:

Is there a point where a commonly repeated library pattern should become a language feature?

What signals that transition?

  • widespread adoption?
  • compiler optimization opportunities?
  • better expression of programmer intent?

Or should some abstractions always remain libraries?

Curious how people think about this boundary.

18 Upvotes

21 comments sorted by

View all comments

Show parent comment

1

u/General_Purple3060 Jul 20 '26

That's a fair point. Features like inline and _Generic are more about extending expressive power and don't really affect the programmer's control over the program.

So maybe it's not true that "all language features trade control for convenience". Some features simply expose new capabilities.

The more difficult cases are abstractions like object systems, memory management, or execution models. When a language takes responsibility for these concepts, it inevitably introduces a different trade-off: programmers give up some implementation choices in exchange for higher-level semantic support.

Where should this boundary be?

2

u/FloweyTheFlower420 Jul 20 '26

The lower level the language, the more things are library features. The higher level the language, the more things are language features. Seems like a pretty obvious trend.

The answer is boring and is just "it depends on the language." If X is useful and X makes sense for the level of abstraction, then introduce X as a feature, unless X can be easily produced by composition.

1

u/General_Purple3060 Jul 20 '26

Thank you for your reply; I benefited greatly from it.

If I had to summarize a possible criteria for when a library pattern should become a language feature, I would consider at least:

The pattern appears repeatedly in many mature projects.

It represents higher-level semantics, not just a commonly used function.

The compiler can make use of this information in ways that are difficult when it only sees the library implementation.

The difficult part is probably not whether something can be implemented as a library — many things can. The question is whether the language gains meaningful information by understanding the pattern directly.