Jung’s Synchronicity theory is as fascinating as unscientific. It is “unscientific” because it can’t be proven false by its very own definition – two events appear to be related even if the causal relation is missing. Someone talks about dreaming of a Golden Scarab and suddenly a Golden Scarab hits your window. There is no apparent causal relationship, yet the event pair is so unlikely that the Synchronicity idea has been developed around this. My rational mind is more inclined in thinking of this as a selection bias (countless times it happens something like – you spend a few days away in a city and suddenly the news is filled with stories about this city). Nonetheless, when it happens I always feel uneasy, like the Universe would like to have a word with me.
So when I read the tweet below, by Mario Fusco, in a quite specific job timeframe, I felt called out
In my whole professional career, I always tried to push the boundaries of the language(s) I was using, from assembly to C++, to achieve better engineering, more robust and safer code, fewer bug opportunities, simpler development, and improved collaboration. This meant sometimes introducing the latest C++ standard, sometimes introducing concepts from other languages and sometimes defining DSL with the help of the preprocessor. So I am not new to some raise of eyebrows when people look at my code.
Continue reading “Unidiomatic Solutions and Technical Debt”
It all starts in schools. When they teach you how to program a computer. You get plenty of code that just works in the happy path scenario. So happy path that there are no other paths at all.
And then it is easy to grow, line of code after line of code, with the idea that error handling is not really part of the code. Elegant code has nothing to do with errors. Could be a sort of brainwashing.
And then language designers, present you the ultimate error-handling solution – lo and behold the Exceptions!
You can still write the code the way you were taught and then when something bad happens, throw an exception. A flare fired in the sky, in the hope that some alert patrol on guard could spot and come to the rescue.
Continue reading “Surprisingly Exceptional”
In my previous post, I described how I devised a programming problem for an internal company contest with the help of the ubiquitous ChatGPT. Also, ChatGPT provided a solution for the problem as part of the development process. Even more interestingly the language model provided a fictional context for justifying the problem.
The task was to write a function
removeVowels( string text ) which takes an arbitrary text (arbitrary as long as it contains no uppercase letters) and returns the same string where vowels have been removed. Given the string “hello world”, the result should be “hll wrld”.
The implementation must not have:
- if statement
- list comprehension
If you want to give it a try before reading the solution, stop here. Otherwise, follow me.
Continue reading “Speak Slowly, no Vowels, pls – Solutions”
Back in another era, when I worked for UbiSoft, my then-boss Alain, started a wonderful initiative – the Technical Meeting. Every Friday afternoon, one of us should present a technical argument to the whole team. A good number of Technical Meetings were held, but when the project entered some frantic period. I have fond memories of these meetings.
So I was very happy when I heard that a similar initiative was going to happen at Schindler – the biweekly Technical Session. The idea is very similar – every two weeks one of the colleagues volunteers to make a short technical presentation and give it to the team. Topics are diverse, mainly related to C++. The goal is to have compact presentations limited to 10-15 minutes, ideally including some hands-on parts.
I volunteer for the second topic, which in turn I’ll present here.
Continue reading “Classy Enums”
If you have kept up to date with the latest developments of C++, for sure you have noticed how convoluted and byzantine constructs and semantics have become.
The original idea of a C with Classes at the root of language is long lost and the fabled smaller and cleaner language hidden inside C++ is ever more difficult to spot and use.
The combo – backward-compatibility latch and committee-driven approval/refusal of proposals, make the language evolution spin around. Missing or late additions to the language are sitting ducks, and the lack of networking in the standard library, for a language that is 40, is enough to tell how poorly the evolution of the language is handled.
Continue reading “Nothing lasts forever, but Cobol, Fortran, and C++”
In my last post, I described the first Schindler Milan office weekly riddle. It has been a big success, and it had a brilliant winning solution (one of mine 🙂 ). A simple problem, implementing increment by one without using addition, yet open enough to trigger a good number of solutions.
As the winner, it was my duty to invent the next riddle. A really daunting task if I wanted to live up to the expectations. Honestly, I didn’t invent anything, I just squeeze the web looking for a good programming riddle in the drops.
Eventually, I decided to go for determining the lowest of two numbers… using if-less programming. After all, if statement can be tricky and someone already pointed out that if statement should be considered harmful in the same way the infamous goto is.
Continue reading “What if “if” would go missing?”
Do you remember the good old point-and-click adventures? They provided plenty of puzzles and riddles with a compelling narrative. I loved them, possibly because I love riddles, puzzles, and this sort of challenge. So I was super excited when my employer supported the initiative of a Coding-Riddle-of-the-Week contest. This is the second issue and I’m going to present it here.
Produce a program which increments an integer variable by a value of 1 without using sum or increment operators.
You are pretty free to choose whatever integer size and type you prefer (I would say, but
bool), and whatever language you want. I stuck with C++ because it was quicker, but most of my solutions can be easily ported to other languages.
So, before continuing be sure to give some thought to this riddle to not spoil the fun.
Continue reading “Mom! My plus key is broken!”
Managing errors and failures in every programming language is usually a pain. Most programming book authors just show the happy path scenario, sometimes noting down that error handling has to be done, but it has been left out for improving simplicity (and readability).
C++ offers the exception mechanism, which is a clever way to leave the happy path in sight and hide the troubles under the carpet. Even before questioning if this is a good idea or not, C++ abstraction is so delicate that you need to take particular care in making your code exception-safe. Meaning that in case of exception, your program does not leak resources and leaves everything in a useful state so that the exception can indeed be recovered from.
Continue reading “Dealing with Errors in C++ Using a Lightweight Monadic Approach”
Learning new programming languages helps in acquiring new perspectives and idioms.
Before learning Scala I was perfectly fine with C++ imperative statements, if you want to retrieve a value out of them just change a variable in the outer scope.
Continue reading “Functional statements in C++”
“He Who Laughs Last Is At 300 Baud”, is possibly a long-forgotten joke, but sometimes C++ standard is like using a 300 baud modem, discovering “innovations” tens of years after other less committee-centric languages discover and apply them.
Let’s take the std::optional which tries to mimic the Option monad available in other languages. Since 1990 there has been a resurgence of functional programming languages in the mainstream – Haskell (1990), and Scala (2004) just to name two that have Option since their first version.
Continue reading “What’s wrong with you, std::optional?”