Italian C++ Community https://www.italiancpp.org Mon, 24 Aug 2020 13:03:53 +0000 it-IT hourly 1 https://wordpress.org/?v=4.7.18 106700034 Italian C++ Conference 2020 https://www.italiancpp.org/2020/08/24/itcppcon20/ Mon, 24 Aug 2020 13:03:53 +0000 https://www.italiancpp.org/?p=9663

Italian C++ Conference 2020 Staff Greetings

Last June 13th, we made an awesome virtual day about C++: the Italian C++ Conference 2020. Due to the Covid-19 emergency, the conference was totally online. Better late than never, I am publishing this wrap-up post.

Let me say that I am very proud that the Italian C++ Conference 2020 has been the very first major C++ event happening online. I hope that our experience has been useful to other organizers.

Some information:

  • the event was totally free
  • total number of registrants: 502
  • total number of unique virtual check-ins: 415
  • number of keynote live viewers: 250

First of all, I would like to thank my staff: Alessandro Vergani (co-organizer), Stefano Saraulli, Alessandro Pezzato, Andrea Barbadoro, Mattia Verasani, Elvis Dukaj, Philipp Lenk, Riccardo Brugo.

In addition, my gratitude goes to the conference sponsors: AIV, Think-cell, Hexagon-Leica Geosystems.

Last but not least, thanks to all the speakers who gave great talks and to all the attendees who joined us!

Some stats

As usual, let me go through the responses collected at the registration (some are missing because the facebook integration skips custom questions on eventbrite):

Online event contents

The Italian C++ Conference 2020 was a full-day online event consisting in:

  • technical talks (for the most part live, just a few recorded)
  • networking virtual area with text and voice/video chat channels

Live talks ran from 9 AM to 4 PM, arranged in a two-track agenda that included two short breaks and a long lunch break. The networking area was up and running for the whole day and was hosted on Discord.

Some numbers:

  • 1×90’ live keynote
  • 7×50’ live Talks
  • 3×30’ and 1×45’ recorded talks

Topics presented:

  • Move semantics
  • C++20 in general and one talk focusing on text formatting
  • C++ Development with Visual Studio Code
  • Coding Patterns
  • Writing efficient C++
  • The Silicon Valley coding interview
  • Current trends in the C++ Community

All the talks were in English (except for one recorded talk that was in Italian).

How the virtual event was made

Let me briefly go through how we have made this conference. For any further information, do not hesitate to contact me directly.

The conference was totally free but registering was required for getting access to the networking virtual area and for receiving talk links in advance. The day of the event, live talk links were disclosed for everyone but recorded sessions were disclosed only the day after.

The day before the conference, we sent a “virtual check-in” form to all the attendees.  After checking in, the people were enabled to visit the lobby page that was the conference “entry point”, including all the links and information to virtually attend the conference (invitation to the networking area and agenda with links).

Technical talks

Live and recorded sessions were hosted on YouTube. To manage the live streaming we used StreamYard. This tool is very simple and allows the hosts to send one link to the speakers who can just share the screen and give the talk as they are taking a video call. Also, you as organizer can manage comments, display banners, and customize a bit the appearance. In my opinion, the most important feature you can get out of StreamYard is reliability, since if you lose the connection the streaming keeps on going and the speaker stays on the safe side. Our first option was a hand-made solution with OBS that is a very good tool but that, let’s say, turn the host into a “single point of failure”.

To handle questions we adopted a simple convention: attendees must use the YouTube live chat by adding “QUESTION” at front.

Just an additional note on recorded sessions: StreamYard can be used to manage recorded sessions too (e.g. the speaker cannot record an high quality talk on their machine). You can arrange some time with the speaker and stream into a private video.

Networking

Networking was based on Discord. As said, this was restricted to registrants (the invitation was not public).

We have set up a server with some text and voice/video channels to host discussions. Discord started supporting video chats just a few weeks before the conference and this was crucial for choosing this tool. Also, it’s free.

An important decision made during the conference was adding one channel for each talk, to trigger discussions around that particular topic (having the speaker on board as well, when possible).

In addition to “general” channels and talk channels, we also set up one channel for each sponsor (like “virtual booths”) and one channel for #include<cpp> (in general, this can be done for all other communities that are happy to join the conference).

Clearly, we had some support channels to ask for help and report issues. Some volunteers that we have found a few weeks before the event helped moderate the rooms and give assistance to the attendees.

Alessandro Vergani and me managed the live streaming sessions so other staff members were managing the networking area (although we stayed connected). In particular, Stefano Saraulli and Alessandro Pezzato coordinated the rest of the people involved.

Lessons learned

It’s time to give you some feedback on the organization from the organization!

First of all, from my perspective the conference was great. This was our very first experience with online events and the number of people behind the scenes was very small. I am proud of what we have achieved.

The worst part of the event was triggering networking interactions, meaning that having spontaneous conversations was really hard compared to in person events. People preferred text instead of voice. As said, creating one channel per talk was a good decision that we made on the fly. Indeed, talks which have been followed up on Discord triggered some calls.

I know that other C++ events (e.g. C++ on Sea, CppCon, Meeting C++) are now using Remo. We are going to explore this solution in the future.

I think that live talks worked well and StreamYard was a valuable ally. I recommend this tool, especially if you plan to stream into multiple destinations. The only flaw I have found during the sessions is that communicating with the speaker is almost impossible if they switch off incoming sound or ignore the private chat. Indeed, at some point during one session I couldn’t communicate with one speaker that the time was over and, after several attempts, I had to close the connection and terminate the live streaming.

Another weakness of the combination of Discord and YouTube is just the lack of integration between them. People need to stay connected in two different systems. So you can even think of hosting the whole event on Discord (only if the event is – say – “small” due to Discord limitations) and just make all the talks available on YouTube in a second moment. This way people have to join the stream on Discord to attend a talk and will stay connected. This should also let people speak more informally since it’s like having them all in the same room.

Anyway, let me say that I have really appreciated Discord. It was very useful for keeping things under control, quickly chat with my staff, reaching people, speaking with sponsors, etc. As an organizer, I think two features could be cool to have:

  • events-friendly graphical skin (e.g. arranging people in tables, table map)
  • possibility to join a random channel (sort of “chat roulette”)

Feedback

The online edition had good feedback, however only a small number of people took the time to vote (just 69):

What’s next

In these troubled times, priorities have changed a bit. That’s also what caused this post to be published so late. The period of uncertainty we are currently living has terrible effects on our congruence-and-certainty-seeker brains. Some rules of the game are changed and we don’t know if such a change is irreversible. Anyway, the price to pay to stay in the game is adaptation, as it’s always been in the history of this planet. However, as human beings are designed, change is tough, requires some effort, and finds lots of resistance on its way.

As most people involved in technical communities I have spoken with, I am trying to make my part and keep up with my community activities, mostly online, although I look forward to making in person events again. My thoughts are with those who have decided, instead, to take a break and stop for a bit. I wish them to find new motivation after this recharge. We need you.

