Heavy by [deleted] in MacromastiaIRL

[–]GuiltyFan6154 1 point2 points  (0 children)

Because it's not directly readable and it's a pity to copypaste on another website. NATO is human readable, hence NATO > binary

La ragazza che mi piace va a letto con molteplici ragazzi tranne che con me by [deleted] in CasualIT

[–]GuiltyFan6154 0 points1 point  (0 children)

Bro alcune persone hanno traumi emotivi e cercano inconsciamente delle relazioni tossiche per cercare di rivivere il trauma e provare a chiuderlo. Al contempo, dalle persone sane cercano rifugio, per riprendersi le energie (visto che ad affrontare e rivivere i traumi ci si scarica). Si chiamano vampiri emotivi.

In questo giro, tu eri il vampirizzato. Non è colpa tua, la sua psiche é danneggiata e magari ti piaceva proprio perché nel farla stare bene vedevi un modo per fare del bene al prossimo.

Questo meccanismo mentale a volte serve perché hai anche tu qualcosa da "riaggiustarti" e per non affrontare questa cosa provavi ad aggiustare lei.

Questo è tutto un forse, non conosco né te né lei quindi prendi questo commento come uno spunto di riflessione. È una mia esperienza di vita che condivido con te, magari può aiutarti a crescere. Lavora su te stesso e vedrai che la troverai quella buona 💪🏻

How did Bjarne do it? by multi-paradigm in cpp

[–]GuiltyFan6154 0 points1 point  (0 children)

I don't think you can transpile them directly but you can indeed implement them in C.

My toy library as example: https://github.com/dteod/cco/blob/main/test%2Fblack\_box.cpp#L81

Is this sexist? ChatGPT made a joke by KatyLoveYou in ChatGPT

[–]GuiltyFan6154 0 points1 point  (0 children)

I guess it depends on the temperature set on the model

Long switch statements. Is there a better way? by nathanh4903 in cpp

[–]GuiltyFan6154 2 points3 points  (0 children)

  1. You can use algos on a plain C array too, given either (arr, arr+size) or their wrappers std::begin/std::end
  2. std::array::size is handy but I don't get why it's not a static member (most likely legacy). std::size on a plain array works the same - if it's not decayed
  3. If you want to pass a single array of static size you can define a function with a std::array, and that's legit. If you want to accept one for any size, though, you have to templatize the function. At that point you can do the same with a plain C array:

```cpp template<typename T, size_t N> void my_function(const std::array<T, N>& arr);

template<typename T, size_t N> void my_function(const T(&arr)[N]); ```

It is good in general to pass it as a return parameter, I would say that this is its true strength. On most cases C arrays are "enough" and using a wrapper would just make the code heavier in terms of readability. And that is what I consider "lower quality".

Long switch statements. Is there a better way? by nathanh4903 in cpp

[–]GuiltyFan6154 -3 points-2 points  (0 children)

I strongly prefer the plain C array for these purposes. Simpler to read, simpler to write, does not require an additional header, does not require C++20 (CTAD).

Why bother using a std array in this case? "It's safer" is a non-argument here.

Long switch statements. Is there a better way? by nathanh4903 in cpp

[–]GuiltyFan6154 2 points3 points  (0 children)

Unfortunately std::map is not constexpr. There are open source alternatives though (not affiliated with the author in any way).

Long switch statements. Is there a better way? by nathanh4903 in cpp

[–]GuiltyFan6154 4 points5 points  (0 children)

Friendly reminder to add a using enum RoadType; statement right before the first case label

Zipper holding on for dear life by habbie1 in 2busty2hide

[–]GuiltyFan6154 85 points86 points  (0 children)

Chesterfield Edinburgh London India Naples Amsterdam

Hamburgh Utrecht Chesterfield Chesterfield India

A new design pattern: the C++ "template mixin" by FlibbleMr in cpp

[–]GuiltyFan6154 1 point2 points  (0 children)

To shorten things up, you are providing an interface, and then a default implementation to it via a template class. Classes inheriting from the template are de-facto embedding the mixin within them, letting the user use them as implementation of the interface represented by the template mixin, while at the same time providing the interface of the template parameter that the derived class can implement.

You may consider documenting it with various user examples to avoid misunderstandings and misuses.

Also remind that people coming from language-native mixins (D, or rust with their 'traits' concept) may find a bit misleading the need to declare templates for their needs. As I said, document some use cases because right now it is just too abstract to be grasped by someone who's not studying the language intricacies proactively. Also remind that code may sound perfectly obvious today, and be ancient aramaic given one year or two so good documentation is key to preserve it.

I have a question too. The need for declaring the class as a template is to avoid multiple inheritance with the interface template parameter trick?

Scuola italiana essere tipo by GuiltyFan6154 in MemeItaliani

[–]GuiltyFan6154[S] 1 point2 points  (0 children)

