2017-03-21

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.

2017-03-17

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. :-)

2017-02-08

"May prosper all the nations"

Jana recently wanted to share with the world – or at least, Facebook – the Slovenian national anthem, because it is a rare hymn that doesn't over-celebrate national pride; or call for indiscriminate bloodshed; but instead...
May prosper all the nations
who long await to see that day,
when over Earth's creation
all fight and strife shall be at bay;
when all men
shall be free;
no devils, only neighbors;
no devils, only neighbors 'll be!
Alas, that's not a widely recognized translation. In fact, it's very new. It's... my today's take on it. If it sounds a bit archaic, like in "all men"... Well, the original was published in 1848. It's supposed to be!

The official translation, though... By Janko Lavrin, from 1954... It starts like this:
God's blessing on all nations ...
Cue screams from Jana across the hallway.

"Who saw it fit to insert a god in this?!"

The whole point of Prešeren's stanza is coexistence and peace; free of religion and ideology. Yet Janko Lavrin chose to go with a concept that has historically divided and killed.

To his credit, Janko didn't know this was going to be a national anthem. He died in 1986.

Oh, and by the way: today is Prešeren Day.