Alessandro's blog

Thoughts on software development

Aug 19, 2019 - Slowness and voice commands

Windows XP was a good OS. A bit heavy during 2001 but then it worked really well for a few years. I now work on a Mac OSX Mojave laptop with SSD, 16 GiB of RAM and it feels slow. Really slow.

Few years back people were talking online about boot times of 10 seconds. Mojave takes way more time to boot. Would it even work on a magnetic disk?

Some apps on my phone take 2-3 seconds just to display a menu with 5 items. Our computing devices have enormous computing power and so much memory that the fact that they are so slow blows my mind. And there are no visible features that justify such slowness. I mean, it took OSX 10.6 to add a keyboard shortcut to lock the screen. Of course they had to cripple Grab, the application that takes screenshots.

Everything is getting bigger, more bloated and slower for no apparent reason. I feel this is a plan to push more for voice assistants. How come that asking “Hey Computer, set an alarm for nine fortyfive am” is faster than opening the alarm app on my smartphone? Wasn’t like this 15 years ago.

I find it fun that some apps have a “Lite” version that can be downloaded just from some countries and not others. The usual lie is “slower internet connections” or “less modern devices”.

Guess I’m just getting old and some nostalgic thoughts about the “good old times” crossed my mind. Or I’m limited and cannot understand why I should download 10 MiB of HTML+CSS+Javascript to read less than 1 KiB of textual information.

Dec 7, 2017 - What to get after Wine?

What to get after Wine? I’m not talking about drinks, but instead I will talk about the Wine project. The project is a kind of “emulator” that let you run Windows applications on Linux.
It is not a real emulator, like the name itself explains with a nice recursive acronym: Wine Is Not an Emulator. It’s a compatibility layer that translates Windows system calls to Linux ones, so the applications really believe to be run inside Windows ;-)

This is so much of a cool idea that Microsoft did the same thing backwards: Windows Subsystem for Linux. I would have expected a joke involving drinks or desserts, at least.

After installing WSL from Control Panel, I downloaded Ubuntu bash from Microsoft Store. Python and Ruby work perfect!
I’m running Jekyll and [Jupyter] ( on my Windows10 laptop.

Bash terminal runs on its own Linux like filesystem, to get accesso to the computer’s disk simply navigate to /mnt/c/ directory.

I’m very surprised of this Microsoft product. It is not clear to me why they decided to support another Operating System architecture in Windows (maybe the popularity of Cygwin?).

Oct 17, 2017 - Mining Monero for free

Monero is cryptocurrency which uses a Proof-of-Work algorithm that runs on regular CPUs and GPUs. Proof-of-Work, in layman terms, means that there must be miners who “mine” each block, and get rewarded when they solve a particular “equation”.

Mining is a profitable activity, but you must pay your electricity bills… unless someone else offers you free CPU cycles! In this article I will show how to mine Monero for free.
But who and why is offering free computing power? There are some competitors in the market who want to hook developers in. Once you start with and know a platform, you will probably stay there for future projects.
In the meantime, let’s try the platforms!


There’s a Free plan with Microsoft Azure, they offer 200$ / 170€ to try their service. It is about 1 month of a 2 vCPU Windows server, or 2 weeks of a 4 vCPU Windows server.
Just install a miner and start free mining!


The Free tier of Amazon AWS offers 1 year of a 1 vCPU Windows server. Unfortunately it’s throttled, so for most of the time it won’t mine. There’s a workaround though: write a script that launches the miner, checks the hashrate every some minutes and if it’s too low, kills it and waits a couple of hours for the CPU to get back to full speed.

Which miner?

The fastest CPU miner I know of is xmr-stak-cpu. Follow the intructions to enable Large Page Support, it boosts performance a lot.
I sent a pull request to enable stdout flushing, so it’s possible to read its status even when running in background through a pipe. To have the miner report its hashrate set the following two options in config.txt:

"verbose_level" : 4
"h_print_time" : 120

If you know other platforms that offer some kind of free trial of their cloud computing, let me know ;-)

If you liked the idea and feel like tipping here’s my address ;-)

Jan 20, 2017 - Clean Code

I just read Clean Code by Robert Martin, a very insightful book on software development. I thought about it for a while and decided to write a little review.

TL;DR version

The book is an interesting read, even if you already know some of the ideas contained. Do you professionally develop software? Go read this book immediately!

Long version

Let’s start with a quote I particularly like: “Programming is a craft more than it is a science. To write clean code, you must first write dirty code and then clean it.
It may sound obvious, but it isn’t. The act of “cleaning” requires a precondition: you must know by experience when the code is dirty and decide to clean it up. Such experience comes from passion, from hard work and from lessons learned from master craftsmen. The author tries its best to be one of them.
As our experience grows, the meaning of “clean” will change to reflect the new lessons learned. Let’s look at some excerpts.

Software systems should separate the startup process, when the application objects are constructed and the dependencies are “wired” together, from the runtime logic that takes over after startup. […] One way to separate construction from use is simply to move all aspects of construction to main, or modules called by main, and to design the rest of the system assuming that all objects have been constructed and wired up appropriately.

We all know some of the usual suspects around: Spring, OSGi Blueprint, Unity… There are many frameworks for inversion of control and dependency injection around. What we get from them is the ability to work with dependencies without checking for NULLs, all object are created and ready to be used. What if something is missing or not constructed? We are going to fail fast of course!
We need dependency injection even if our applications supports one kind of database or a single remote service. Because we will need at least a second database engine: a mock database engine for testing purpose.

Test code is just as important as production code. It is not a second-class citizen. It requires thought, design, and care. It must be kept as clean as production code. Tests are very important becase tests enable change. Tests let you know that you didn’t break the expected behaviour. Tests let you know that you didn’t break the expected behaviour of tested code, that’s why test coverage is important too.

Another quote I like about tests: Test F.I.R.S.T.
Fast - Tests should be fast. They should run quickly.
Independent - Tests should not depend on each other.
Repeatable - Tests should be repeatable in any environment.
Self-validating - The tests should have a boolean output. Either they pass or fail. You should not have to read through a log file
Timely - Unit tests should be written just before the production code that makes them pass.

There’s nothing as relaxing as the line of green dots of passing tests. Red ones should be fixed immediately, because we want everything green to feel great. How much time would you want to wait after fixing the code to see everything green again? No more than some seconds, I bet.

Tests should be structured as follows:
The BUILD-OPERATE-CHECK pattern is made obvious by the structure of these tests. Each of the tests is clearly split into three parts. The first part builds up the test data, the second part operates on that test data, and the third part checks that the operation yielded the expected results.

Also known as Arrange Act Assert pattern. Almost any testing framework offers its own way to hook into test lifecycle to setup and clean any resource or data required. Assertions can show customized messages when they fail.

Open-Closed Principle: Classes should be open for extension but closed for modification. We want to structure our systems so that we muck with as little as possible when we update them with new or changed features. In an ideal system, we incorporate new features by extending the system, not by making modifications to existing code.

Is there anyone not yet familiar with Decorator and Adapter patterns?

There’s a lot more in the book than these concepts. For example, there are examples of “bad code” and how the author proceeds in refactoring it.

About me

My online presence can be proven by the following social accounts ;-)