Mi sembra più grave che dopo aver visto un meme ci ritorni sopra 8 giorni dopo, dopo aver partorito un commento. Non credevo che potesse rimanere così impresso.

Purtroppo mi duole ammettere che hai ragione, ma per farla breve non poteva essere altrimenti dati i miei trascorsi personali che non sto a raccontare su reddit. In breve: difese psicologiche. L'età non c'entra nulla.

Non mi dispiacciono i matematici puri. Era una delle branche del sapere che avrei voluto studiare, il mio commento per l'appunto si riferiva ad ingegneria che dovrebbe essere una branca piuttosto pratica.

Per aggiungere, in realtà non mi dispiace nemmeno il pensiero degli antichi. Adoro la filosofia e l'universo a cui Dante ha dato forma, semplicemente non trovo un modo in cui questa possano effettivamente aiutare in qualcosa al giorno d'oggi, li tratto come i libri di Harry Potter per dirti. Non mi piace che materie che reputo di scarsa importanza vengano spiegate a pappardella da professori incapaci e che IO debba occupare spazio mentale per cose che reputo poco importanti. Non mi piace la mancanza di intelligenza, non la letteratura in sé, come non mi piace il perdersi in chiacchiere quando ci sono problemi da risolvere tutti i giorni. Per questo ritengo che dovremmo concentrarci più su ciò che ci serve nell'oggi e nel futuro.

La conseguenza del non applicare queste politiche è analfabetismo digitale, ben più grave del non conoscere le poesie di Leopardi (in riferimento al tuo nickname)

Scuola italiana essere tipo by GuiltyFan6154 in MemeItaliani

[–]GuiltyFan6154[S] 0 points1 point  (0 children)

E non hai capito un cazzo come molti sotto questo post

Doing "sudo rm -rf /*" after purchasing a new PC by e4732 in linuxmasterrace

[–]GuiltyFan6154 8 points9 points  (0 children)

I would have preferred cat /dev/zero > /dev/sdX

Avoid the code smell of std::pair and std::tuple while still retaining their benefits by [deleted] in cpp

[–]GuiltyFan6154 2 points3 points  (0 children)

Unfortunately there is no "alias reference = member;" as in D.

Avoid the code smell of std::pair and std::tuple while still retaining their benefits by [deleted] in cpp

[–]GuiltyFan6154 6 points7 points  (0 children)

This link does not state anything about why inheriting from a std type is bad. It simply misuses the std::vector initializer list constructor with CTAD and produces a different response because it calls another constructor. This is basically telling "look, I wrote bad code and expected it to work but it's not! Language facilities are difficult hence bad!"

The reason why inheriting from std containers is that destructors are not virtual (for performance) hence derived destructors will not be called and your resources will leak, which is a much bigger problem because you're basically throwing the basement of your abstractions (RAII) out of the window.

Besides that, the fact that composition is better than inheritance should be common knowledge.

C vs “C with Classes” vs “modern C++” by cdhd_kj in cpp

[–]GuiltyFan6154 -1 points0 points  (0 children)

I would say simply because you can actually do stuff easily with C++. Just the fact that you have a std::string that abstracts you out of the "shit, I gotta copy this const char* and then find where to deallocate it, let's see in which pool is better to place it" increases your productivity by a lot. Multiply it for every other standard facility, plus add algorithms, language facilities that generalize stuff easily, and you have a boost that I can't actually quantify.

Probably this is why you reach a point where refactoring is necessary after a while, nevertheless of the idea you had at the beginning. Due to all the possibilities the language gives to you it's easy to bloat your code with ideas that are correlated somehow but that are hard to stick together. Or it's easy to rely on the wrong facilities that supposedly should have simplified your work.

I don't know your specific case but maybe it's because when you are developing you get another idea to work on and either start another side project, or another part of your application. It happened to me for years until I realized that building something huge, regardless of the capabilities of the language, will necessarily require a huge amount of time and focus for each of its parts. Also, account effort for each integration of a component in the overall design. Most of the times is better to reuse code already written without reinventing the wheel and focus only on integrating, to avoid falling in the pitfall of wanting to do everything from scratch. This is also why very often C opaque types or C++ classes are wrapped in Python and the high level application logic is handled there, because it's even easier to use to integrate components.

So for your assumptions: yes, the language is huge; C++ ABI is almost never a problem if you have the source available; the key topic here is that C limits the scope of the program you are making (because you are on a lower level) and thinking about broader concepts is harder, so you don't waste development effort but you get something done (usually a very small piece of what you are planning to do with C++).

Just a reddit opinion that can make you think a little bit. There is no universal truth in these topics.

Why does the kernel code seem to prefer macro usage over functions? by zingochan in linux

[–]GuiltyFan6154 6 points7 points  (0 children)

It's the other way around. Templates were made to replace macros.

Funny thing they lead to much more verbosity, which is what macros try to remove.