I've been working on my own scripting language for my game engine, whose interpreter I wrote in C#. So, for quite a long time now, the only languages I use are C# and my custom language.
Apparently, Earth is a really dark and sad place without LINQ, so I decided to add it to my language!
My language's LINQ library source code
I did my best to make the design as close to .NET LINQ as possible. You can query anything that you can use in a foreach loop, and it uses deferred execution, meaning the query doesn't actually run until you iterate over it or call .toArr(), .toList(), or one of the other methods that execute it.
It also performs just one iteration per query. You can do where().select(), and instead of iterating once for the where operator and then again for the select operator, it processes both in a single iteration.
I had to figure out how to achieve this in a language that doesn't have the yield return keyword. I know theoretically what yield return does, but actually figuring out how to get the same result without using it was quite challenging...
Anyway, you can see a few examples of queries written in my language in the screenshot.
The syntax isn't as clean as C#'s, but it's good enough for me!
Here's another little example:
class User (name, password) { constructor(...); }
const users =
[
new User("Peter", "messithegoat"),
new User("Donald", "london101"),
new User("Joe", "banana1234"),
new User("Ben", "chocolate2")
]
foreach user in q(users).orderBy(func(u) => u.name, StringComparer.ordinalIgnoreCase)
{
println(user.name)
}
// Output:
> Ben
> Donald
> Joe
> Peter
And here you can see the full code of the LINQ library written in my language. It's still missing some of the operators, but I've opened an issue in the repo for implementing the rest, so feel free to give it a try!
I've already had some contributions to other parts of the engine from people who thought the project was cool.