Why Rust for TRex?

by simbo1905

My programming career started out with C and C++ last century. I then switched to Java for a long while then finally moved onwards and upwards into Scala. Along the way I have put JavaScript into production and written a JavaScript authentication library others use. There was also a bit of PHP on the side which I don’t draw attention to. Why not return to C++ for a systems programming language port of Trex? Or try D? Why Rust? 

I am sure that a lot of folks would say that my languages history makes me a blue collar and curly-brackets kinda guy. Scala folks would tell me to go learn a Haskell for the greater good. Someday I will. At the moment though I am looking to kick the tires on a systems language closer to the metal. Something more in an industrial space than an academic one.

So why not C++ for TRex? I worked for someone who transferred away from a large Scala program onto a cutting edge C++ team. So I am aware that that language has had a reboot. Surely back-to-the-future with C++ would be the pragmatic way to go? But I couldn’t face the risk. The risk that I would learn how to do things in new-world C++, then find myself in a big shop of C++, to find all the legacy baggage of C++ dragging things down. Even the initial question of which toolchain to install and whether to go with GCC or clang seemed like a step back to the bad old days. The bad old days where choice is the Hobson’s choice of picking between vendors [1]. Shudders.

New languages that grow up in the age of the internet now live in a world where having competing compiler vendors does not make any economic sense. Compilers are extremely expensive to mature. An ecosystem with multiple compilers is automatically constrained in what it can achieve by the crushing costs. A single open source compiler such as Scala can advance faster. Older languages with multiple vendors mediated by a standards committee are automatically hamstrung. What is touted as a virtue is “choice”, yet it is actually the vice of “duplication of effort”.

Standards driven languages are like a bazaar of competing vendors where as a developer have to haggle over commodity goods. Buyer beware. Internet-native programming languages are like start-ups striving for a breakthrough with differentiated products.

So why not D? The fact that D has been around since 2002 but hasn’t taken off is something that it’s architect admits is a problem for many companies. I did come across D when it was about the age that Rust is now. I liked what I saw. Yet at that time Java was going from strength to strength. At the time I thought of D as a better C++. A decade later C++ now is a better C++. This doesn’t suggest that D is about to have a breakthrough in adoption. It seems more like the startup who is past its shelf life and who’s wave has passed. Still, I may be wrong on that which would be a very good thing.

And Rust? Well, I like the fact that Mozilla Labs have started replacing bits of Firefox with it. Having built a browser out of C++ they should be fully aware of the strengths and limitations of that language. Rust as the challenger language within the Firefox ecosystem has to be competitive with the incumbent C+++. They are competing head-to-head. In my experience, Scala is competitive with Java exactly because it constantly goes head to head in the same firms. It is also a symbiotic relationship in that Java can adopt popular features that Scala and Kotlin pilot first. The new languages offer a genuine choice and are forced to innovate. I have had a lot of success with Scala so kicking the tires with Rust seemed like a good idea to me.


[1] If you want an example of what I mean see page 2 paragraph 2 of this C/C++ memory model paper which explains how gcc and clang do different optimizations which may invalidate the C11 memory model.