I have no idea what this is trying to say, or what it has to do with the rest of the article.
Pipelining might be my favorite programming language feature
71–80 of 360 posts
Re: Pipelining might be my favorite programming language feature
#72 auto get_ids(std::span data)
{
return data
| filter(&Widget::alive)
| transform(&Widget::id)
| to();
}Re: Pipelining might be my favorite programming language feature
#73> allows you to omit a single argument from your parameter list, by instead passing the previous value I have no idea what this is trying to say, or what it has to do with the rest of the article.
Re: Pipelining might be my favorite programming language feature
#74Earlier quoted context omitted.
We might be able to cross one more language off your wishlist soon, Javascript is on the way to getting a pipeline operator, the proposal is currently at Stage 2 https://github.com/tc39/proposal-pipeline-operator I'm very excited for it.
I was excited for that proposal, but it veered off course some years ago – some TC39 members have stuck to the position that without member property support or async/await support, they will not let the feature move forward. It seems like most people are just asking for the simple function piping everyone expects from the |> syntax, but that doesn't look likely to happen.
I'm not a JS dev so idk what member property support is.
Re: Pipelining might be my favorite programming language feature
#75I'm personally someone who advocates for languages to keep their feature set small and shoot to achieve a finished feature set quickly. However. I would be lying if I didn't secretly wish that all languages adopted the `|>` syntax from Elixir. ``` params |> Map.get("user") |> create_user() |> notify_admin() ```
Re: Pipelining might be my favorite programming language feature
#76First example doesn't look bad in C++23: auto get_ids(std::span data) { return data | filter(&Widget::alive) | transform(&Widget::id) | to (); }
Re: Pipelining might be my favorite programming language feature
#77C# has had "Pipelining" (aka Linq) for 17 years. I do miss this kind of stuff in Go a little.
I 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-ref...
[1]: https://learn.microsoft.com/en-us/dotnet/csharp/linq/get-sta...
Re: Pipelining might be my favorite programming language feature
#78data.iter() .filter(|w| w.alive) .map(|w| w.id) .collect() collect(map(filter(iter(data), |w| w.alive), |w| w.id)) The second approach is open for extension - it allows you to write new functions on old datatypes. > Quick challenge for the curious Rustacean, can you explain why we cannot rewrite the above code like this, even if we import all of the symbols? Probably for lack of > weird operators like , , $, or >>=
> The second approach is open for extension - it allows you to write new functions on old datatypes. I prefer to just generalize the function (make it generic, leverage traits/typeclasses) tbh. > Probably for lack of > weird operators like , , $, or >>= Nope btw. I mean, maybe? I don't know Haskell well enough to say. The answer that I was looking for here is a specific Rust idiosyncrasy. It doesn't allow you to impo…
You probably noticed, but it should become a thing in RFC 3591: https://github.com/rust-lang/rust/issues/134691
So it does kind of work on current nightly:
#![feature(import_trait_associated_functions)]
use std::iter::Iterator::{filter, map, collect};
fn get_ids2(data: Vec) -> Vec {
collect(map(filter(Vec::into_iter(data), |w| w.alive), |w| w.id))
}
fn get_ids3(data: impl Iterator) -> Vec {
collect(map(filter(data, |w| w.alive), |w| w.id))
}Re: Pipelining might be my favorite programming language feature
#79 fn get_ids(data: Vec) -> Vec {
collect(map(filter(map(iter(data), |w| w.toWingding()), |w| w.alive), |w| w.id))
}
to fn get_ids(data: Vec) -> Vec {
data.iter()
.map(|w| w.toWingding())
.filter(|w| w.alive)
.map(|w| w.id)
.collect()
}
The first one would read more easily (and, since it called out, diff better) fn get_ids(data: Vec) -> Vec {
collect(
map(
filter(
map(iter(data), |w| w.toWingding()), |w| w.alive), |w| w.id))
}
Admittedly, the chaining is still better. But a fair number of the article's complaints are about the lack of newlines being used; not about chaining itself.Re: Pipelining might be my favorite programming language feature
#80I'm personally someone who advocates for languages to keep their feature set small and shoot to achieve a finished feature set quickly. However. I would be lying if I didn't secretly wish that all languages adopted the `|>` syntax from Elixir. ``` params |> Map.get("user") |> create_user() |> notify_admin() ```
I feel like Haskell really missed a trick by having $ not go the other way, though it's trivial to make your own symbol that goes the other way.
users
& map validate
& catMaybes
& mapM persist