From my side, I will keep on arranging monthly C++ meetups (physically in Modena, when possible, and always online – as it’s been since 2018).  However, we do not have any proposal yet so I need your help to diffuse this call for sessions link.

Also, I will still lead Coding Gym and, as a trainer, organize sessions on a monthly basis. Currently, the plan is to stay online for a bit, since social distancing is technically impossible in a traditional Coding Gym (you know, we do pair programming).

At the beginning of this year, I have founded ML Modena, a new community to meet up with people interested in Artificial Intelligence in the Modena area. Unfortunately, our very first meeting was planned just when the lockdown started in Modena so we have not gathered together yet. We hope to schedule a new kick-off meeting soon but we would really love to make it in person, if possible.

Usually, at this point of the year we are already working on the C++ Day. Honestly, this year I don’t know if we will make it. For sure, we cannot do it in person. Alessandro and I will speak about that by the end of August. If you are willing to help, please get in touch directly with us.

Stay safe. Hope to see you soon!

]]>
9663
Italian C++ Conference 2020 will be an online-only event https://www.italiancpp.org/2020/04/06/itcppcon20-online/ Mon, 06 Apr 2020 07:15:08 +0000 https://www.italiancpp.org/?p=9382 In light of recent developments globally and the growing concerns around the spread of the COVID-19 virus, we have made the decision that this year’s Italian C++ Conference will be an online-only/virtual event. It will be scheduled for the same day at the same time (June 13 from 9 AM to 6 PM CEST).

The event page continues to be the main point of reference.

We do not have the resources to postpone this event.

We do not have experience with online events. If you want to help us, please get in touch. Also, please respond to this quick survey: we would like to get your ideas and to know what you could expect from the conference.

The event should include:

  • live streaming of technical sessions (the schedule will be published soon – still waiting for speakers confirmation)
  • virtual rooms for networking/taking a break/chatting
  • other engaging activities, if possible

Attending the virtual event will require (free) registration. We’ll open the registrations in May.

We hope to see you soon, in some form or another.

Stay safe, stay home.


What about C++ Day 2020?  You know, it depends on getting proposals to co-organize the event. Currently we do not have any. We cannot organize it totally on our own.

As usual, get in touch if you want to make this event possible by co-organizing with us.

]]>
9382
C++ Day 2019 https://www.italiancpp.org/2019/12/26/cppday19/ Thu, 26 Dec 2019 11:22:45 +0000 https://www.italiancpp.org/?p=9304

On November 30th, we had an awesome day about C++ in Parma: the C++ Day 2019. We co-organized this event with Elettric80. The event was hosted by the University of Parma!

The C++ Day 2019 had ~170 attendees.

The event was possible thanks to the joint work of Elettric80 and a few people from the Italian C++ Community (Alessandro Vergani, Illya Dudchenko, Federico Ficarelli and I) and the University of Parma.

That’s all about the C++ Day format: a joint effort between the Italian C++ Community and one or more local hosts. As I told during my welcome and closing messages, the call for C++ Day 2020 is open! Two things are needed:

  • an event location with at least 2 rooms with 150 seats each and some space for catering and sponsor stands. Possibly free;
  • some support to co-organize the event. If you are interested, let’s speak about it!

In addition to Elettric80, the C++ Day 2019 had two other supportive companies which I would like to thank:

Last but not least, thanks to all the speakers and to all the attendees!

I have published several pictures of the event here on our Facebook page.

Some stats

As usual, the responses to the C++ survey follow:

Structure and contents of the event

The C++ Day 2019 was a full-day event about C++ development with 8×50′ and 2×30′ talks arranged in two parallel tracks throughout the whole day, 1×45′ Q&A Panel.

Networking and breaks: 1h before the kick-off, 2×30′ breaks (1 morning, 1 afternoon) and 75′ lunch break. Food, hot and cold beverages available through all the event.

The Main Theme of the event was C++ in Industrial Automation. 

Some topics:

  • Cross-compilation in C and C++
  • Python bindings in C++
  • STL algorithms design
  • TBB Dataflow
  • Design patterns and idioms in C++ use cases
  • MISRA C++
  • Monte Carlo Tree Search algorithms in C++
  • From iterators to ranges

Most of the talks were in Italian.

Feedback

This year we had less than 30% of the attendees giving feedback.

What’s next

The organization of the Italian C++ Conference 2020 has already started. It will be in Rome and the call for sessions is open. If you would like to support the event, get in touch.

In 2020 I will keep on arranging monthly C++ meetups in Modena, hosted by ConoscereLinux (which I have been recently joined the official council). A call for sessions is active there as well.

In addition, I will keep on directing Coding Gym and, as a trainer, I will keep on organizing Coding Gym in Modena on a monthly basis.

That’s all. See you in 2020!

]]>
9304
Italian C++ Conference 2019 https://www.italiancpp.org/2019/07/16/itcppcon19/ Tue, 16 Jul 2019 06:18:50 +0000 https://www.italiancpp.org/?p=9104


The 4th edition of the Italian C++ Conference took place at Politecnico di Milano last June 15th.

The awesome day opened with a very special keynote by Andrei Alexandrescu.

The conference was attended by ~240 people, 20% more than last year. The drop rate was about 23%, slightly higher than last year.

As always, I have co-organized the conference with Alessandro Vergani. In addition, the staff on-site included: Guido Pederzini, Raffaele Rialdi, Illya Dudchenko, Gian Lorenzo Meocci, Federico Ficarelli. Thank you guys!

Some news: first of all, the conference was hosted for the first time at Politecnico di Milano, which I would like to thank. In addition, since I have recently co-founded a not-for-profit association – Community Crumbs – attendees could optionally donate to help cover the main costs.

As usual, the conference was totally free. We could rely on some companies and some donations to cover the event costs (slightly less than 8’000 €):

  • Coffee break in the morning, lunch and some beverages in the afternoon (~4’300 €)
  • Video recordings and technicians (~1’000 €)
  • Air conditioning – oddly enough, that’s not free (~800 €)
  • Badges, stickers and some other gadgets (~300 €)
  • Staff & Speakers dinner (~800 €)

I would like to thank all the companies which supported the conference: KDAB, JFrog/Conan, AIVJetBrainsSigeoDeveler, Hexagon. Moreover, a big shout-out to 32 people who donated (~10% of the total number of registrants).


Last but not least, thanks to all the speakers and to all the attendees!

I have published several pictures of the event here on our Facebook page.

Here is the beautiful “itCppCon19 Panorama”:


Some stats

We have some stats, as usual.

Attendees gender:

  • male: 224 (registered 289)
  • female: 16 (registered 21)

Age average: 36

Responses to the C++ survey:

(less than the total number of registrants because I have discovered that registrations from Facebook bypass the survey…).

Structure and contents of the event

The Italian C++ Conference 2019 was a full-day event about C++ development with 1×90′ keynote and talks arranged in two parallel tracks throughout the whole day: 8×50′ talks, 2×30′ short talks and one 20-min featured talk during lunch.

Networking and breaks: 1h before the kick-off, 2×30′ breaks (1 morning, 1 afternoon) and 75′ lunch break. We offered a coffee break in the morning and a lunch meal. In the afternoon, beverages were available for free.

