Blog

Rust Module System Encourages Poor Practices (Comparing to Go)

Note that I'm not gonna be saying that it's confusing, hard to understand etc. Those things would be subjective, and even if I agree that it's not too intuitive, it's still totally learnable and not a big deal. In this article I'm gonna be talking about matters which are more objective.

Also note that it's not a tutorial on how Rust module system works; I'm assuming the reader is already familiar with it.

I like Rust-the-language a lot; I spent enormous amount of time in my life debugging memory corruption bugs in C, and so I'm fascinated by the ideas behind Rust, which gives us an incredible level of memory safety without compromising performance. That's very unique. However, there's one thing in Rust that really bothers me: the design of crates and modules.

2023/06/11 19:31 · dfrank

Connect Four 3D

There is a board game called “Connect Four 3D”, in real life it looks like this:

And as part of my efforts to learn Rust in 2023, I implemented a virtual version of it.

2023/05/27 14:07 · dfrank

Treating Email More Like a Password Manager

There is a natural tendency that communication tools, which never meant to be security devices, end up being used heavily for security purposes. This happened to both emails and mobile phones. You know, SMS to a mobile phone is still sometimes the only option for a second factor authentication, despite a lot of evidence that in real life it 's a very bad idea due to SIM swap attacks (check e.g. looks like this or this). And emails are almost universally being used to reset passwords.

I say it's a “natural tendency”, because when the need for something new arises, people obviously try to find and (ab)use something that is already available. But then it strikes back, because first of all these tools were implemented with different goals in mind, and second, even our usage patterns remain mostly unchanged. So when it comes email and phones, we keep using them as if they were only for communication.

2022/12/18 16:49 · dfrank

Bulgaria Freelance Taxes Detailed Breakdown

