Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,583
|
Comments: 51,213
Privacy Policy · Terms
filter by tags archive
time to read 3 min | 591 words

So my current project is to learn Rust. This is part of firm belief that if you don’t actively extend your reach, you’ll be forever stuck in an infinite loop. So Rust it is.

Why Rust? Because the previous time I did something like that I looked at Go, which is nice, but except for green threads (which I’m familiar with from Erlang), it is pretty much the same old thing. I’ll admit that the compilation speeds are pretty attractive there, but I’m working mostly on system software this days, and it seems like it is almost there, but not quite.

So the choice was between Rust and modern C++. The last time I actually did any C++ professionally was in 2006, I needed to build a tool to make a machine join the domain automatically, or something like that. I remember being stuck for an embarrassing long time on “using std” vs “using namespace std”. Before that, I actually did C++ for a few years, in 1999- 2002 or so. I was below average, at best, but I had read all the Myers books, and I had great confidence that I can mess up real well.

But C++ today is a wildly different beast, much nicer, but at the same time… The core concepts (memory management, RAII, etc) I already know, and a lot of the rest seems like stuff that I now take for granted (foreach, auto,lambdas, not doing manual memory management all the time, etc). Looking into modern C++ codebase and discussion, I see a lot of stuff about move constructors and variadic templates. That caused me some pain, but basically, there isn’t anything new there for me, just detail work.

Rust is new, in the sense that it has the Burrow checker and it is supposed to be a safe & fast system programming language. That seems like a big contradiction in term, but it is at least interesting.

So I set out to read the Rust book. I have done so, and below you can see some of my impressions while reading it.

This post is written before I did anything more interesting than writing a hello world.

Rust has macros, and I like that. Should be interesting to see what it can do.  Okay, I saw what it can do, and I sort of want to go back to variadic templates. To be rather more exact, that syntax looks sort of the same. And remind me strongly of trying to grok XSLT in the 90s.

I like that it has explicit threading support, and it is interesting that this is baked directly into the language and checked by the compiler. Although some of the stuff that is mentioned there is fishy (Rc<RefCell<Vec<T>>> and other strangeness), but then again, I’ve literally just read the book, so need to see how this work out in practice.

Something that was really strange during the reading is that Rust uses the type of the assignment to infer types.

Speaking of this, I’m used to languages that have far less syntax. In comparison, it seems like Rust have a lot of stuff going on. Most of it seems to be optional / inferred, but that is surprising.

Loop labels and named break / continue are really nice. They are always ugly when you need them.

And obviously the type system is quite sophisticated. I’m going to see how hard it is going to hurt me when I try writing actually stuff with it.

time to read 1 min | 176 words

I run into the following inside a C codebase.

image

That caused some head scratching, until I realized that this is probably just a funny way to write a static assert.

Basically, sizeof() is a constant time value that is being evaluated by the compiler, I assume that the cast to void is to make this clear to the compiler that we are throwing away the value intentionally and that it shouldn’t actually generate any code here.

The rest is pretty basic, the compiler need to compute the size of the array, and to do that, it need to compute the value, but if the above statement is false, the value is –1, and that is not a valid size for the array, so a compiler error will be raised.

I think that there are better ways to do it, but I’m guessing this a more portable version?

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. Production postmorterm (2):
    11 Jun 2025 - The rookie server's untimely promotion
  2. Webinar (7):
    05 Jun 2025 - Think inside the database
  3. Recording (16):
    29 May 2025 - RavenDB's Upcoming Optimizations Deep Dive
  4. RavenDB News (2):
    02 May 2025 - May 2025
  5. Production Postmortem (52):
    07 Apr 2025 - The race condition in the interlock
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats
}