The whole agenda was in English (slides here and videos here). Andrei Alexandrescu gave an awesome keynote Allegro Means Both Fast and Happy. Coincidence?. Other talks were about several other topics like C++20 (Modules, Concepts, Coroutines), Cross-platform development, Link time and profile guided optimization, CONAN C++ package manager, Entity Component System pattern. Check out the event page for more details including links to videos and slides.

Feedback

About 55% of attendees gave feedback. I am glad for the results:

Best #itCppCon19 tweets

Our events come with prizes only for “best tweets”. The definition of “best tweet” is unspecified though…A few are listed below:

 

 

 

What’s next

We have already started the co-organization of the C++ Day 2019. We are just waiting for the official confirmation from the university but it should be in Parma on November 30. Save the date! The call for sessions will hopefully open in a few weeks. The event is co-organized with the Robotics Team of the University of Parma.

I am looking for speakers for the second half of the season of monthly C++ meetups in Modena, hosted by ConoscereLinux. If you like to give a talk, moderate a workshop, or moderate a roundtable, etc. please get in touch (myname [at] italiancpp [dot] org).

I am proud of Coding Gym and I keep on investing time and effort on this project. We have launched the format in two new cities (Bassano Del Grappa and Bari) and we have our yearly “trainers summit” on July 27 in Bologna.

As said before, I have co-founded and I am the president of Community Crumbs, a not-for-profit association. We have lots of work to do on this newborn project.

That’s all. See you soon!

]]>
9104
C++ Day 2018 https://www.italiancpp.org/2018/12/08/cppday18/ Sat, 08 Dec 2018 15:15:43 +0000 https://www.italiancpp.org/?p=8892

Two weeks ago, on November 24th, we had an awesome day about C++ in Pavia: the C++ Day 2018. We co-organized this event with the University of Pavia and in particular with two proactive guys: Riccardo Brugo and Federico Pasqua. The event was hosted by the Physics Department and by the director Alberto Rotondi which actively supported the C++ Day. Many thanks to all the people involved and to the university!

The C++ Day 2018 had ~110 attendees, like the previous edition in Modena.

The event was possible thanks to a joint effort between a few people from the Italian C++ Community staff (Alessandro Vergani, Illya Dudchenko and I) and the local hosts Riccardo, Federico and the Physics Department of the University of Pavia.

That’s all about the C++ Day format: a joint effort between the Italian C++ Community and a local host. As I told during my welcome and closing messages, the call for C++ Day 2019 is open! The C++ Day needs two things:

  • an event location with at least 2 rooms with 150 seats each and some space for catering and sponsor stands. Possibly free;
  • some support to co-organize the event. Let’s speak about it.

If you are keen on hosting the C++ Day 2019, please get in touch! And if you have just questions, ask!

The C++ Day 2018 had two sponsors which I would like to thank again:

Last but not least, thanks to all the speakers and to all the attendees!

I have published several pictures of the event here on our Facebook page.

Some stats

We have some stats, as usual.

Attendees gender:

  • male: 89,
  • female: 8,
  • not declared: 9.

Attendees coming from abroad: 5.

Responses to the C++ survey:

Structure and contents of the event

The C++ Day 2018 was a full-day event about C++ development with 1×90′ keynote and talks arranged in two parallel tracks throughout the whole day: 8×50′ talks and 2×20′ short talks.

Networking and breaks: 1h before the kick-off, 2×30′ breaks (1 morning, 1 afternoon) and 90′ lunch break. We served snacks, coffee and drinks during both the breaks and we could even offer a full meal at the university restaurant to everyone thanks to the sponsorships.

Less than half of the talks were in English (slides here and videos still to be published). John Biddiscombe gave the keynote HPX : High performance computing in C++ with concurrency parallelism and futures, very appreciated according to the feedback received. Other talks were about several other topics like C++20, GIS in C++, Optimization, Templates, Reflection, AI, Algorithms, …Check out the event page for more details.

Feedback

As it usually happens, about 50% of attendees gave feedback. I am personally very happy about the results:

Best #cppDay18 tweets

Our events come with prizes only for “best tweets”. The definition of “best tweet” is unspecified though…A few are listed below:

What’s next

We are diving into the organization of the Italian C++ Conference 2019. It will be in Milan, as usual, but we don’t have a confirmed setting yet, so we are considering alternative locations. If you know one, please get in touch!

In 2019 I will keep on arranging monthly C++ meetups in Modena, hosted by ConoscereLinux (which I have been recently joined the official council).

In addition, I am putting a lot of effort and time to direct Coding Gym that we will bring to new cities in 2019. As a trainer, I will keep on organizing Coding Gym in Modena on a monthly basis.

Coding Gym is a place where we practice expressing ourselves through programming and collaboration. I put emphasis on “expression of ourselves” because it’s what I consider our most important thing as human beings. If you like knowing more about Coding Gym, just come over. If you cannot, visit the website or drop me an email ($myName [at] italiancpp [dot] org).

That’s all. See you in 2019!

]]>
8892
Italian C++ Conference 2018 https://www.italiancpp.org/2018/07/08/itcppcon18/ Sun, 08 Jul 2018 16:24:01 +0000 https://www.italiancpp.org/?p=8714

 

 

On June 23, 200 people swarmed in Milan and attended the Italian C++ Conference 2018, one of the Italian C++ Community event formats. Again, we had a sensible drop rate (~28%) and we are discussing ideas to contain such a phenomenon in the future. Anyway, our target has been achieved: 200 attendees. The event fell the day before the community turned 5 and then I put on something a bit more special during the welcome message.

The event was hosted at Università Bicocca which I would like to thank a lot. Bicocca hosted us for the third year in a row!

As usual, the Italian C++ Conference 2018 has been organized starting from no budget and relying only on sponsorships. As I told during the event kick-off, two main things constrain the number of available (free) tickets: 1) number of (physical) available seats, 2) food and drinks. The former is free (thanks to our host) and the latter is generally quite expensive (e.g. 1 coffee break + 1 lunch for 200 people = 17.5 € + VAT per person).

This year we had 10 sponsors and thanks to such a huge number of contributions we were able to fit our budget a proper catering and also some extra gifts for all the attendees like: fully customized badges and lanyards, C++ bags, C++17 cheatsheets (last year we bought them), C++ stickers.

See some pictures of the conference.

A big shout-out

I led an awesome staff. As usual, Alessandro Vergani and Guido Perderzini played with me fundamental roles in the event organization. At the event, Marco Foco, Illya Dudchenko, Gian Lorenzo Meocci and Raffaele Rialdi joined us and gave a huge support. Thank you all guys!

Thanks to our speakers: Peter Sommerlad, Alberto Barbati, Paolo Severini, Anastasia Kazakova, Diego Rodriguez-Losada, Emanuele Bartolesi, Vittorio Romeo, Raffaele Rialdi, Denis Panin, Felix Petriconi. Thanks for sharing your great ideas and stories!

Thanks to the conference sponsors: Bloomberg, JFrog/Conan, AIV, JetBrains, AresysRecognition Robotics, Sigeo, Develer, COMELZ, KDAB.

