Giovanni Bricconi

My site on WordPress.com

Archive for June 2022

Me and the climate

leave a comment »

This is the first of a series of articles about climate change, how I feel about it, and what I am doing on my own.

About six months ago I watched “Before the flood” by Leonardo di Caprio: it dates of 2016 but was somehow available on Disney Plus, and I do not know how I have found the time to look at it. Usually, my daughter monopolizes the tv, but not that evening.

if you are curious about the film, you can have a look on Wikipedia to know more, or just watch it. It is a documentary, it is not super exciting but it was telling about surprising things about climate change. I do not remember many episodes but one was about Miami and attracted my attention.

The episode on Miami was describing the county plan about sea water raising. Some parts of the city are impacted, more and more, and they decided to rebuild part of the infrastructure in more elevated places. For sure this will require a lot of money and will impact many people that will have to relocate their activities.

So a real town, very known in the world, is so impacted that had to start a huge project to reduce the climate change impact. It has been quite easy to find the official site with many details on what they are doing: https://www.miamidade.gov/global/economy/resilience/sea-level-rise-flooding.page

There is a 3D model showing where the impacts will be, and a mini guide explaining what will be the problems. This is a picture taken from this guide

impacts of rising sea level

So it is a real, huge project, with many people and money behind it – as you can read on their site. This made the climate change problem much more concrete for me.

The surprising thing for me was also that you do not fight the cause of the problem, just try to adapt to its consequences. By the way what else could do Miami’s citizens: they cannot just fix the problem for everybody else.

After this episode, and others that I will describe in other posts, I started thinking at what I can do about climate change. I don’t believe that politics will find a solution to the problem, for a simple reason: it is so cheaper to continue living as we do today until we have to pay personally for the damages. We all love to pay the least possible for everything we need, and fossils energy sources are so inexpensive compared to other sources.

As a really selfish individual, I will change what I can, and I will talk about it. It won’t be a huge contribution, but at least I am not just passively watching to what is happening.

Written by Giovanni

June 19, 2022 at 5:55 pm

Posted in Varie

jep/428 Java Structured Concurrency

leave a comment »

Well it is a lot of time I do not develop concurrent code in Java, but reading this JEP has been really nice and I hope it will find its way to an official feature.

An example is given, where one task spawns 2 parallel threads. If everything goes fine we are all happy, but if one of the threads gets interrupted it is easy to have some leaks. For instance if one of the sub-threads fails, also the second thread should be killed and the parent thread interrupted.

Manually coding this seems complicated, and difficult to test. The StructuredTaskScope they propose seems good to solve many problem, event though the syntax is a bit cumbersome

Response handle() throws ExecutionException, InterruptedException {
    try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
        Future<String>  user  = scope.fork(() -> findUser()); 
        Future<Integer> order = scope.fork(() -> fetchOrder());

        scope.join();          // Join both forks
        scope.throwIfFailed(); // ... and propagate errors

        // Here, both forks have succeeded, so compose their results
        return new Response(user.resultNow(), order.resultNow());
    }
}

Also they propose to modify the thread dumps to make evident the problems caused by subtask failures.

I hope you will enjoy reading JEP 428: Structured Concurrency (Incubator)

Written by Giovanni

June 3, 2022 at 1:21 pm

Posted in Varie