Category: Blog

Fun with Functors in C

C language is old, actually, a very old language that resisted all the innovations that impacted the software development industries. Even ISO standard Cobol integrated object-oriented capabilities in 2002!

This didn’t prevent programmers from applying object-oriented programming to C. With some macro juggling and a lot of self-control not to break framework rules, you can have inheritance and dynamic dispatching.

Generic programming is, in the same way, foreign to C language1. You can use preprocessor macros to implement generic containers or functions that can be instantiated on the type you need, but it is a painful endeavor.

Continue reading “Fun with Functors in C”

Ad Astra

“Friends come and go, but enemies accumulate” [A. Bloch]. In my experience I never found a witty saying farther from truth than this.

I am about starting a new job and I am in the same mood and feelings I expressed here two years and something ago – thankful to the people I met and nervous to meet new people, although, I’m sure, they’ll be great people to work with and to share a good chunk of life.

Continue reading “Ad Astra”

What Happens in Monads Stays in Monads

There are moments in life when you have to take a stance. You know countless people already tried and possibly succeeded in doing something, but you feel the urge to try it yourself.

So yesterday I attended the Milan C++ Meetup by Marco Arena, presented in a very entertaining and well-organized way, what’s new in C++23. Everything was fine until Marco presented the std::expected template and its “monadic operations”. Now it was in the context of a much wider presentation and there was no time to go into details, but I got the impression that the C++ community has a bit of an ad-hoc approach to monads. I mean C++98 failed to recognize that containers are monads, C++11 failed to recognize that std::future is a monad, C++17 failed to recognize that std::optional is a monad, and C++20 failed to recognize that coroutines are monads. You can see a pattern there.

Continue reading “What Happens in Monads Stays in Monads”

It Is Exactly Twenty Years Today…

… since my first post in this blog:

I’ve just registered the domain ‘maxpagani.org’. This should be the first step in the online life of this site. A little step for a site, nearly unnoticeable for humanity :-D.

Thank you for visiting my website and reading my rants all these years!

It was 2004, and Facebook had just been founded but had still to reach critical mass and take off. RSS had to become a thing and Google Reader had to happen the next year, MySpace was still in its infancy, and “blogosphere” was the trending word. BTW the BASIC language just turned 40 that year.

Back then I worked at UbiStudios Milan and we were told the studios would be downsized, and that programmers would be better off looking for a job elsewhere. So I decided I needed some self-promotion and thought of this blog idea. A place where I could write about stuff that I like letting other people (possibly including prospective employers) know about me.

Initially, the blog was made with a bunch of static pages produced by a sort of template processor written in bash. This is how it looked. Later I implemented the blog section using PHP and plain files. I spent quite a lot of time on PHP trying to evolve the website and even prepared a second version with a better look. But eventually, I switched to WordPress.

I always wrote single, stand-alone posts, until I stumbled against PIC18. A microprocessor so unfriendly to C and so hostile to the high-level programmer, that I decided I needed to write a PIC18 survival guide that spanned over 5 posts. Since then I have written a few series, which I am quite proud of –

Since late 2023 I started collaborating with Embedded Related website and moved my publishing of … embedded related articles there. I plan to continue writing on my blog for everything else.

The Advent of Scala Code – What I Learned

It all started with an innocent-looking question, from a colleague – “This year I’d like to propose an office leaderboard for the Advent of Code, what do you think?”. Well, why not? I made a lame attempt at AoC some years ago and possibly gave up on the first day for lack of time (and commitment).

But this looked like an interesting challenge and I agreed and promoted the idea. Since I miss working in Scala, I wrote AoC solutions in Scala 3 to dust off some rust (ops) and learn the new syntax. Solving a (double) puzzle a day for 25 days (Xmas day included), is not a light endeavor. It requires at least from 1 to 2 hours and is increasingly difficult to squeeze into a normal working day especially if you have a life.

Continue reading “The Advent of Scala Code – What I Learned”

Scala Italy 2023 – Scala Blues

It was 2015 when I attended my first Scala Italy conference. I was freshly landed in the functional programming magic world and I was tasked by my boss to asses whether Scala was a technology with a future or just a fade. I sat there, as proved by the picture used over the years as a background for the conference website, and enjoyed the show.

The conference was well organized, with a bunch of sponsors and some hundred people attending. My report, reinforced by attending Scala Days 2016 in Berlin, was that Scala was viable with quite a strong interest and support from the industry.

Over the years the conference grew, I missed the Venice edition in 2016, but I was in Rome in 2017, Florence in 2018, and eventually Bologna in 2019. Both Florence and Bologna were two-day events.

Continue reading “Scala Italy 2023 – Scala Blues”

Take the “Smart” out of Work

Starting the post with “When I was a kid…” sounded proper until I realized this is the typical incipit of elder people talking about something that wasn’t around when they were youngsters. So I convinced myself to find an alternative incipit, but yeah, when I was young no one ever dreamed of working at home, the cave was where rocks and pebbles were and you had to fight your way with saber tooth tigers, wild mammoths, and velociraptors to get there.

The idea of remote working is not new. It gained popularity during the pandemic in the years 2020-2021, but it was already widespread in the technologically advanced industry. Once all your work is done on a computer, thanks to the innovative (but now more than 60 years old) idea of connecting a computer together at a distance – you may do your job anywhere a computer and an Internet connection are available.

Continue reading “Take the “Smart” out of Work”