Last but not least, a big shout-out to our awesome 200 attendees!

 

 

 

Some stats

As usual, when people sign up for the event we ask a few questions about their experience with C++ and tools. Let me share some data with you.

Attendees age:

  • oldest attendee: 59,
  • youngest: 16,
  • average: 39.

Attendees gender:

  • male: 100,
  • female: 6,
  • not declared: 94.

Attendees coming from abroad: 35.

Responses to the C++ survey:

Structure and contents of the event

The Italian C++ Conference 2018 was a full-day event about C++ development with 1×90′ keynote and talks arranged in two parallel tracks throughout the whole day: 8×50′ talks and 2×20′ short talks.

Networking and breaks: 1h before the kick-off, 2×30′ breaks (1 morning, 1 afternoon) and 70′ lunch break. We served food and drinks during the first coffee break and lunch (actually left-overs were served on the second break too, although that was not planned).

Most part of the talks were in English (slides here and videos here). Peter Sommerlad gave the keynote ABC – Agile BMWs and C++: 30+ years as a Software Engineer, very well received. Other talks concerned several topics:

Organization notes

I’d like to log a few notes about organization it’s worth recording (at least for me):

1) This year, for the first time, the conference took place on two floors. I was strongly against placing the catering on the first floor and the rest of the conference on the ground floor, however we had no choice due to new policies of the university. Anyway, the event went well but a few people (and a sponsor) flagged this as a possible problem.
Action for next year: negotiate a single floor, although this will requires to change building and thus paying some money.

2) I had overhead with a few suppliers, in particular those I had to visit, email or call (instead of doing everything from a website). The final result was fine but I had to push for proceeding with the job.
Action for next year: try to buy everything online or press this year suppliers from the very beginning of the organization.

3) For the first time in 5 years I went to the conference setting the day before to set things up. In particular, Alessandro Vergani and I unloaded boxes from suppliers/sponsors and we brought them to the university. In addition, we prepared all the “C++ bags”. This would have required too much time the day after. On the other hand, our video makers had time to try lights, sound and could fix a few issues they found with the system. Having this half-day at the university was a killer feature for the conference.
Action for next year: take advantage of such a time slot and set up an even more detailed plan to save time the day of the event.

Feedback

As it generally happens, about 50% of attendees gave feedback. In general it was quite good and I am very happy that the community has appreciated our effort.

Best #itCppCon18 tweets

Our events come with prizes only for “best tweets”. The definition of “best tweet” is unspecified though…A few are listed below:

 

 

 

 

What’s next

As announced at the event and here, I am driving the community towards an aggregator model where we keep on organizing activities and events, but we also help other people make C++ events and activities in Italy by patronizing them. The very first “implementation” of such a model will be the C++ Day 2018 in Pavia, on November 24th. Riccardo Brugo and Federico Pasqua are are leading the organization of this event and we are working with them.

Read here (in Italian) if you are interested in this model.

]]>
8714
5 years of italiancpp https://www.italiancpp.org/2018/06/24/5-years-of-italiancpp/ Sun, 24 Jun 2018 06:00:52 +0000 https://www.italiancpp.org/?p=8644 Time flies. Today of 5 years ago I officially launched this website to the world.

Happy birthday ++it 🙂

I believe that 5 years is a great milestone. When I started the community, from scratch, my network was relatively small and I didn’t have any previous experience in managing something other than a small project developed in the spare time with a few friends.

I didn’t care about the difficulties I would have face with, I was pumped for this new adventure and I just wanted to go live and put myself on the line.

A community is about people and I’d like to say thank you to all the people who have joined and supported the Italian C++ Community during the last 5 years. Some people have been very important for this tribe, in particular the staff members helping behind the scenes. At the very beginning I started with Franco Milicchio, Raffaele Rialdi, Stefano Saraulli, Alfredo Di Napoli and Davide Di Gennaro. Along the way other great people joined the group. It’s worth mentioning in particular Alessandro Vergani, Guido Pederzini, Marco Foco, Illya Dudchenko and Gian Lorenzo Meocci. Thank you all!

I would like to recall some numbers and important dates:

  • Website officially born on March 26, 2013
  • Public announcement on June 24, 2013
  • First public appearance of the community on February 26, 2014 at Community Days, where we looked after an entire track about C++. 50 people attended.
  • First meetup on June 28, 2014, half-day + lunch. 30 attendees
  • Last event: “Italian C++ Conference 2018” on June 23, 2018. 200 attendees.
  • Total number of events organized: 15
  • Total number of events attendees: 1040
  • Newsletter subscribers: 1000+

For the last 5 years, our commitment has been spreading around C++ best-practices and good resources, and connecting people with the Italian C++ ecosystem through the online community and events. We have organized events, given dozen of talks, facilitated workshops and produced articles and tutorials about C++, connected with other communities and events (not only about C++).

I feel like sharing some words about the story of the community.

When and why everything started

In 2012, while I was watching Going Native 2012, I started wondering why we didn’t use to have events about C++ in Italy. We had dozen of conferences every year about other topics but C++. We didn’t have any user group neither.

Then, a very “simple” idea started forming in my mind: “I want to organize an event about C++ in Italy”. My target was not so ambitious, I thought.

The first thing I asked myself was “What do I need to make an event?”. I thought a bit and then I answered “People”. That was my very first naive thought. That was true: events come with people. Management, logistics, money, badges, etc come afterwards. I needed to get people involved.

Then I decided to start something, with a low profile. I made two social groups, inspired by “C++ Enthusiasts” – a Facebook group that was really popular at that time and I made a Facebook and a Linkedin group about C++ in Italy.

“How do I call such groups?” I asked myself.

“What about ++it?” I thought.

++it, condenses everything: it recalls both Italy and the classical iterator name – a typical C++ concept. The prefix ++ is for both C++ and also for advancing such an iterator in a C++ish manner – as opposite to it++. “I like it!” It was love at first sight. Probably a rare case of me being exactly right at naming!

Anyway, we were at the end of 2012 and such groups did not achieve a resounding success. I used to share news and resources about C++ on the groups but they were missing something fundamental: Community. They were just cold groups. A Community is made up of people and relations. A community needs to be fed, continuously.

Dropping a few comments about articles and videos was not about building up a community.

A few months passed. At the beginning of 2013 I didn’t have time nor mind to think about my project: my mum passed away on Feb 2.

I took a few weeks for myself and then I gave me two options: giving up or turning around.

I chose the latter, as you know because you are reading this article.

I’ve always thought that, in a sense, my loss drove my commitment. Maybe my life needed to compensate, somehow.

Then I started, seriously. I put 100% of myself into the project, into the ideal.

On March 26th I bought the domain italiancpp.org.

Afterwards, I spent some time writing down a mission and setting up targets for my community. Although ++it has never been part of my job, I’ve took it professionally from the beginning. I think this point has been very important for the evolution of the community.

