Dawid Ciężarkiewicz aka `dpc`

contrarian notes on software engineering, Open Source hacking, cryptocurrencies etc.

make-a-big-revert-to = "!f() { \
     ts=`date +"%Y%m%dT%H%M%S"`; \
     tmp_branch="_make-a-big-revert-to-`date +"%Y%m%dT%H%M%S"`"; \
     git diff-index --quiet HEAD || { echo "Not clean"; exit 1; }; \
     git branch ${tmp_branch}; \
     git reset --hard ${1}; \
     git submodule update --init --recursive; \
     git reset --soft ${tmp_branch}; \
     git branch -D ${tmp_branch}; \
     shift; \
     git commit -a --no-verify "$@"; \
  }; f"

Based on an answer to “Revert to a commit by a SHA hash in Git?”

Humans are very competitive. If you give them a number to rate themselves with, they will try to increase it.

If you find an Open Source project, and it's not very optimized on a certain metric you care about, to make it better, you have to do only one thing: write a benchmark for it. Ideally showing this project is worse in a given metric compared to some other similar projects. You're almost guaranteed that in a short time there will be improvements.

Most people must be familiar with the quote:

“Measurement is the first step that leads to control and eventually to improvement. If you can’t measure something, you can’t understand it. If you can’t understand it, you can’t control it. If you can’t control it, you can’t improve it.”

― H. James Harrington

It's an important insight and people internalized and wish to apply it... even where it can't be.

Read more...

A couple of years ago I've read a blog post somewhere, where the author said that they always use < or <= and never > and >=.

So instead of:

if v.len() > MAX_ALLOWED_SIZE {

which is written the way one would say it: “if the length of v is greater than allowed ...“, to use:

if MAX_ALLOWED_SIZE < len.size() {

which instead of trying to be a transliteration, puts the sides in the natural order, like in:

0, 1, 2 3, 4 ...

I got curious if doing it this way is beneficial, and half-consciously tried it out. And I got hooked, and highly recommend it to everyone.

I think the main reason why it works is that it effectively eliminates one complication. I look at the comparison and don't have to parse which way is the operator pointing and interpret it. I don't have to “read it in my head”. I just look and “left is lower”, “right is higher”. Simple.

The only downside is that now seeing > in code that I did not write, annoys me a bit. I still immediately notice that “it points to the wrong side”, and have can figure it out fast, but having to think about it seems inconvenient.

That's kind of it. I can't find the original blog post (was it maybe a reddit comment or something?)~, but if you do, please send it my way and I would put the link below. You can find the original blog post here (thank you Johannes!).

Please check this out first (feel free to skip around):

Have you noticed, that drawing a spiderman is very much like building a software project? No? Here's why I think so:

Read more...

I find that it's useful to think about software projects as restrooms. Surprisingly a lot of aspects of software development fit well in this analogy.

We have toilets (codebases) to serve our needs. We don't particularly value them for what they are, other than as much as they are useful to us. We have rules and rituals around sharing them, and so on.

But let me just tell you something important about restroom maintenance.

Read more...

Since “mocks” and “mocking” is somewhat vague, and nuances between mocks, fakes, mock objects, test doubles, spies, etc. are confusing, let's start with what I mean by “mocking”.

What I mean by it is intercepting and/or substituting internal and often arbitrary function calls to test your code.

A great example of a mocking approach is a mocking framework like Mockito, where the tests look like this:

Read more...

I have recently discovered a very good youtube channel about business software development: CodeOpinion. Very concisely yet informative. I highly recommend it. Don't worry – it's OOP-rant free, and all about mainstream accepted good practices, not some wacko OOP-hater like me.

Anyway, while going through some of the episodes I have found a good example of how “Objects” (in OOP) are a metaphor that is just confusing people.

Please watch the AVOID Entity Services by Focusing on Capabilities – it's just 7:30:

Read more...

BTW. I highly recommend Statistical Rethinking 2022 Youtube lectures by the same author. I started watching them recently and I am enjoying them a lot so far (finished first two videos so far).

I like fast code, and I cannot lie.

I've been optimizing a lot of projects over the years, and here are some tips that I'd like to share with you

Read more...

TL;DR: I published a parallel processing library for Rust that works differently than rayon and is especially useful in cases where rayon falls a bit short. I'll talk a little bit about it, and show you when it can be helpful.

Read more...