Rust is beautiful

I've invested some time to learn in detail about Rust, which means reading the excellent online book here. And it is beautiful. It makes me wish I could pause the world for a few years, to convert some 500,000 lines of C++ that exist under my purview into Rust, and continue from there.

Rust seems to take all the little design lessons I've learned in 20 years of C++ programming, and consolidates them into one language:
  • It's not best that everything is mutable by default, and const if the programmer points it out. It's healthier the other way around.
  • The fundamental string type is a sensible, immutable string slice (in Rust, a &str). This is great for zero-copy parsers, such as nom. Our code has had that for a decade – I named it Seq, or SeqPtr. C++ is adding std::string_view in C++17.
  • Elegant built-in variant with pattern-matching (in Rust, this is an enum). C++ is adding std::variant in C++17.
  • Type traits solve the problems of abstraction and generics, providing both static and dynamic dispatch, in an apparently more elegant manner than C++ inheritance (which is dynamic-only) or templates (which are static-only). Traits seem similar to concepts, which for now (unfortunately) remains a glimmer in Bjarne Stroustrup's eye.
  • Universal function call syntax. Something else Bjarne would like to introduce to C++.
  • Macros. Gawd, better macros (though not ideal – too templatey).
  • And of course, the crown – which sadly can't be brought to C++: compile-time memory safety!
If I were to start a programming career right now, I would use Rust. Hands down. I wish our major operating systems – let alone software we use – could be rewritten in it.


Limitations of Central-American pronunciation

OK, pet peeve.

We (probably) know how native English speakers have trouble pronouncing Spanish – and most other languages – in a way that doesn't sound silly. English uses Latin in legal contexts, and I personally cringe how it's pronounced. I was brought up on classical and ecclesiastical Latin pronunciation, and Latin pronounced by English speakers sounds like none of that. To me, it sounds most like pig Latin.

But interestingly, the vocal range of Central American Spanish speakers – in my experience, Costa Rican and Nicaraguan – is even more restricted. "How could that be?" you ask. "They can pronounce rolled Rs!"

Yes they can. But here are a few words that Central Americans I've met cannot properly pronounce:

EnglishCentral American
pizzaPronounced pixa.
shortsPronounced chor, as in "el chor" (masculine singular: short pants).
sushiPronounced suchi.
Marshall (the name)Pronounced Marchal.
MitsubishiPronounced Mitsubichi.
Yency (name)Pronounced Jen-see.
Jana (my wife)Pronounced either Hah-nah or Jah-nah, with a "j" sound.
Correct pronunciation, Yah-nah, has not been achieved by anyone.

To clarify – this is not just a style that speakers prefer, but can deviate from. They cannot:
  • Try to teach them to say "sushi". They keep repeating "suchi", with a clear "ch" sound.
  • Try to teach them to say "Yah-nah". They keep repeating "Jah-nah", with a subtle "j".
  • Try to teach them to say "pizza". They keep repeating "pixa", with a clear "x".
This is not even to mention the constant confusion between "b" and "v". In Central America, it's as though these two letters produce the same sound. They can't tell the difference.

Let me not get cocky, though. I can't really tell (or pronounce) the difference between č and ć.

And then there's Cantonese, where the word we'd spell maa has at least 5 very different meanings, depending on the tone of the "aa", and we'd catch none of them without training. :-)