A Harsh Criticism of Rust

I really like the rust programming language.  It does so many things elegantly, beautifully, concurrently and safely.  I consider myself a rust-fanboy.  But what's not to like?   Here is my list of terrible things about rust (or perhaps computer science in general.) 

  1. That CS disconnect issue of 0..10 being what humans think of as First=1  to Tenth=10 and what computers think of the nine elements 0,1,2,3,4,5,6,7,8,9.  There are a considerable number of online rust help responses where a stymied rust beginner asks to loop between 1 and 10 and the helpful reply is a iteration of 1..10 (which is 1,2,3,4,5,6,7,8,9 with 9 elements) or 0..10 (with ten elements but does not include 10).  Rare is answer 1..11 given as they way to count between 1 and 10 in rust.  Insert hundreds of variant examples here involving for loops, slices , iter() or rand.   Once you start seeing the beginners and helpers make this mistakes in hundreds of different ways - you start to see it almost everywhere.  I conclude all humans have some weakness for this kind of lingual/CS bait and switch.  

    I count myself among those with a weakness for this kind of this as I recently wrote a random vec (list) subsample function that would quite infrequently return a shorter list than I expected.  

    My proposed fix?  Change English forever so kiddies think of zero as beginnings and count their nine fingers.  Maybe write a perception filter for VS code so 1..10 appears as 1..10(counts 1 to 9)?  Add syntax sugar in rust so that fingercounting!(1..10) magically converts the embedded iteration?   Burn all the computer languages to the ground that approach this differently?
  2. That rust thing where complex mathematical ideas become deeply layered and indecipherable.   This is a human thing, but mix type casting mixed into something already a bit tricky any you get deeply murky expressions.  C lets you subtract 1 from “B” and get “A”, probably… C sets a terribly unsafe and unpredictable example, but there are moments when I just wish I could just type a=(b+c*d-e)%65536.  Rust does it right by making this hard and forcing you to do conversions explicitly but the result is usually a parenthesis maze or sequence of variable conversions that obscure the idea:
    let conv_b = b as f64;
    let conv_dc = (c as f64) * d;
    let conv_e = (conv_b  + (conv_dc as f64) - e) as usize;
    let a:u16 = (conv_e%65536 ) as u16;
    Hardly can see the math for the type casting.. what were we doing?  Yes rust is proably doing this the right way, but somehow I'm not certain a rust macro wouldn't make fewer mistakes than I already do.
  3. Passing generic Vectors Vec to a function.  Rust stands in praise of don’t repeat yourself (DRY) code writing… but not when it comes to random subsampling a population represented by a vector... I don't have a lot of hope that you can write a generic population polling function that works with on Vec<integers>, Vec<floatingpoints>,  Vec<mydatastruct>.   I should get over myself and just use hashmaps and boxes to store data I guess. 
  4. Rust has certain concepts that are new and really conceptual.  In part from new ideas like ownership and no garbage collection.  When I wrote a rust prime number toy, there was a CS programming pattern that amounted to "learn, do, transfer new knowledge across all CPU cores and repeat to extend knowledge base." That sounds simple, and the prime number program wasn't complex.   But ownership did force me to approach the problem in a different way.  Certain rust paradims are still pretty opaque to me  - like returning boxed closure trait objects.   Others make me feel like coding rust walks me around some invisible idea or pitfall that was deemed "not the rust way."  Its hard to explain, but there is a rust way and you learn it even if you quite intend to.



Rust's rand::distributions

Rust's rand crate, a external library for generated randomness, moved from 0.5.5 to 0.6.0 and wow... what new goodies!  There are now ways to generate random distributions that follow a number of probability distributions.  Wow... so many non-uniform probability distributions (Normal, binomial, bernoulli, LogNormal, Poisson, Exp, Gamma, ChiSquared, StudentT, FisherF) are available hinting at genius and insanity obsession at once.  I love it!

