A more general implementation of Lamport's Byzantine Consensus algorithm in Python

Marton Trencseni - Tue 12 August 2025 • Tagged with lamport, byzantine, generals, python, flask, distributed

This follow-up factors Lamport’s Byzantine Generals algorithm into a generalized class that's independent of I/O and payloads. Any node can initiate a round (be "king"), values can be arbitrary strings, and multiple rounds can run concurrently.

Continue reading

Lamport's Byzantine Generals algorithm in Python

Marton Trencseni - Wed 30 July 2025 • Tagged with lamport, byzantine, generals, python, flask, distributed

I discuss Lamport's Byzantine Generals problem and why it requires a total of N≥3M+1 nodes with M malicious nodes, and then implement the solution using Python with HTTP Flask servers.

Continue reading

Lamport's logical clocks and the Ricart–Agrawala Distributed Mutual Exclusion algorithm in Python

Marton Trencseni - Sun 13 July 2025 • Tagged with distributed, mutual, exclusion, ricart, agrawala, python, flask

This post shows how to implement the Ricart–Agrawala Distributed Mutual Exclusion algorithm with Lamport's logical clocks using HTTP Flask servers.

Continue reading

Exploring Lamport's Bakery algorithm in Python

Marton Trencseni - Fri 11 July 2025 • Tagged with lamport, bakery, python, flask, distributed

This post shows how to implement Lamport’s Bakery algorithm with Python HTTP Flask servers. The Python code is short and readable, helping newcomers grasp the algorithm’s logic without the syntactic overhead of C++. The asynchronous HTTP flow also generates plenty of overlap between workers, so the need for mutual exclusion is obvious. Exposing the variables through REST endpoints enables observation of ticket picking and critical section entry in real time, potentially making the flow of the algorithm easier to understand.

Continue reading

Exploring Lamport's Bakery algorithm in C++20

Marton Trencseni - Sun 06 July 2025 • Tagged with lamport, bakery, c++

I explore Lamport’s Bakery algorithm and show how a naive C++20 implementation breaks on weak memory models, how to fix it with std::atomic, and how to implement bounded tickets.

Continue reading

A simple telnet based Taboo game in async Python

Marton Trencseni - Sun 06 October 2024 • Tagged with taboo, python, async

I built a simple Python-based Taboo game server using asyncio to provide a customizable multiplayer experience via Telnet.

100

Continue reading

Wordcount III: Beating the system `wc`

Marton Trencseni - Fri 29 September 2023 • Tagged with c++, wc

In this follow-up to the previous article about writing a C++ version of the Unix command-line utility wc, I make some modifications to beat my system wc in performance tests.

wc

Continue reading

Wordcount II: Introducing a cleaner C++ class hierarchy to `wc`

Marton Trencseni - Sat 23 September 2023 • Tagged with c++, wc

In this follow-up to the previous article about writing a C++ version of the Unix command-line utility wc, I make the class structure more complicated to keep separate concerns and functionality in different C++ classes. The result ends up being significantly more complex than the original, but does not make the overall program easier to understand or modify.

wc

Continue reading

Wordcount I: Implementing the Unix command-line tool `wc` in modern C++

Marton Trencseni - Sun 10 September 2023 • Tagged with c++, wc

After reading the excellent book Beautiful C++ about the language's latest features, I implement the Unix command-line tool wc in modern C++.

Beautiful C++

Continue reading