Forging SQL from Rust
pgx creates PostgreSQL extension SQL definitions that bind to Rust.
PostgreSQL offers an extension interface, and it's my belief that Rust is a fantastic language to write extensions for it. Eric Ridge thought so too, and started
pgx awhile back. I've been working with him to improve the toolkit, and wanted to share about one of our latest hacks: improving the generation of extension SQL code to interface with Rust.
This post is more on the advanced side, as it assumes knowledge of both Rust and PostgreSQL. We'll approach topics like foreign functions, dynamic linking, procedural macros, and linkers.Continue reading...
Optional Arguments in Rust
Exploring Rust UX and API design.
When designing an API for your crate one topic which can come is how to handle optional arguments. Let's explore our
Options in Rust!
The Path to Rust on the Web
Recently there has been quite a bit of talk about WebAssembly, a new format for code for the web. It is a compile target for languages like C and Rust that enables us to write, and run, code from these languages in our browser.
Disclaimer: WebAssembly is stabilized, but most implementations are not. The information contained here may become out of date or be incorrect, despite working at the time of writing.
Setting up a Rust Development Environment
In this post we'll be discussing one way to set up your machine for Rust development. There are different ways, particularly related to the text editor, so feel free to skip what is irrelevant to you. We'll focus on:
- Setting up Rust via Rustup.
- Valuable tools like
- Configuring VS Code for Rust.
- Debugging with the command line and inside of VS Code.
- Using different compile targets.
Everything we do should be functional on both Linux and MacOS, on Windows your mileage may vary. I, unfortunately, don't have a Windows instance to test on.Continue reading...
The Future with Futures
Recently there has been a lot of progress in the Rust language towards a robust asynchronous stack. In this article we'll take a look at what these things are, take a tour of what's available, play with some examples, and talk about how the pieces fit together.
We'll get started with the
futures crate to start, move on to
futures_cpupool, and then eventually to
tokio. We will assume you have some knowledge of programming, and have at least thought about trying Rust before.
Pretty State Machine Patterns in Rust
Lately I've been thinking a lot about the patterns and structures which we program with. It's really wonderful to start exploring a project and see familiar patterns and styles which you've already used before. It makes it easier to understand the project, and empowers you to start working on the project faster.
Sometimes you're working on a new project and realize that you need to do something in the same way as you did in another project. This thing might not be a functionality or a library, it might not be something which you can encode into some clever macro or small crate. Instead, it may be simply a pattern, or a structural concept which addresses a problem nicely.
One interesting pattern that is commonly applied to problems is that of the 'State Machine'. Let's take some time to consider what exactly we mean when we say that, and why they're interesting.Continue reading...
A Rust Heroku Buildpack
I'm happy to introduce the first stable version of my Rust Heroku Buildpack!
Just looking to get your hands dirty? Look here.
The project was a really interesting learning experience about how Heroku does things, on
bash scripting, and about
multirust, which I'd not used before but now am quite a fan of! (I previously just
rustup'd the newest nightly every few days.)
Understanding Over Guesswork
Evolving How We Learn Systems with Lessons from Programming in the Large
Some bugs are just that+++a one off. A wayward moth that just happens to be innocently fluttering through the wrong relay at the wrong time. But some kinds of bugs aren't like that. Instead, they have risen to superstar status, plaguing veterans and newcomers alike. But what if these aren't bugs at all? What if they are actual deficiencies in safety and robustness offered by the C programming language as a consequence of the degree to which guesswork is introduced. Here we explore a more explicit approach to systems level programming supported by Rust, which we believe will better promote understanding of design intent, and eliminate some of the guesswork. Guided by a set of classic, but still relevant, bugs identified almost 15 years ago by Engler, we consider this in the context of the new generation of students learning about systems in a typical OS course, where students often first encounter these deficiencies.
Photos: San Fransisco Trip
A selection of images from my trip that I thought I'd share with the world.
If you want to use one of these for anything at all, just fire me an email and ask!
The Raft-rs Rust Meetup
The next few weeks are full of excitement and busy-ness! First up is the Meetup in San Fran (See our planning). I can't wait! It will be so fun to meet many people I've already met in IRC and through the community!
If you'd like to do something, or show me around the city, let me know! I've never been to the USA before, let alone San Fransisco.
After that I'm moving into a new place! A friend and I landed a great location for the next year and we're looking forward to the changes ahead. Once I'm settled in classes will be starting and I have a very busy term ahead!Continue reading...
Raft Progress & Examples!
Raft: Tooling & Infra Update
In preparation for the forthcoming 0.0.1 release of Raft we've taken several forward steps to improve our (already pretty darn cool!) tooling and infrastructure. If you attempt to set up any of these on your own and have issues let me know! I'd be more than happy to help. You can find our
Raft: New Crates!
We've been resoundingly busy with our Raft implementation after a brief period of calm in the early summer! I'll be posting a few bits over the next weeks to help people both learn Rust, and learn about Raft!
As a result of Raft development two new crates have been put together for general consumption! Both of these are macro-centric and lead mainly by James.Continue reading...
Reading Rust Function Signatures
In Rust, function signatures tell a story. Just from glancing at the signature of a function an experienced Rust user can tell much of the functions behaivor.
In this article we'll explore some signatures and talk about how to read them and extract information from them. While exploring, you can find many great function signature examples in the Rust API docs. You can play around on the Playpen.
This article assumes some knowledge of Rust, glossing over a bit of the book should be quite sufficient if you are lacking that but have programmed before.Continue reading...
Collecting Results from Collections
I've been playing around with a new project that uses a lot of collections of results, for example
Vec<Result<()>> and asked some folks on Rust if they new a good way of transforming this into a
.collect() can do it for you!
A Journey into Iterators
One of my favorite features of Rust is iterators. They are a fast, safe, 'lazy' way of working with data structures, streams, and other more creative applications.
You can play along on http://play.rust-lang.org/ and by browsing here. This article is not a subtitute for the documentation or experience.
Raft: Status Update
Learning Cap'n Proto RPC
Rust, Travis, and Github Pages
Rust is probably my favorite programming language (as the contents of this site suggests). My interests in networks, development operations, and systems programming align strongly with Rust. They're pursuing the trifecta: Safe, Fast, Concurrent. It's been a great learning journey for me so far and I learnt to write better code in all languages.Continue reading...
Getting Acquainted with MIO
MIO is a lightweight IO library for Rust with a focus on adding as little overhead as possible over the OS abstractions.
Raft: A First Prototype
Raft: Progress on the Log
A lot has taken shape in the codebase. It still will panic at
unimplemented!() about 300ms after you start a node, but "That's a feature!"
Note: All interfaces and code are not final, and are for educational and interest purposes.
First look at Cap'n Proto in Rust
Cap'n Proto is what's billed as a 'Data Interchange Format' and 'Capability-Based RPC System'. Or a 'Cerealization Protocol'.
Raft Experiences and Repo Made Public!
Raft So Far
I've been working quite a bit on my Raft implementation over the last few days and I must say it's been quite a pleasure to work in Rust, which recently released it's 1.0.0-alpha.
It takes the work out of needing to serialize and deserialize data, it enforces data safety, and it's type checking is incredible. I'm very quickly able to make a change, build it, fix the errors the compiler catches for me, and build again, then test. So far the only times my tests have failed after a successful build was when I was accidently disgarding one of my channels.Continue reading...
Raft in Rust
I'm currently working on implementing the Raft Distributed Consensus protocol in Rust.
This is a project I'm doing for my CSC466 class at the University of Victoria, and I'm hoping to use it as part of one of my projects for CSC462.
At the end of the project I plan to release it as MIT licensed code. Please stay tuned...Continue reading...
Parsing Arguments in Rust
Longest Common Increasing Sequence
A really 'cute' problem popped up in our Data Structures & Algorithms homework and I wanted to write about it.
If you're in the class this will obviously ruin the fun, so read it later, after you're done!
Command Execution in Rust
One of my projects over the upcoming semester is to explore the Linux boot process and the job of the init (initialization) system. The init system is considered PID 1 and is responsible for a significant portion of userspace functionality. Common init systems on Linux are OpenRC and systemd. One of the key parts of an init system is to spawn new processes, like in command shell.
Executing child processes may be useful to any number of programs, but common applications include:
- Init systems
- Interfacing with command line applications
Option Monads in Rust
One common monadic structure is the
Maybe in Haskell and other languages) type. This can be seen as an encapsulation type. Consider a function which may fail to produce a meaningful value for certain inputs. For example,