News for hackers. Stuff that matters.
Re:Hecto: Build your own text editor in Rust by shrimp_emoji on Monday January 18, 2021 @09:45PM (#25829409)
Haha. True! I knew about D, but I forgot about it[0]. (I also know extremely little about it.) ;w; I feel bad.

That code is as beautiful as it is incomprehensible.

0: https://youtu.be/_P5BOietpDY

Re:Hecto: Build your own text editor in Rust by ibraheemdev on Monday January 18, 2021 @10:43PM (#25829759)
I agree. The D program is cool, but pretty cryptic. A simple Rust version [0] is only 21 lines yet much more readable in my opinion. I'd take readability over a couple less loc anyday.

[0]: https://play.rust-lang.org/?version=stable&mode=debug&editio...

Re:Hecto: Build your own text editor in Rust by littlestymaar on Tuesday January 19, 2021 @02:15AM (#25830816)
The `op.parse()` at line 7 was a little hard to understand for me at the beginning. Only a few seconds after, I understood it was `op.parse::<f64>()` with the type parameter inferred from the type of `stack`, but I think it's easier to understand with the explicit type annotation (the turbofish) than without it.
Re:Hecto: Build your own text editor in Rust by mhh__ on Monday January 18, 2021 @11:01PM (#25829858)
You miss the point of the original one. When I wrote it the idea was that it is functionally pure and guaranteed to be such by the compiler (the annotation was removed because readln is not pure for obvious reasons).

Most uses of loops break down to map, fold, or similar being able to use them cleanly can avoid a lot of bugs and API plasticity.

Re:Hecto: Build your own text editor in Rust by Measter on Tuesday January 19, 2021 @12:18PM (#25835788)
There's nothing stopping you from doing a functional style in Rust, neither: https://play.rust-lang.org/?version=stable&mode=debug&editio...

There is a function on nightly that would make line 16 a little nicer, but oh well.