I have nothing super finished, this is for fun (until I get time or funding!).
But I bet is far more reusable than normal code in most cases.
The reason is that the relational/array model has more values: https://www.infoq.com/presentations/Value-Values/, and combined with structural types and the power of relational operators you can eliminate a lot of cases where macros or generics come.
One major feature of a "values" language is that is naturally introspectable. Not just values, but types, and metadata. So this is NOT crazy:
mod People:
data Person:
name: Str
age: Int
data Customer: Person //not subtyping but `SELECT * Person INTO Customer`
active: Bool
end
mod Auth:
data User: People.Person //not subtyping but `SELECT * People.Person INTO Customer`
password: Password
active: Bool
data UserSafe: User ? deselect password // SELECT People.Person.*, active INTO UserSafe
end
fn print(p: Person ... ) // Accept anything that is `SELECT name, age FROM ?`, but critically, not remove the other fields, are just invisible here. This means you don't make type conversions in unnecessary cases
fn print_type_no_person(mod:Mod): String
let types = mod ?select as_data(this) != Some(Person...) // Anything is a relation, anything query
types ? union | into(String) //SELECT t1 UNION t2... + reduce()
In a lot of ways the Logic Programming languages are effectively relational (e.g. Prolog, Datalog, KIF) but the search behavior for relations that satisfy a query is a bit different than SQL-like relational languages.
On a previous project I embedded a SQL-like sub-language into a model language so that ETL pipelines and OLAP/OLTP processing could be generated to query aggregates and value lookups during inference. It is nontrivial to embed a relational language into another language without making some compromises but there are certainly contexts where it is quite useful. I think C#'s LINQ is a reasonable effort at this but I'm not much a fan of the rest of that language.
I'm not sure that it results in a good reusable code though. Any examples?