In the past few years I've been living in Bulgaria, working remotely as a software engineer (technically, “consultant”) for foreign companies (both European and US), and by now I have a pretty good idea about all the taxes and other business-related expenses one has to pay in this setup. Since it's ridiculously hard to find a good and detailed breakdown like that (most often you'll find that income tax is 10%, and dividend tax is 5%, which is accurate but awfully incomplete), I just decided to put this page together. After all, taxes here are pretty simple, unlike countries like US.

2022/03/09 09:22 · dfrank

Mocking time and testing event loops in Go

Initially I wanted to write articles on those two topics separately (mocking time and testing event loops), but during the process I realized that the things I want to talk about are too interrelated: when I need to mock time, it's usually to test some event loop with it, and when I test event loops, typically mocked time is also involved in that.

So in the end, it felt better to just combine all that in a single article.

2021/09/30 09:15 · dfrank

Reliable, Secure and Universal Backup for U2F Token

I really love the security level U2F provides, but together with security, we have to think carefully about the backup and recovery plan. It would totally suck to get locked out of my accounts if something happens with my U2F token. At the same time, it doesn't make sense to have a backup which compromises U2F security.

→ Read more...

2018/08/15 09:54 · dfrank

Why not improve error handling in our Go projects?

As I was saying already, I love Go, I really do. And in particular I like the minimalistic approach to error handling: no exceptions, each caller should check the error explicitly and deal with it as it wants.

2018/03/02 10:14 · dfrank

Here's why I love Go

Many years ago, I've been waiting for a language like Go. Back then, I was primarily working with C (for microcontrollers), and C++/Java/Python/etc (for bigger machines). These are great tools, but still I was longing for compiled, statically typed, memory-safe (and garbage collected) language, which compiles for the target platform machine code, and has a big enough community.

2018/03/02 10:12 · dfrank

Mongoose Embedded Networking Library on nRF51 and nRF52 (Bluetooth)

2017/02/28 00:13 · dfrank · 0 Comments

I'm Tired of Makefiles

At Cesanta, we use Makefiles to build our firmwares, libraries, and perform other things. But the more I use make, the less I like it. I want my incremental builds to be reliable, and I want to be able to reuse my Makefiles as needed. make can't provide that, and builds just kinda-sorta work most of the time.

Most annoying issues are:

→ Read more...

2016/12/11 17:33 · dfrank · 24 Comments

Docker Printable Quick Reference Card

I use Docker, but not often enough to memorize even basic Dockerfile instructions and CLI commands. After all I got so annoyed by being unable to quickly sketch some Dockerfile or to do something with the existing containers occasionally, so I decided to write a concise cheat sheet which I can print once and constantly keep on my desktop:

2016/08/01 12:59 · dfrank

Let's Run Lisp on a Microcontroller

2016/07/18 17:11 · dfrank

Heap on Embedded Devices Analysis and Improvement

The heap on a device is usually a kind of black box: heap API rarely provides anything more than just returning free space size, and quite often it doesn't provide even that (since C standard doesn't oblige it to). We have little idea of the fragmentation (in particular, we're interested in longest contiguous free chunk of memory) and the behaviour of the allocator in general. But in the resource-limited circumstances we're highly concerned about being memory efficient, right?

Read more

2016/01/26 21:16 · dfrank

Standard interface between a text editor and an IDE?

You may probably consider this a rant post.

UPD 2023 actually, the rant is now irrelevant. These days, we have LSP (Language Server Protocol), which is exactly what I was talking about back in 2015. Still, I'll leave the rest of the text below unchanged.

→ Read more...

2015/10/09 17:56 · dfrank · 8 Comments

Microchip PICkit3, Don't Halloo Till You Are Out of the Wood

Microchip has a tool called MDB: Microchip command-line debugger. It's a very nice idea: we can automatize things; at least, we can program a hex from a script. Implementation, however, is far from perfect, but, well, it works somehow.

→ Read more...

2015/10/07 00:05 · dfrank · 2 Comments

Unit-testing (embedded) C applications with Ceedling

Just like a lot of other embedded software engineers, I used to ship my embedded applications to production without testing them properly. Only some manual tests were done. I was under the impression that there's no real way to test them: you know, embedded applications run in a custom hardware and interact with this specific hardware heavily, which makes them not so easy to test automatically.

But the more I worked in this field, the more I thought that there should be some way to make my applications more reliable. Of course, I strive to develop right application design and write good implementation, but mistakes (sometimes very silly ones) happen. And one day, I've come across the awesome book: Test Driven Development for Embedded C by James W. Grenning. It is a very good book, and it explains the topic very thoroughly; highly recommended.

Although this article is based heavily on what I've learned from this book, it is not just a very short version of it: while trying to put my knowledge to practice, I found some new tools that simplify the process even more. I hope that the article will help you to start quickly.

Read more

2015/10/05 15:12 · dfrank

How I ended up writing new real-time kernel

I work with embedded stuff for several years: our company develops and manufactures car trip computers, battery chargers, and other car-related electronic devices.

The processors used for our designs are primarily 16- and 32-bit Microchip MCUs, with RAM from 8 to 32 KB, and ROM from 128 to 512 KB, without any kind of MMU. Sometimes, there are even more modest 8-bit chips.

read more

2015/09/20 22:02 · dfrank

Testing Socket.io with authentication by Passport.socketio

The usage of real-time socket connection with authentication data seems quite regular thing to me. And, personally, I find it very strange that this topic receives so little interest.

2015/09/17 01:29 · dfrank · 0 Comments

How do JavaScript closures work under the hood

From my experience, a lot of JavaScript programmers, mine included, learned how to use closures without having clear understanding of how closures actually work, and what exactly is going on behind the scenes when we use them. What the closure actually is, to begin with? When it is created and deleted? What the implementation should look like?

So, I've written an article How JavaScript closures work under the hood which explains the subject in a very intuitive way, with clear diagrams and examples.

2015/09/09 07:45 · dfrank · 0 Comments

Qt Creator in VirtualBox with Windows guest OS

I needed to develop an utility application in Qt, which should work in Windows. I use Linux, and this is no problem since Qt is crossplatform, but anyway, to make sure resulting application works in Windows as intended, I've installed Qt in Windows guest OS in VirtualBox.

Surprisingly, at the time of writing this, there were two issues running Qt Creator in Windows guest OS.

→ Read more...

2015/07/16 10:28 · dfrank · 0 Comments

Usage of Ragel in Qt project

Recently I had an opportunity to work with Ragel State Machine Compiler in my Qt project (There was a requirement to parse binary protocol), and the question was, how to integrate Ragel source files in the project conveniently. After all, I've read about qmake's QMAKE_EXTRA_COMPILERS facility, which does the job very well.

→ Read more...

2015/07/16 08:24 · dfrank · 0 Comments