Thu 24 September 2020

Filed under Programming

Tags Rust

It's that time of the year again where we all gather around the campfire to muse on the future of this language we love. Last year I didn't blog anything because I was very new to Rust. I started learning about it in the summer of 2019, but the first real code I wrote was in the fall. I have loved it ever since and was lucky that I was able to write Rust code at work. (Everything is in C#, but I got to start an embedded project)

So to summarize:

  • I use Rust mostly for embedded and the accompanying server.
  • I've been using Rust almost full-time for a little over a year.

Tooling

This has gotten a lot better in the last year. The IntelliJ plugin has improved and Rust Analyzer came into being.

Specifically for embedded, there's the probe.rs project and also the Knurling project. Both show great promise of what embedded development can become!

But there is an improvement I'd like to see to the tooling.

Suggestion

Show crate features on crates.io and allow us to document them for docs.rs. This would improve the crate discovery experience for me. Often I want to know which features I can turn on, or rather, which I can turn off like std.

Language

I've been working with macros lately and they're so much better than the ones found in C.

The variables all have meta types. An example:

macro_rules! foo {
    (x => $e:expr) => (println!("mode X: {}", $e));
    (y => $e:expr) => (println!("mode Y: {}", $e));
}

Each branch of this macro has a variable 'e' that is an expression. There are many more of these meta types like path and ty.

Suggestion

I would like to see some more. Most notably I want to see something that encodes trait bounds.

Imagine this:

macro_rules! create_foo {
    ($b:bounds) => {
        pub struct Foo<I: $b> {
            pub bar: I,
        }
    };
}

create_foo!(Debug + Copy + Clone)

Why would this be special? Well, currently this is very difficult to express! Bounds can come in many forms, so if you want to use this in a macro you've got two choices. Using a tt token tree to capture everything or elaborately encoding all possible options in the macro branch.

Using tt limits your macro in a lot of ways. The other option isn't any better.

End

Thanks for reading!

Comment

Thu 07 May 2020

Filed under General

Tags Thoughts

I think I'm suffering from a condition. I call it 'configuphobia'. It is the fear of configuring programs.

Why?

Configurations are very loosely coupled. When programming, I really like static type checking because it gives you confidence that what you typed in or changed is correct. If it's not correct …

Read More

Thu 23 January 2020

Filed under Hardware

Tags Embedded

First of all, any field has its challenges and can be difficult in its own right. But designing hardware genuinely is very hard and I want to make the case that it's actually harder than writing software for said hardware.

What are those challenges then?

  1. Laws of physics
  2. Lack of …
Read More

Sat 04 January 2020

Filed under Programming

Tags C C++ Library Rant

I want to complaint for a bit. The title says enough for you to know about what.

In my experience with embedded software, sometimes you just don't want to write something yourself. This is very normal and in any environment, be it .NET, Node or somewhere else, I would not …

Read More

Thu 26 December 2019

Filed under Programming

Tags Style

There's often this huge debate about whether to use tabs or spaces in programming. I think there's only one real solution, but I didn't come up with it: Use both!

Image

Why tabs?

Tabs are easy and customizable. Need some indentation? Hit tab in any environment and you're there! Don't agree …

Read More

Thu 26 December 2019

Filed under General

Tags Dion Dokter

Hey there, I'm Dion Dokter. I was born in 1996 and live in the Netherlands. I have a bachelor in Applied Computer Science and now work at 247TailorSteel.

Currently I'm learning about Rust and I'm loving it. I've also worked with C#, C++, Unity and OpenCL.

Previously I worked on …

Read More

Carmine Crystal Blog © Dion Dokter Powered by Pelican and Twitter Bootstrap. Icons by Font Awesome and Font Awesome More