Here are some cool links to other Stuff. Enjoy, or Don't. I'm not your boss.

Iterating Fast in Rust

One of the most common complaints I think we hear about Rust is that you fight with the compiler, or it's to hard to just whip out some code in order to test something really quick. Although I'm not arguing that there is a portion of time where when you don't know the rules it does seem like you're fighting with it left, and right. There is light on the other side. There is a point that is completely reachable where you can iterate fast with Rust. There is a point where we can write our bad development code when we just want to test something out.

I know it probably seems weird that I'm advocating for Rust here, because it allows us to write bad code. There seems to be the perception that if you write your code in rust it has to be perfect the first time otherwise the compiler will yell at you. Take it from someone who has written bad rust code, and will probably continue to write bad rust code every time he wants to test something out real quick.

To help showcase this point I'd like to point to the original commit on a project I built in less than a night. text-to-polly-ssml. Which at the time of writing this (although I'm doing some work on it). Is one of the hackiest parsers I think I've ever written. It's goal was simple. Given an arbitrary body of text with some potential formatting I wanted to create SSML (Synthetic Speech Markup Language) v1.1 that was compatible with AWS Polly.

Specifically I wanted this for a chat bot I run in our works Slack gwiz-bot. Who at the time did have a polly integration, but it was text only. I wanted to be able to support the wide range of SSML that Polly supports. Getting things like whispering, higher/lower pitches, and telling him to spell out a word. Without typing XML into slack everytime I wanted to say something.

Enter the aforementioned text-to-polly-ssml. This takes in a String, and returns SSML Output with the full support for tags/attributes that Amazon Polly Supports. If you can do it in the SSML Console, you can do it with text-to-poly-ssml. It supports a fairly naive syntax (and the parser at this point is really really bad).

For a taste of what it looks like take the following text:

You say, ${phoneme|alphabet=ipa|ph=pɪˈkɑːn} pecan ${/phoneme}

Would generate the following SSML:

<?xml version="1.0"?>
<speak xml:lang="en-US" onlangfailure="processorchoice" xmlns="" xmlns:xsi="">
  <p>You say, <phoneme alphabet="ipa" ph="pɪˈkɑːn"> pecan </phoneme></p>

This gives me the ability to just use normal text if I want too, while also allowing people to take advantage of SSML if they know what it is, and are so inclined. You don't have to go memorize a whole bunch of SSML syntax, you can just write some Text, and have it come out the other side.

If you just take a look at this code, you'll realize there are tons of pitfalls in it, I mean just look at the first little bit of the parsing code:

for line in to_parse.lines() {
    if line.is_empty() {
    let mut is_first: bool = true;
    for word in line.split_whitespace() {
      if word.is_empty() {
      if !is_first {
        try!(xml_writer.write_text(" "));
      } else {
        is_first = false;

If you've written a parser you can probably see many problems. Rust doesn't magically help you write perfect code. this code compiles, passes test cases, and has pretty decent benchmarks. However this is still bad code, and has a number of defects from a usability and technical standpoints. The difference? This code is safe. I know I'm not going to segfault, I know I'm handling all possible cases (and not accidentally missing something). Sure my my code is safe, but that doesn't automatically mean my code is good in any stretch of the word, or even close to being used in a production setting.

If you look through the code I'm sure you'll notice defects, shortcuts, and more. The point is if you're not using Rust because you feel like you can iterate, or test things quickly you should take another look. Rust will even be better because with your safe code, it's much easier to give demos without worrying about potential things going wrong. You know you've handled each case, or you have the great unimplemented!() macro.

Rust isn't keeping you from iterating quickly, don't let it be perceived that way. Rust is a powerful language where you can iterate quickly, refactor with confidence, and write some really cool code. Let it have your back, and continue doing all the things you'd normally do.

Beginning the New Year

Actionable Stacktraces in Rust