r/Compilers • • Jun 12 '26

Code Readability Comparison

/r/programmer/comments/1u3x0z8/code_readability_comparison/
0 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/Mean-Decision-3502 Jun 12 '26

Thank you for your great Rust support! I don't use Rust at all.

Expression like this:

darr.iter().map(|&i| -> i64 { i.into() }).sum::<i64>()

Might be short and powerful, but I find it hard to read. You have to focus on small symbols sitting dense. This is pretty much write-only for me.

Of course a language or a library can have support doing the whole summing with one short line, but it is good to see what is when you have to process the data one by one.

1

u/matthieum Jun 13 '26

Expression like this [...] Might be short and powerful, but I find it hard to read.

It definitely is.

As the lengthy comment above mentions, this is hitting a particular bad spot of the standard library & type inference algorithm forcing extensive type annotations.

Ideally, we should be looking at darr.iter().sum() and calling it a day.