r/ProgrammingLanguages • • Jul 23 '26

Will we see another fundamental programming language feature as revolutionary as the borrow checker?

That is I am mainly curious about compile time features that you design a whole language around rather than optimisations/features that could be applied to most languages. I am mainly inquiring about things that could offer additional robust safety/performance guarantees at compile time rather than runtime. Ideally not things that just offer similar effects to the borrow checker with less restrictive tradeoffs

61 Upvotes

127 comments sorted by

View all comments

Show parent comment

1

u/thedeemon Jul 29 '26

There is barely any language with parametrized modules.

In the one I'm making all modules are parameterized by default (i.e. if your module M imports other module like IO, when I import M I can provide some other implementation of IO to your M, and I can have different versions of M with different substitutions of modules it imports).

Is there any language other than Scala with both sum types and classes? Let alone type classes and abstract classes.

Swift has both algebraic types, OO classes and type classes (which it calls protocols).

2

u/EggplantExtra4946 Jul 29 '26 edited Jul 29 '26

Swift has both algebraic types, OO classes and type classes (which it calls protocols).

It makes sense, Swift is very well polished, but the point is that it should be a basic utility common to most languages, modern ones anyway, compositions/abstractions primitives like that are relatively language agnostic and paradigm agnostic and it sucks that only languages that make it one of their main design directives have them.

if your module M imports other module like IO, when I import M I can provide some other implementation of IO to your M, and I can have different versions of M with different substitutions of modules it imports

The module system that I'm designing works the same in that respect but I want my modules to do a lot more than that. It's already a powerful thing to compose modules with other modules or classes like that, but I think modules could also be great as a way to abstract over and compose metaprograms. My idea is to tie compile time execution, macro expansion and conditional compilation to module instantiatation. Each time a module is instantiated, the compile time code specific to that module is executed and it can use the module parameters to generate the exact data type definitions and the functions that manipulate them that you want, among the different configurations and options that the module provides.

For example, you could have a dynamic array module and the module arguments allow you to decide wether it grows by reallocation or grows in a segmented manner with multiple non contiguous buffers. The compile time code will have to generate different array types definitions depending on the module parameters but it will also have to adjust the array functions because the way to iterate over the elements for example will be different.

There is another layer in my design and other transversal aspects but their purpose is to manage code bases where you fully embrace the module instantiation metaprogramming I tried to expose above to its limit, so it's going to be too much for this post.