@jhx You asked for it, so I'll answer it:
Imho, C++ design is broken from the very beginning. It wanted to provide #OOP language constructs, still maintaining full #C compatibility (which already failed many years ago, cause the languages took different roads).
It combines #exceptions (IMHO generally a bad idea) with explicit resource management (an *awful* idea, forcing you to use #RAII which will in turn mandate creation of purely "technical" classes, just to manage resources).
It wanted #generics, but that's impossible without breaking C compatibility, so it came up with #templates, actually a #preprocessor on steroids.
Overloading also doesn't fit into the simple C library ABI (where #linker symbols are named just like the function), so it came up with "name mangling" ... which is especially horrific because it is *not* standardized.
Ah well, I could go on 😂
#oop #c #exceptions #raii #generics #Templates #preprocessor #linker
As much as we love #C, we've always felt the lack of a convenient #RAII feature in the language. Yet, many compilers allow to implement such feature with relatively little effort.
So, @micia thought to share such implementation, and our point of view on the subject, in a article.
We’ll be glad to hear your feedback and suggestions before we publish it on our website.
#c #raii #cprogramming #programming #software
As much as we love #C, we've always felt the lack of a convenient #RAII feature in the language. Yet, many compilers allow to implement such feature with relatively little effort.
So, @micia thought to share such implementation, and our point of view on the subject, in a article.
we’ll be glad to hear your feedback and suggestions before we publish it on our website.
#c #raii #cprogramming #programming #software
Il #C ci piace, ma sentiamo spesso la mancanza di un meccanismo di #RAII nel linguaggio. Per fortuna, molti compilatori consentono di implementarne uno con relativamente poco sforzo.
Perciò il buon @micia ha pensato di buttare giù un articolo per mostrare come farlo e spiegare il nostro punto di vista.
Qualcuno abbastanza volenteroso da condividere commenti e dirci se abbiamo sbagliato nulla, prima di pubblicarlo sul nostro sito?
#c #raii #cprogramming #programming
I actually don't hate #rust more the more I use it, which is rather refreshing given how I did come to really hate #golang and what #google has done with that. I do strongly disagree with some specific choices made in rust, though others do make clear sense, and cargo makes project life so simple. I do love how locking can be inserted in front of container access; this feels cleaner than c++ guards, and once again demonstrates why #raii is so essential, not an anti-pattern.
I just noticed that having access to a memory region (mprotect) can be interpreted as having a resource.
Following the #raii principle, that resource can be encapsulated in an object that automatically unlocks the memory when constructed and locks it again when destructed.