The community’s mission is:

  • spreading C++ in Italy by promoting news and resources;
  • involving and connecting people interested in C++;
  • supporting and helping beginners and students with C++;
  • easing relationships between companies and people interested in C++;
  • making events and meetups about C++.

In a few words: ++it’s mission is to be the C++ landmark in Italy.

The rest of the story might be covered in future articles.

++it Rejuvenation

I’d like to spend a few words on the massive “refactoring” I did in Summer 2016.

In 2016, after 3 years of experience with ++it, I developed a new vision on how to deliver contents and offer interactions to my tribe.

If you used to be a ++it user before that time, you remember we had a forum. Running statistics on the usage, I noticed it was more or less unused or visited mostly by beginners. But actually, people loved discussing in several other channels like facebook, emails, etc.

I started elaborating this idea of making ++it an aggregator of ways to interact. I coined the term interaction proposals: as a community leader, I basically offer to my tribe several ways to communicate, interact and build up relationships, all at the very same level. It’s up to them which one(s) to use, I cannot decide for themselves. My task is to make all such proposals at the same experience level. At that time, the forum was my first citizen choice. That was a mistake.

In addition, I worked a bit on setting up a more modern and engaging theme. The final result has been online since August 2016.

At the end, I got rid of the forum and then I disabled the registration of users (they can only subscribe Slack and the newsletter). I replaced the forum with a dedicated subreddit and put more effort and moderation on Slack channels. The forum is not the central point of the community anymore. In addition, I worked on a code of conduct.

Here are the activities and the interaction proposals of the community:

  • Social channels (Twitter, Facebook, Linkedin)
  • Slack team
  • Subreddit
  • Articles
  • Newsletter
  • Job offers
  • Events, meetups and other social activities

Moreover, I set up a bit of automation among some of the channels above. This way all the interaction proposals have exactly the same rank and importance. People won’t miss updates just because they don’t use Slack, for instance.

For example, when I tweet adding the hashtag #news, a bot spreads the same content to Facebook and Slack. Also, the full stream of filtered tweet will be sent via newsletter at the end of the month. I could cover this automation in a future post, if you are interested.

Next plans

“5 years have passed. What’s next?”

You know, when you reach such milestones, you have to look at the future and set the next milestone(s).

Not being conceited, I think my originary targets have been achieved: ++it is the C++ landmark in Italy. I am glad when people tell me that ++it has been useful for finding job opportunities or important connections, when I read amazing discussions on Slack, and when students find help. Moreover, it’s very significant that companies ask my support for recruitment in the italian C++ ecosystem.

I have not mentioned that I have developed a simple program to help companies find C++ developers. If you are a company and you need such a service, please visit this page (it’s in Italian, though).

During the years, I have refined my original vision on ++it by introducing interaction proposals, I have previously described. From one hand, I have worked a lot on the platform/website itself by aggregating digital services and communication channels like reddit or Slack. However, I believe I need to put more effort on openness. Let me explain.

My next target is to reinforce the concept of ++it as an aggregator of activities and events not directly organized by our core team. Basically, ++it will help people make activities, meetups and events about C++ in Italy.

++it will patronize such events by flanking organizers and will offer visibility, network and advertisement. After 5 years we have experience and network to empower willing people who want to make C++ activities in our country. I feel lonely at doing monthly C++ meetups in Modena! Why not having meetups in Milan, Rome or Florence?

As I announced yesterday at the Italian C++ Conference 2018, the very first experiment of this model is the organization of the C++ Day 2018, expected for November 24th in Pavia, which has been in the pipeline for some months, driven by Riccardo Brugo and Federico Pasqua, willing students at University of Pavia. I’ve been supporting such good guys for some time but the biggest part of the job is on their shoulders. I will join the full organization during Summer.

Adopting this model, I imagine the following activities:

  • (at least) 1 event per year fully organized by the core-staff (e.g. Italian C++ Conference);
  • (at least) 1 season of monthly meetups set where I live (Modena, at the moment);
  • any number of meetups and events patronized by ++it but not 100% organized by the core-staff;
  • usual core tasks like managing the community, selecting resources and news, making the newsletter, etc still ~100% on me.

If you are interested in running events, activities or meetups about C++ in Italy, even small ones, please get in touch. ++it and I will be very happy to help and give support!

I have written this page (in Italian) with more details.

Italian C++ Conference 2018 Staff. From left: Marco Foco, Raffaele Rialdi, Guido Pederzini, Marco Arena, Illya Dudchenko, Alessandro Vergani, Gian Lorenzo Meocci.

 

That’s it for now! Thank you very much for reading. I hope to meet/see you in person very soon.

Marco Arena, founder and president of the Italian C++ Community

]]>
8644
C++ Day 2017 https://www.italiancpp.org/2017/12/11/cppday17/ Mon, 11 Dec 2017 18:48:01 +0000 http://www.italiancpp.org/?p=8356

At the beginning of December, on the 2nd, the Italian C++ Community hosted the C++ Day 2017 and about 110 people gather together. The drop rate was the lowest I have ever seen: ~8% (120 tickets emitted). This free event was hosted at Centro Culturale Giacomo Alberione, an historical location in the lovely center of Modena.

As usual, the event has been organized with no budget. Only a few sponsors covered the main expenses. Guido Pederzini was the event co-organizer and, above all, he found and was responsible for our charming location. Guido and I organized this event in a few weeks. Initially, the plan was to do it in Bologna. However, at the beginning of September, an agreement I had with some people there fell through (you know, bureaucracy…). Then we restarted from scratch, in September, with no location, no sponsors and just a few confirmed talks. Giving up? Not me.

I pushed a lot for having this event because I think continuity is important. I am committed to be directly involved in the organization of 2 main events about C++ in Italy every year. My target is to keep alive this “italian” dialogue about C++ that I have started about 5 years ago.

Guido is from Modena and he found this beautiful location in the center of the city. Just a few days later we made a visit to this place and then we set the event live on our website.

Honestly, after the huge results of the Italian C++ Conference 2017, my expectations for the C++ Day 2017 were simply lower. Only one track, no money for lunch and a location with “only” 100 seats.

I was wrong.

The available tickets got sold out in 3 weeks and people started flooding the wait-list shortly after. We ended up emitting more tickets than available seats. That’s normal for free events because organizers have to take into account some “drop” (people who subscribe but at the end don’t show up). Then we had 120 tickets but our room could accommodate at most 100 people. Guess what? 110 people showed up! Thus the room got full packaged and we needed to add some additional seats on the fly. This clearly caused some inconvenience.

My apologies for that, it’s our fault. Mine, firstly.

Apart from that, the event was really pleasant and the feedback we have received so far confirms my feeling.

Modena was a great location! During the last two years I have created some activities here in Modena (above all: Coding Gym and C++ meetups), thanks to my collaboration with ConoscereLinux (Modena Linux User Group). In the future I’d like doing more stuff in this city.

THANK-YOU!

Let me spend some kind words to thank who made the event possible:

The co-organizer Guido Pederzini and the rest of the staff Alessandro Vergani and Illya Dudchenko. A few awesome people! Thank you.

Our sponsorsRecognition RoboticsSigeo srl, Elettric80. Thanks for your big support!

