StackLang, part 4: an interpreter. Here we go again!
This time, the goal is to actually get code running
StackLang, part 4: an interpreter. Here we go again!
This time, the goal is to actually get code running
StackLang, part 3: parsing. This is going to be the most complicated one thus far! Onward.
StackLang, part 2: lexing.
It’s quite often the simplest part of implementing a programming language (although parsers for s-expression based languages come close), but it’s still something that needs done. So here we go!
I enjoy writing programming languages. Example: Tiny. Let’s do that again.
This time, StackLang:
{
@[n fact]
1
{ n 1 - $fact fact n * }
N 1 <= if
} @fact
5 $fact fact writeln
Bit of gibberish there, I suppose, but the goal is to write everything in a postfix/stack based model. So n 1 - $fact fact n *
is equivalent to fact(fact, n - 1) * n
in a more traditional language.
Over the next few posts, I hope to write up where I am thus far and what’s next.
Another Redis in Rust series. It’s really starting to come together now!
In this post, updating the state to store expiration times + a thread to handle said eviction + the implementation of a small pile more of the general Redis functions.
And I’m back. It’s been a busy month with the [Genuary]([Genuary 2023]) series and life in general, but I’m still thinking about Redis in general 😄.
Up this time, let’s see what the official redis-cli
app does when talking to our client and actually start handling some commands. Specifically, the very basic commands: SET
and GET
. With that, we would actually have a (very very basic) keystore up and running!
Okay, we’ve got a server and we can ping it. Let’s actually make a simple client, so I don’t have to do funny things with echo any more. Specifically, let’s make a REPL!
Following up from Cloning Redis in Rust: RESP [Part 1], we can parse the protocol. So now… let’s do something with it.
The obvious(ish) next step, in my mind? Make a server. It’s all going to be over the network eventually, so it’s either here or storing data. Here it is!
Specifically, my goal is not to build the networking and data structures for this project from scratch. Where there are primitives or libraries that will do something like networking for me, I’m going to use them.
Ergo:
So, how do I write a simple server in Tokio?
Recently, I read through Build Your Own Redis with C/C++. C/C++ are ugly, so let’s run through it in Rust!
My goal: implement some large subset of Redis (both server and client) in Rust. For any features I implement, it should be compatible with Redis off the shelf. I should be able to use their client with my server and their server with my client and it should just work.
No idea if this is going to work out, but it sounds like an interesting problem!
First task: the REdis Serialization Protocol (RESP).
Okay, in Proc Macro Workshop: derive(Builder) [Part 1] we created a derive(Builder)
macro to implement the builder pattern. We created a new *Builder
struct, created methods to set each field in a chain, and allowed some fields to be optional.
So what’s left? (Be sure to start with Part 1 if you haven’t read that!)
Let’s do this!