Quantum Mechanic

Content tagged Rust

Blog Walk Roundup 2015-12-10

posted on 2015-12-10 13:34:00

I spent a bunch of time collecting things around the web today. I think some of these are worth a read, so I'll link a bunch here.

Additionally, I participated in my first Massdrop and got my Code WASD Clears keyboard, yesterday. It's really nice to type on! If you're interested in playing that game, consider using my referral thing (https://www.massdrop.com/r/D2EFXE), because I like what they've done and I'd like a goodie box!

Neat blog comment policies




From Tim Chevalier's Blog:
If you comment, I have a few requests:

  1. Refrain from phobic or discriminatory speech, or speech that (in the words of s.e. smith) suggests that "people don't deserve autonomy, dignity, and a place in society."

  2. Refrain from comments that have the effect of silencing or derailing (see Derailing for Dummies for additional examples).

  3. As a corollary, refrain from questioning the existence of privilege or systematic oppression. There are many resources available online and offline for learning about these issues.

  4. Provide a name or pseudonym that reflects a consistent online presence (as opposed to so-called "throwaway" or "sockpuppet" identities).



Apparently, this is stolen from Christie Koehler's.




Rust stuff




At work, we've been looking at using Go for a rewrite of a major project. I keep trying to dig into it and have been annoyed by a bunch of things. I still think it could be a nice idea, there, but I have this problem where I get strong affinities for things pretty quickly and I've gotten pretty interested in Rust as, perhaps, and alternative to Go.

I've barely used it yet, but it seems to have nice easy package management, immutable data, a helpful compiler, a type system I can get behind, and whose documentation I can find! For some reason, I feel like it's been difficult to find good explanation of Go.

In any event, I've started working through Rust's book, after using the emacs setup shared here. This has been a long time coming, because I've been hearing about Rust over the years and keep meaning to try it. Reading the blogs above, it turned out that Tim Chevalier worked on Rust, so there was a handy link to a presentation to remind me to check it out!

Both languages are current better than the python 2.7 we use at work, because they both use unicode! Something that should just be standard at this point!

extern crate rand;

use std::io;
use rand::Rng;
use std::cmp::Ordering;

fn main() {
println!("Guess the number!");

let secret_number = rand::thread_rng().gen_range(1, 101);

println!("Please input your guess:");

loop {
let mut guess = String::new();

io::stdin().read_line(&mut guess)
.ok()
.expect("Failed to read line");

let guess: u32 = match guess.trim().parse() {
Ok(num) => num,
Err(_) => continue,
};

println!("You guessed: {}", guess);

match guess.cmp(&secret_number) {
Ordering::Less => println!("Too small!"),
Ordering::Greater => println!("Too big!"),
Ordering::Equal => {
println!("Correct!");
break;
}
}
}
}