The speakers: Carlo Pescio, Stefano Cristiano, Daniele Pallastrelli, Alberto Bignotti, Sebastiano Galazzo. Thanks for sharing your stories with the ecosystem!

Centro Culturale Giacomo Alberione, for hospitality and support. Thanks a lot!

Last but not least, a big thanks to 110 people who attended the C++ Day 2017! You are amazing!

Some stats

As usual, some data about the attendees.

Attendees age:

  • the oldest: 58,
  • the youngest: 19,
  • the average: 35.

Attendees gender:

  • gentlemen: 105,
  • ladies: 5.

Responses to the C++ survey:

(I don’t use C++ at work – Rarely – At least half of the time – Daily/Most of the time)

 

(I don’t know C++ – Novice/Student – Fluent – Expert)

 

(I don’t use C++ – C++98/C++03 – C++11 – C++14 – C++17)

 

(Boost – Qt – MFC – POCO – JUICE – Scientific Libs – Graphics Libs – Physics Libs – Other)

 

(VS – CLion – Eclipse – VSCode – DevC++ – QtCreator – VAX – ReSharper++ – Other)

 

Structure and contents of the event

The C++ Day 2017 was a single-track full-day event consisting of 5×60′ technical talks, 2 coffee breaks (30′ each) and a long lunch break (90′ – people formed groups and went around the center of Modena). The talks (all in italian):

  • (Slightly) Smarter Smart Pointers by Carlo Pescio
  • C++ and UI: un unorthodox approach by Daniele Pallastrelli
  • Immediate Mode Graphical User Interfaces in C++ by Stefano Cristiano
  • C/C++ interoperability with other languages by Alberto Bignotti
  • Artificial Intelligence Today by Sebastiano Galazzo

Slides and links

It’s worth mentioning that Sebastiano Galazzo is currently the only italian holding a Microsoft MVP title for the category AI. I was very happy to invite him talking not strictly about C++. The most part of the attendees appreciated the idea too (according to the feedback).

And…a special guest joined the event for a few minutes:

Thanks to Herb Sutter for his message! This was a surprise for the people attending, even if, due to technical issues, I was not able to play it at the beginning of the event as I planned but just after lunch.

Videos of the talks are on YouTube.

Feedback

Less than 50% of the attendees left feedback. The feeling was quite good and it seems that only that inconvenience with the seats penalized the event a bit. This was definitely a 4-star events. Some charts follow:

 

 

 

 

 

(Learning new things – Peeking at what others are doing – Networking – Job opportunities – Business opportunities – Having fun)

#cppDay17 and quizzes

You know we always give gadgets and prizes during the event. Prizes come with tweets but, this time, I decided to give a chance to quick quizzes. These consisted in understanding the output of a few lines of C++ code. The snippets were always an application of an STL algorithm.

The first snippet was something like:

vector<int> v = {1,2,3,4,5};
cout << accumulate(next(begin(v)), end(v), 2);

Here you just have to notice the summation starts from the second element and the accumulator is initialized with 2.

The second exercise:

vector<int> v = {1,2,3,4,5};
reverse(begin(v)+2, end(v));
reverse(begin(v), begin(v)+2);
reverse(begin(v), end(v));

One person got it right and he won a prize. Afterwards, I asked: “what’s this code really about? Are you able to replace the last three lines with only one?”.

A couple of smart guys replied: “rotate“. Indeed, std::rotate was the answer:

vector<int> v = {1,2,3,4,5};
rotate(begin(v), begin(v)+2, end(v));

This exercise was inspired by the last Coding Gym I moderated in Modena a few weeks ago. The final challenge was about shifting an array and Roberto Melis proposed this solution to emulate std::rotate (rotate would have been the easy solution, however we set up the constraint “don’t use rotate or such”). Many people learnt something new!

The last snippet was copied from cppreference:

std::vector<int> v(10);
v[0] = 1;
adjacent_difference(v.begin(), v.end() - 1, v.begin() + 1, plus<>{});

This is basically filling v with the first 10 Fibonacci numbers. A bit of explanation here:

adjacent_difference computes the differences between the second and the first of each adjacent pair of elements of a range. The result is written into another range, eventually overlapping with the input. In the snippet, the operation is “plus” (sum), and input and output lean on the same range: the input begins from the first element, the output begins from the second. This way, adjacent_difference will output the sum between the first and the second elements into the third, between the second and the third into the fourth, and so on (remember the first step of adjacent_difference is always to copy the first input straight into the destination):

v[0] -> v[1]
v[0] + v[1] -> v[2]
v[1] + v[2] -> v[3]
...

Regardless the application of this particular snippet in real-world code, I think it’s very instructive to see patterns and how they work. That’s one of the pillars of my Coding Gym.

A couple of pictures of the winners (thanks to O’Reilly Media for free books):

What’s next

We already have some activities in the pipeline.

In 2018 I will keep on organizing Coding Gym and I have new plans for that. Please get in touch if you want to set up a monthly Coding Gym  in your town. On Jan 9 evening I’ll be speaking and demoing about Coding Gym in Bologna, at XPug January meetup.

We are checking the waters for the Italian C++ Conference 2018. We need sponsors and we’ll open a call for papers at some point. Please get in touch if you are interested.

It’s likely that, before Summer, we’ll have another C++ event that a few good guys from Pavia are looking after. The Italian C++ Community will patronize such event and the “historical” staff will get somehow involved in the organization (me, firstly).

]]>
8356
Italian C++ Conference 2017 https://www.italiancpp.org/2017/07/04/itcppcon17/ Tue, 04 Jul 2017 17:12:48 +0000 http://www.italiancpp.org/?p=8120

 

Last June 17 we had the Italian C++ Conference 2017 in Milan, one of the events totally focused on C++ organized by the Italian C++ Community that I lead and manage. ~230 people signed up for the conference and about 160 attended. We are really disappointed about the drop rate (~30% – higher than usual). Probably, the nationalwide transport strike that happened in Italy the day before did a number on the conference.

The event was hosted at Università Bicocca of Milan.

The event was the biggest one I ever organized: 160 attendees, 7 sponsors10 technical sessions splitted into two tracks, a panel on diversity and inclusion and, above all, no budget! Indeed, the event was totally free and realized thanks to the support of the sponsors and me and my staff’s willingness. I love spending a good part of my spare time (and also some nights) on organizing free meetups, activities and events for people who want to join the ecosystem.

I really enjoyed the event, the vibes were great and I met many new people!

Find here a bunch of pictures of the event.

 

THANK-YOU!

Let me spend some kind words to thank who made the event possible:

My staff, in particular: Alessandro VerganiGuido Pederzini, Marco Foco, Raffele Rialdi, Illya Dudchenko, Davide Di Gennaro, Franco Milicchio, Gian Lorenzo Meocci. You are awesome, thanks a lot!

Our sponsors: Bloomberg, JetBrains, KDAB, Think-Cell, Abaco Group, Recognition Robotics, JFrog/Conan. Thanks for your big support!

