Rust *
Multi-Paradigm Compiled Language
Proof's by induction using Rust's type-system
Rust's type system is quite powerful as it allows to encode complex relationships between user-defined types using recursive rules that are automatically applied by the compiler. Idea behind this post is to use some of those rules to encode properties of our domain. Here we take a look at Peano axioms defined for natural numbers and try to derive some of them using traits, trait bounds and recursive impl
blocks. We want to make the compiler work for us by verifying facts about our domain, so that we could invoke the compiler to check whether a particular statement holds or not. Our end goal is to encode natural numbers as types and their relationships as traits such that only valid relationships would compile. (e.g. in case we define types for 1 and 3 and relationship of less than, 1 < 3 should compile but 3 < 1 shouldn't, that all would be encoded using Rust's language syntax of course)
Let's define some natural numbers on the type level first.
How does Rust treat Strings and Vectors internally
In Rust strings can be represented in two ways:
a) String type
b) String slice
String type:
String type is defined as a struct of the following structure:
Depending on arch (in my case x86 64bit it is 24byte)
{
pointer to the address where string characters are stored (8b)
capacity (8b)
length (8b)
}
Tests vs. Types — Rust version
A few days ago 0xd34df00d has published the translation of the article, describing the possible information about some function if we use it as a "black box", not trying to read its implementation. Of course, this information is quite different from language to language; in the original article, four cases were considered:
- Python — dynamic typing, almost no information from signature, some hints are gained by the tests;
- C — weak static typing, a little more information;
- Haskell — strong static typing, with pure functions by default, a lot more information;
- Idris — dependent typing, compiler can prove the function correctness.
"Here's C and there's Haskell, and what about Rust?" — this was the first question in the following discussion. The reply is here.
Long journey to Tox-rs. Part 1
Hi everyone!
I like Tox and respect the participants of this project and their work. In an effort to help Tox developers and users, I looked into the code and noticed potential problems that could lead to a false sense of security. Since I originally published this article in 2016 (in Russian), many improvements have been made to Tox, and I lead a team that re-wrote secure Tox software from scratch using the Rust programming language (check out Tox-rs). I DO recommend using tox in 2019. Let's take a look what actually made us rewrite Tox in Rust.
Original article of 2016
There is an unhealthy tendency to overestimate the security of E2E systems only on the basis that they are E2E. I will present objective facts supplemented with my own comments for you to draw your own conclusions.
Spoiler: The Tox developers agree with my points and my source code pull request was accepted.
Generic Methods in Rust: How Exonum Shifted from Iron to Actix-web
A bot for Starcraft in Rust, C or any other language
StarCraft: Brood War. This game means so much to me! And to many of you, I guess. So much, that I wonder if I should even give a link to its page on Wikipedia or not.
Once Halt sent me PM and offered to learn Rust. Like any ordinary people, we decided to start with hello world writing a dynamic library for Windows that could be loaded into StarCraft's address space and manage units.
The following article will describe the process of finding solutions and using technologies and techniques that will allow you to learn new things about Rust and its ecosystem. You may also be inspired to implement a bot using your favorite language, whether it be C, C++, Ruby, Python, etc.
Authors' contribution
humbug 810.2RustLangRu 630.0freecoder_xx 468.0PsyHaSTe 460.2m1rko 424.0badcasedaily1 391.0ozkriff 376.6aio350 360.8mkpankov 319.2GRaAL 318.0