3 ms·
C# has had "Pipelining" (aka Linq) for 17 years. I do miss this kind of stuff in Go a little.
by osigurdson 2y ago
C# has had "Pipelining" (aka Linq) for 17 years. I do miss this kind of stuff in Go a little.
- vjvjvjvjghv 2y agoAgreed. It would be nice if SQL databases supported something similar.
- NortySpock 2y agoI've used "a series of CTEs" to apply a series of transformations and filters, but it's not nearly as elegant as the pipe syntax.
- sidpatil 2y agoPRQL [1] is a pipeline-based query language that compiles to SQL. [1] https://prql-lang.org/ https://prql-lang.org/
- bob1029 2y agoI don't see how LINQ provides an especially illuminating example of what is effectively method chaining. It is an exemplar of expressions [0] more than anything else, which have little to do with the idea of passing results from one method to another. [0]: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/expressions https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
- delusional 2y agoYou might be talking about LINQ queries, while the person you are responding to is probably talking about LINQ in Method Syntax[1] [1]: https://learn.microsoft.com/en-us/dotnet/csharp/linq/get-started/write-linq-queries#standard-query-operator-extension-methods https://learn.microsoft.com/en-us/dotnet/csharp/linq/get-sta...
- hahn-kev 2y agoSo many things have been called Linq over the years it's hard to talk about at this point. I've written C# for many years now and I'm not even sure what I would say it's referring to, so I avoid the term. In this case I would say extension methods are what he's really referring to, of which Linq to objects is built on top of.
- osigurdson 2y agoI'd say there are just two things: 1) The method chaining extension methods on IEnumerable<T> like Select, Where, GroupBy, etc. This is identical to the rust example in the article. 2) The weird / bad (in my opinion) language keywords analogous to the above such as "from", "where", "select" etc.
- osigurdson 2y agoExample from article: fn get_ids(data: Vec<Widget>) -> Vec<Id> { data.iter() // get iterator over elements of the list .filter(|w| w.alive) // use lambda to ignore tombstoned widgets .map(|w| w.id) // extract ids from widgets .collect() // assemble iterator into data structure (Vec) } Same thing in 15 year old C# code. List<Guid> GetIds(List<Widget> data) { return data .Where(w => w.IsAlive()) .Select(w => w.Id) .ToList(); }