Our outstanding speakers: Michael Wong, Phil Nash, Bartosz Milewski, Jens Weller, Dietmar Kühl, Raffaele Rialdi, Davide Di Gennaro, Paola Presutto, Carlo Pescio, Stefano Cristiano. Thanks for sharing your experiences with the ecosystem!

Università Bicocca, for hospitality and support. Thanks a lot!

Last but not least, a big thanks to ~160 people who attended the Italian C++ Conference 2017! You rock!

 

Some stats on the audience

As usual, when people sign up for the event we ask a few questions about their experience with C++ and tools. Let me share some data with you.

Attendees age:

  • oldest attendee: 64,
  • youngest: 14,
  • average: 36.

Attendees gender:

  • male: 148,
  • female: 7.

Attendees not coming from Italy: 20.

 

Responses to the C++ survey:

(I don’t know C++ – Novice/Student – Fluent – Expert)

(I don’t use C++ at work – Rarely – At least half of the time – Daily/Most of the time)

(C++98/C++03 – C++11 – C++14 – C++17)

(for some unknown reason, Evenbrite normalized this histogram in 0-92 but the chart is actually based on the whole set of data).

(VS – CLion – Eclipse – VSCode – DevC++ – QtCreator – VAX – ReSharper++ – Other)

(Boost – Qt – MFC – POCO – JUICE – Scientific Libs – Graphics Libs – Physics Libs – Other)

 

Structure and contents of the event

The Italian C++ Conference 2017 in numbers:

  • 8×60′ (parallel) technical sessions
  • 1×75′ (plenary) keynote
  • 1×45′ session on diversity and inclusion
  • 1×20′ interactive panel on diversity and inclusion
  • 130′ allocated for breaks and networking

We had two plenaries (the keynote and the session on Diversity and Inclusion by Microsoft) and two parallel tracks (one in Italian and the other in English).

Our outstanding keynote speaker Michael Wong talked about C++ executors to enable heterogeneous computing in tomorrow’s C++ today.

The other sessions:

We also hosted an interactive panel on diversity and inclusion moderated by Charlotte Zhao and Andrea Chiarini from Bloomberg:

Diversity Panel by Bloomberg

Videos are in post-production and (I hope) will be published by the end of July. Further communication will follow.

 

Feedback

This time ~60% of attendees gave feedback. It’s been very good so far and I’d like showing you some charts (1 corresponds to the minimum rate, 5 to the maximum):

 

#itCppCon17 and gifts

As usual, we set up a social contest and awarded the “best tweets” with hashtag #itCppCon17.

 

 

 Some winning tweets and reactions after being awarded:

 

Thanks to O’Reilly Media and Manning for the free books!

 

What’s next?

Well, my mind is already heading towards the second annual event that we usually organize: the C++ Day. My staff and I would like to make it happen in Bologna or Modena by December…we’ll keep you posted! If you are keen on helping or sponsoring please get in touch.

Thanks to all!
]]>
8120
Singleton revisited https://www.italiancpp.org/2017/03/19/singleton-revisited-eng/ https://www.italiancpp.org/2017/03/19/singleton-revisited-eng/#comments Sun, 19 Mar 2017 15:52:43 +0000 http://www.italiancpp.org/?p=7740 It happens quite often to deal with those annoying objects, used everywhere in your applications. This may be because of a poorly designed application but, sometime, it is simply an inevitable condition. With this in mind and considering that either a design refactoring to remove the global dependence is, sometimes, not affordable because of business needs or not convenient because it leads to more complex code, I’ll try to propose a non-canonical solution to the problem.

The obvious solution is the global scope, but we all know that it is also something which is better to avoid if you don’t want to run into sneaky problems, easy to cause and way more complicated to solve. We learned to be wary of the use of the global scope, as it is indeed a bad programming practice often causing long debugging sessions. But the problem still remains as it is at least useful (sometime necessary) to have variables valid within our whole program.

To bring to light the most relevant cons concerning the use of the global scope, we need to consider that its use involves the impossibility to count on data consistency. Furthermore, those variables can be modified at any time without us, as programmers, being really aware of it.

The global sharing can be a necessity, that’s why a standard pattern like Singleton exists. Ok, this pattern does something more, enforcing the uniqueness of a given type instances, however, at least as far as my own experience is concerned, the use of Singleton is often justified by the will of being able to easily refer to a unique object from any point effortlessly.

I’ll try to describe an alternative which, from my perspective, can work better.

A typical case

A typical example is the implementation of a logger to be used application wide. If you don’t want to pass that object around, as a parameter in each and every function and constructor, you’ll probably implement that object as a Singleton.

At a first glance, it is a good idea, it must be unique and shared. This snippet below is a quite standard implementation:

class Logger{

  Logger() = default;

  public:

  static Logger& get(){
    static Logger instance;
    return instance;
  }

  void log(std::string s){
    std::cout << s << std::endl;
  }
};

Ok, this is quite nice, it achieves the result and also avoid troubles with resource acquisition and release, which you may have defining the instance as a private class member.

But the Singleton is a weak choice because it enforces the uniqueness of the object for the whole application life and this is not what we really want.

Let’s suppose that we need to log the activity of a really long function, and that we want to log to a different file every time the function is executed. (In the following examples I’m omitting some details for simplicity).

void g(){ 
   singleton::Logger::get().log("do something");
}

void f(){
  singleton::Logger::get().start();

  singleton::Logger::get().log("call g()");
  g();
  singleton::Logger::get().end();
}

start and end methods are there to open and close a new file to log to. It works decently but it’s probably not the most beautiful code you’ve ever seen. Too many things can go wrong once that snippet become part of a much more complex application.

Let’s suppose that the functions you need to log the activity are many, for each of them you need to insert that calls to open and close the file to ensure other function are logged the right way. What if you forgot to close the file at the end of one of those functions? The next call would open a new log file leaving the old one open. And what if in the next call you don’t even open the new file? It will continue to write to the old one causing an unexpected behaviour.

As programmers our task is to write error-less code and, as it is a hard one, the best way is to design things so that they are not error prone.

In the example above, the first reference to the Singleton creates it but still does not really initialize it. At that point, even if we have the object, we can’t use it but after some preliminary action. Moreover, we’d like not to be able to refer to a resource once it is released, as it happens after the file is closed in the example. Ultimatly, the problem, in that example, is that the Singleton is doing more than what we really want it to do. The logger must not be unique and accessible during the whole application life but only for a part.

This Singleton’s limit has become clear to me when I was asked to put such a resource under test. In that case it was not a logger but a global component that, once under test, was to become local to the test. In practice I had a global (an exotic one implemented as a Singleton but still a global) to handle. That led me to try some variation on a theme, till I realized that I was searching for something like dynamic scope.

C, C++, Java, C# and many other languages, bind names to addresses using the static scope mechanism. That is, statically looking at the code, it is possible to decide which is the definition a variable name is referring.

int i;

void f(){
  int i=9;
  b();
  // here i refers to the local variable
}

void b(){
  // here i refers to the variable in global scope
   
}

void a(){
  // here i refers to the variable in global scope
  i= 3;
  b();
  f();
}