Yes, actually love it.  Conceptually at least... still playing with it.  The big book of random ( contends rand 0.6.0 isn't crypto grade, but I'll contend it is certainly aiming for full featured.  Slight worries about compile times and new version bloat... Historically rust doesn't seem to be great about take only what you need.  Then again, Rust's cargo library version manager makes my point mostly moot, opt in to an earlier version as you wish.  Almost pure goodness!





Rust on Arduino

This fall I got a fun little Hallowing from Adafruit and thought I'd try to cross compile something in Rust Lang ( for it.  Wow that board is has 48Mhz speed demon with 32 Kb of RAM and and 256k flash rom program memory plus a !8MB! SPI flash drive loads and saves... and a 8192 color 128x128 dot TFT display with 4bit blues and reds and amazing 5bits for vibrant greens.  Easily twice the computational power of your average 1976 mars lander!   

The sorry state of the Rust programming language on Arduino right now is "I am not smart enuff to make it work".   I blindly hope that's changing... perhaps I am merely not patient enough.     I really thought rust+arduino might be a happy couple soon, not all that long ago, and the last AVR Rust language fork was released almost simultaniously with this post so perhaps they are yet destined to be together. (  

I'm a fan of Arduino C, and a fan of Rust.  Rust would be a strong choice for hack hardened electronics - the language is designed to be resistant to memory attacks and undefined states - weaknesses frequently exploited in compiled C.  Executable rust programs run nearly as speedy as C or faster if you can leverage low bar multithreading.)   If your next router was running rust, a good number of security vulunerabilities might just not exist in the way they do now.  

My present barriers to entry:

(1) RUST executable sizes are larger than ARDUINO C.  With effort not double, but still harrowing for a hallowing 32kb system.  

(2)  I don't presently have projects that really needs Rust's security or parallelism even if I would prefer to write in Rust.  If I take up programmed robotic painting again, a Raspberry Pi with multiple coresc and configured with 4mb of (slow) virtual memory should work for the build on device.  

(3) No Rustified Arduino cross compile IDE exists so far as I can tell, at least nothing like the sweet sweet  Long arcane configurations and rustc command lines should not deter me, but do, especially when I follow examples and still get "That probably worked a few versions ago type" errors.

(4). Did I mention the "that probably worked a few versions ago with a specific unstable AVR fork off the main rust nightly branch " type errors?  Good news, there's a better way and I just don't seem to be up to speed yet.  Yea.  And I'm reaching for that single thread slow ass Ardino C IDE to do a library search again (The cross platform Arduino C IDE really is execellent in so many ways... super kudos to the Arduino team of Massimo Banzi, David Cuartielles, Tom Igoe and David A. Mellis.  If only they each loved rust... soft wet weeping sound ensues along with the the unformed thought "if only Claude Monet had painted entwined lovers atop just one of his usual pastoral haystacks in contented shades of iron oxide and colbalt turquoise.")

I do want to see Rust come to Ardino, and since it barely, almost, sort of, sputterlingly, has- maybe I should add "and BE EASY!"   I really think Arduino+Rust would make the world better.    I like C, but how much of the worlds computational security woes come from that code base?  Perfectly tallented C programmers write wonderful things that compile and run and still have hidden hordes of gremlins inside.   I really do hope the state of Rust on the Arduino platform changes soon... I'm not quite ready to jump in and swim yet.


Ugh. CNN Reports Spin News.

Link: index.html "Police officers in the US were charged with more than 400 rapes over a 9-year period"

This really sounds bad, even a police rape epidemic.  Far too many traffic stops resulting in victimization.  But how do police compare in this regard to the remainder of the population? 

CNN reports 405 rapes over 9 years by law enforcement officers.  Given a estimated US population of 327,445,198 (Google) people, and an estimated police force of 422,869 officers (Statistia US employment records) by my estimation there were total 153809 successfully prosecuted rapes in the last rolling calendar year in the United States.  This is a dismally low portion of the total number of rapes, but please accept that the number can not reasonably be argued to be even lower than the values that follow.

If police were committing this crime at national rates, roughly 1892 events would be recorded in the 9 year period.  So I conclude law enforcement is not offending at a rate higher than the general population in this regard.   Even if the police force is taken to be the 120,000 full time officers they offend at rates similar to the general population - which is actually still better than average men given strong male bias toward both the crime and the law enforcement career choice.

By in large, the police mostly suck because their job sucks.   My last happy interaction with one was "help find a likely teen suicide in a large park but if alive report to the professionals and do not engage" and I did and despite a long blood trail, it was not completely terrible until the teen's father showed up, and in random dark moments that father still haunts my memory more than his child.  I can't constrain what I saw into words, and won't judge.  Praise the Lord that isn't my day to day.  Police suck because far too many people suck.  But police don't suck because they commit rape at a rate higher than the general population.  


The Nice and Accurate Prophecies of Agnes Nutter

Very nice book, full of good omens.  Highly recommended.  In an effort to chanel Agnes, I got this:
Kavanaugh, in victory dress, moves the court toward self enscribed rectitude.
Phyrric need named the crime and the deed, truth or lies are nobody's guess. 
Justice will take blindfold and weights, and hand down many a rule.
Remember her name, the rage and the shame, a burden for many more years.  
Hmm... I didn't explode... so maybe I didn't actually chanel Agnes.   I clearly channel the Nutter not, for my words are  those of this century and not 1672.  Still don't know why she let the town folk burn her as a witch when she had the foresight to pack her peticoat with gunpowder...