Order map in Go

As you may know, it’s not possible to order a map in Go (just like in any language where maps are implemented as hash maps). However, we can achieve the same result by working with the map’s keys.

The approach is to extract the keys into a slice, sort them, and then retrieve the corresponding values from the map using the sorted keys.

Let’s take a common example: given a list of strings, return the list of strings sorted in decreasing order of their frequency.

func orderByFrequency(slice []string) []string {
	occurrenceMap := make(map[string]int, len(slice))

	for _, elem := range slice {
		occurrenceMap[elem]++
	}
	keys := make([]string, 0, len(occurrenceMap))

	for key := range occurrenceMap {
		keys = append(keys, key)
	}
	sort.SliceStable(keys, func(i, j int) bool {
	     return occurrenceMap[keys[i]] > occurrenceMap[keys[j]] 
	})

	return keys
}

In this approach, we first create a map to count the occurrences, then create a slice of the keys and sort them.

But what happens if we want to add another sorting criterion? For example, if two strings have the same occurrence count, we want to sort them in decreasing order by their string value.

In this case, we modify the sorting function as follows:

sort.SliceStable(keys, func(i, j int) bool {
		if occurrenceMap[keys[i]] > occurrenceMap[keys[j]] {
			return true
		}
		if occurrenceMap[keys[i]] == occurrenceMap[keys[j]] && keys[i] > keys[j] {
			return true
		}
		return false
	})

Try to create an exercise yourself.

Install Matrix Server

First Step to Develop a Matrix Client: Set Up a Local Matrix Server

The first step to developing a Matrix client is to set up your own Matrix server. This allows for a simple configuration to get started quickly. The easiest way is to use a Matrix server via Docker. For simplicity, this setup uses an SQLite database instead of the PostgreSQL database typically used in production environments.


Below is a summary of the steps, based on the official instructions found here: https://hub.docker.com/r/matrixdotorg/synapse

Install docker


The installation method depends on your operating system. Follow the instructions on the official Docker website for your OS.

Download the docker image
docker pull matrixdotorg/synapse

Generate initial configuration
docker run -it --rm --mount type=volume,src=synapse-data,dst=/data -e SYNAPSE_SERVER_NAME=my.matrix.host -e SYNAPSE_REPORT_STATS=yes matrixdotorg/synapse:latest generate

Start Matrix server
docker run -d --name synapse -v synapse-data:/data -p 8008:8008 matrixdotorg/synapse:latest

Create users
docker exec -it synapse register_new_matrix_user http://localhost:8008 -c /data/homeserver.yaml -u user2 -p password2

This command creates a user named “user2” with password “password2”.

Repeat this command to create additional users as needed.

Conclusion

Now everything is up and running (the server is listening on http://your_ip:8008). If you shut down Docker, remember to restart both Docker and the container.

For example, on openSUSE:

systemctl start docker
sudo docker start /synapse

Matrust: A Matrix Client in Rust + Slint

I’ve just started a new open-source project called Matrust (naming things isn’t my strong suit 😅).

The Goal

The idea is to build a Matrix client (https://matrix.org) using:

But why this stack—especially when I have over 20 years of experience with C++ and Qt?

Why Rust + Slint?

Love it or hate it, Rust is one of the most exciting languages around today—safe, fast, and supported by a strong ecosystem.

As for Slint, I see it as a modern and lightweight alternative to Qt/QML, with a fresh take on UI development, especially in the Rust world.

So I thought: why not build a learning path, like I previously did for SwiftUI, but this time with Rust + Slint—on a real project?

This is a learning journey for me too—it’s the first time I’m combining these three technologies.

Current Status

The project is in a very early stage. At the moment, Matrust supports:

  • Logging in
  • Receiving messages from a test Matrix server

It’s basically a first commit. What’s in the repo today will likely evolve—or be completely rewritten—as the design and architecture solidify.

A Guide for Developers

I’ll be documenting every step of the process, to build a resource for:

  • Rust or Slint beginners
  • Developers curious about building a Matrix client
  • Anyone who, like me, prefers learning by building real things

What’s Next

One of the upcoming posts will walk through setting up a local Matrix server using Docker. That way, we’ll have all the components running locally, making development and testing easier and more consistent.


The repo:

https://github.com/niqt/matrust

Bare-Metal Programming: A Great Book to Start with STM32

The last book I read dives into bare-metal programming, which means writing code that runs directly on the hardware, without an operating system. If you’re curious about embedded systems beyond platforms like Arduino or Raspberry Pi, this book is a great starting point.

The book is titled Bare-Metal Embedded C Programming, and it uses the NUCLEO-F411 development board, based on the STM32F411RE microcontroller. It’s a powerful yet affordable board ideal for learning low-level programming.

Who is this book for?

Both beginners and experienced developers will find it useful. It starts with setting up the development environment—installing the IDE, the toolchain, and the software required to upload code to the board.

Although the author works with Windows, I tried the examples on both Linux and macOS without issues.

What’s inside?

Each chapter includes:

  • A theoretical introduction
  • A practical coding section

This structure helps you understand the concepts before jumping into implementation.

What you’ll learn

Throughout the book, you’ll get hands-on experience with:

  • ADC (Analog-to-Digital Converter)
  • SPI (Serial Peripheral Interface)
  • I2C (Inter-Integrated Circuit)
  • And many other low-level features of STM32 microcontrollers

If you want to explore bare-metal embedded development and move beyond high-level platforms, this book is definitely worth reading.

What I don’t like about the AI hype.

Two things I don’t like about the current AI moment:

The word “democratization” in the context of software development.
Why is it considered democratized only now? Was it impossible before to learn computer science through university, courses, books, or videos? Did we not already have resources to learn?
Calling it democratization can be misleading—it may actually be (a fake) simplification. If you don’t understand the fundamentals of computer science, should you really be building software for a bank? (And if you are, please let me know the name of the bank—I’m very interested!)

Schools have long democratized writing: if you know how to write, you can use a pen, or draw letters in the sand with a stick.
But if you build something using AI tools without understanding how it works, and one day the tool breaks, what will you do? Nothing. So where is the democratization in that?

And please don’t tell me that without internet, software engineers wouldn’t be able to work. Sure, we’d be slower without access to documentation, but we can still do our job.

The mantra: “AI doesn’t steal your job, but people using AI will.”
Is this a way to reassure yourself—or just a marketing slogan?