Using dynamic binding, instead, the variable a symbol refers to depends on the current call stack. In the example above, the name refers to the global or the local defined in f() depending on the call stack that lead to the execution of b().

If we had something like the dynamic scope, we could define a new object each and every time the need for a new resource arises, share it thereafter as it was a global untill the function which acquired the resource terminates and the resource itself is released

In the example below things are a little complicated to make it possible to define into dynamic scope any type even if it requires some parameter to be constructed:

template <typename T>
struct dynamic_scope {
  
  static std::stack<T>& instances(){
    static typename std::stack<T> m_instances;
    return m_instances;
  }

  static T& instance() {
    return instances().top();
  }
                     
  template <typename... Args>
  dynamic_scope(Args... args){
    instances().push(T(args...));
  }

  ~dynamic_scope(){
    instances().pop();
  }
};

void f2(){
  dynamic_scope<Console> the_console (Console(40L, 3L));
  dynamic_scope<Console>::instance() << "log from f2"; 
}; 

void f1(){  
  dynamic_scope<Console>::instance() << "log from f1"; 
  f2(); 
}; 

int _tmain(int argc, _TCHAR* argv[]) { 
  dynamic_scope<Console> the_console (40L, 3L);
  dynamic_scope<Console>::instance() << "log something"; 
  f1(); 
  
  return 0; 
}

What I did here is to enforce the uniqueness of a stack of instances. Every instance override previous one once it is defined and untill it is released.

In the example, main function and f1 log their data in a different Console then the more specific one that f2 uses. Moreover every call to f2 causes the acquisition of a new Console object. Every each time a new dynamic_scope object is created, it is pushed on the static stack. The instance in use is always the one on top of the stack, it will be popped  and destroyed once the corresponding dynamic_scope object comes out of its scope.  At that point, the last overridden instance become the current in use again. The name given to the variable that manages the dynamic scope is not important.

A little programming puzzle can help clarify even more. What’s the output of the following program?

#include <iostream>
#include <stack>

template <typename T>
struct dynamic_scope {
  
  static std::stack<T>& instances(){
    static typename std::stack<T> m_instances;
    return m_instances;
  }

  static T& instance() {
    return instances().top();
  }
                     
  template <typename... Args>
  dynamic_scope(Args... args){
    instances().push(T(args...));
  }

  ~dynamic_scope(){
    instances().pop();
  }
};

void f2(){
  std::cout << ++dynamic_scope<long>::instance() << std::endl;
};

void f1(){
  dynamic_scope<long> the_long(10);
  std::cout << ++dynamic_scope<long>::instance() << std::endl;

  f2();
};

int main(int argc, char* argv[]){
  dynamic_scope<long> the_long(80);

  std::cout << dynamic_scope<long>::instance()  << std::endl;
  f1();
  std::cout << dynamic_scope<long>::instance() << std::endl;
  
  return 0;
}

Here I defined a unique instance of and integer on the dynamic scope. When the program enter main function, one instance of the integer is created on the dynamic scope. Its value is 80 and that is the value sent to stdout.

When the program enter f1(), the integer instance defined in its scope override the previous one becoming the current in use. Its initial value is 10 which is increased by one, so 11, and is sent to the stdout before f2() get called.

In the scope of f2() function, the integer is accessible and it refers to the last instance defined in f1() therefore a new increment makes its value be 12 which is the value printed in f2().

When calls are popped from the call stack and the execution return within main function, the integer instance defined in main() itself is restored as the current in use so that the last instruction still print 80.

Limits

I don’t think this is really a dynamic scope implemented in C++ because we override variables based on their type not their names. We always refer to the unique active instance of type so we will never refer to two different objects of the same type at the same time if they are managed by the “dynamic scope”.

Hope this notes of mine will be useful for anyone.

Write down your idea is a great thing

And it is even better if someone review you.

After I wrote this and asked for a review, the reviewer has pointed out that someone had similar proposal. Bob Smidth, the author of this article published on ACCU-2085, had similar motivations to arrange a design and write his proposal.

Aside the use of the stack that adds features and try to highlight how the little forgotten  dynamic scope concept can be a good solution for a common problem, the approach I proposed here is very close to the one published by Bob. To me, the difference, is in a different compromise between invasiveness and use friendliness.

The tool I wrote here is not the most terse (I mean it is too verbose) but, on the plus side, it makes clear that we are accessing variables that do not follow common scope rules.

I mentioned the invasiveness because I think that the pattern proposed by Bob has the requirement to wrap every interface you want to be a Singleton (or with some modification in the dynamic scope) into a mono_nvi wrapper. This simplify the usage for sure but at the cost of boilerplate.

Anyway the two solutions are really similar, to switch to something really similar to the one in  ACCU-2085, you need just to write that small piece of boilerplate that define a temporary used to access the instance on top of the global stack. This code try to synthesize both approaches:

#include <iostream>
#include <stack>

struct ilogger {
  virtual void info(const char* msg) const = 0;
};

struct logger : public ilogger {
  std::string m_name;
  
  logger(std::string logger_name) : m_name(logger_name){}
  
  virtual void info(const char* msg) const {
    std::cout << m_name.c_str() << ":  " <<  msg << std::endl;
  }
};

template <typename T>
struct dynamic_scope {

  static std::stack<T>& instances() {
    static typename std::stack<T> m_instances;
    return m_instances;
  }

  static T& instance() {
    return instances().top();
  }

  template <typename... Args>
  dynamic_scope(Args... args) {
    instances().push(T(args...));
  }

  ~dynamic_scope() {
    instances().pop();
  }


  struct entry {
    T& m_obj;
    
    entry() : m_obj(dynamic_scope::instance()) { }

    void info(const char* msg) const {
      m_obj.info(msg);
    }
  };

};



void f2() {
  dynamic_scope<logger>::entry the_logger;

  dynamic_scope<logger>::instance().info("from f2");
  the_logger.info("from f2 (simpler?");
}

void f1() {
  dynamic_scope<logger> dynamic_logger("f1");
  dynamic_scope<logger>::entry the_logger;
  
  dynamic_scope<logger>::instance().info("call f2");
  the_logger.info("call f2 (simpler?)");

  f2();
};

int main(int argc, char* argv[]) {
  dynamic_scope<logger> dynamic_logger("main");
  dynamic_scope<logger>::entry the_logger;

  dynamic_scope<logger>::instance().info("call f1");
  the_logger.info("call f1 (simpler?)");

  f1();
  dynamic_scope<logger>::instance().info("returned from f1");
  the_logger.info("returned from f1 (simpler?)");

  return 0;
}

What if you are in a multithread world?

I don’t want to try a solution for Singleton in the multithread realm, but want just to warn about the dangers of such a solution applied in a multithreaded application.

For sure, even if the underlying object is thread safe, you need to synchronize the access to the shared global stack. You can do it using the inner structure entry: integrate a std::lock_guard  into it and be careful to not keep the temporary alive too long. But is a shared dynamic scope really meaningful? To me it is a stretch.

]]>
https://www.italiancpp.org/2017/03/19/singleton-revisited-eng/feed/ 4 7740