Rust beginner notes & questions

Let my try and explain why I'm focusing on it so much: because it's a great example. It's one of many. It's not the reason I abandoned Rust, it's just one paper-cut out of hundreds.

Based on all of the Rust std lib code that I've seen, and reading between the lines of statements like "I don’t think C++ is doing anything about this (Pipeline) either." that Rust seems like a "safer C++ for people that at their heart just wanted C++ 2.0 without the C legacy".

I learned C, used C++ productively for a decade, and then moved past it and I'm not going back. If someone handed me a "C++ 2.0" with safe memory management it would be still unproductive, repetitive, and fragile compared to any truly modern language.

This has nothing to do with being a platform language -- people have written operating systems in C# -- and Both Java and C# are used in constrained, embedded scenarios.

This has nothing to do with POSIX I/O conventions.

What I'm saying is that the Rust team have come up with a procedural language with most of Haskell's wonderfully advanced and elegant language features and then decided not to use it. Instead of immediately embracing an abstraction that:

  • Is composable without incurring repeating costs
  • Is extensible to non-copy types, not just u8
  • Is more elegant to use for common, practical use-cases.

The arguments I'm hearing are along the lines of "oh no... we would have to allocate a buffer in the std lib. That's just too much! Do it yourself!". Well... no. I won't. Why would I, when I can just pick up a language that has an API that does zero copy by default -- quite often outperforming Rust out-of-the-box -- and also has a bunch of stuff written around it so that I don't have to write my own shims between whatever the netbricks guys did and the rest of the ecosystem.

The code @BurntSushi horrifies me. He had to write code to detect encoding, do the decoding for a stream, and he has his own code for handling decompression. These aren't special cases. This is core to the type of programming Rust was originally designed for!!! Encoding detection, character encodings, switching between stream handlers (some of which decode to UTF-8 and some that pass-through), and decompression is all in common with HTML parsing. This is core stuff for something like Servo, the project for which the language was invented. But all of this had to be reinvented for a grep tool. What the ..?

I admit that the C# guys also wrote their new I/O API to be u8 only, but that's because in C# they have no choice. The template features of the language aren't powerful enough to support the more general case because there's no equivalent of traits.

Rust the language is not constrained in the same way, but its core developers act as if they are.

1 Like