← Home ← Back to /g/

Thread 105733647

61 posts 18 images /g/
Anonymous No.105733647 [Report] >>105733654 >>105733874 >>105734055 >>105736471 >>105737127 >>105737172 >>105737801 >>105738309 >>105739285 >>105742237 >>105742292 >>105742517 >>105742533
Why is everything ten times more complex in C++ than it should be?
Even the new language features are botched in several ways compared to other languages. It's like the community is full of masochists.

The automatic npc answer is:
>MUH BACKWARD COMPATIBILITY! REEEE!
Imo it's just a weak excuse for retarded choices. The whole language is a big tragedy of the commons and lack of comprehensive planning.
Anonymous No.105733654 [Report] >>105743287
>>105733647 (OP)
Try APL
Anonymous No.105733874 [Report] >>105737801 >>105742389 >>105742570
>>105733647 (OP)
>
https://pastebin.com/raw/NhENNRgu
Anonymous No.105734055 [Report]
>>105733647 (OP)
severe case of retardation
Anonymous No.105734115 [Report]
There are less Rust threads nowadays, and more and more complaining about C++. They're giving up and accepting their fate.
sage No.105734954 [Report] >>105736263 >>105737243
Why do these ragebait threads never name a single specific thing? Who does nobody ever call out OP on this? It's like the entire thread is bots.
Anonymous No.105736263 [Report] >>105736311 >>105736461 >>105737012 >>105737197
>>105734954
Header hell forexample .... forward declarations are just as painful and dumb like 30 years ago. Every strategy to minimize complexity has some major flaw because the language is designed in such a stupid way.
They created modules now what is just as bloated and painful as header fuckery but in a different way.
These things are much simpler in other languages. The C++ committee lives in a bubble.
sage No.105736311 [Report] >>105736396
>>105736263
Not a C++ feature.
Anonymous No.105736396 [Report]
>>105736311
You are officially stupid.
https://en.cppreference.com/w/cpp/language/modules.html
Anonymous No.105736461 [Report]
>>105736263
i hate cpp, but no one cares about this shit.
Anonymous No.105736471 [Report] >>105736814
>>105733647 (OP)
By keeping the constrains outside of code and moving them in to comments or documentation(if you even do that), you are only archiving an illusion of simplicity. By avoiding formalization, you are skipping the short-term chore with a permanent cognitive overhead, which at some point in future will overwhelm you and you will inevitably start making mistakes.
Anonymous No.105736814 [Report] >>105737077 >>105739061
>>105736471
Comments never overwhelmed me because I don't waste my time writing them.
Code is self explanatory, to me. I am the only person who matters, nobody else asked me anything about my code, so 0 people would benefit from comments.
Anonymous No.105737012 [Report]
>>105736263
skill issue
Anonymous No.105737077 [Report]
>>105736814
>Comments never overwhelmed
I am not talking about comments per se, but complexity. The complexity is unavoidable and it has to be dealt with. Both writing comments or brute memorization can be used, but given large enough scope, both will fall short to formalization.
>Code is self explanatory
It only is until it isn't. We use names, types, signatures, templates, abstractions, etc to express these invariant in the code itself so it can better explain itself and how to properly use it.
Anonymous No.105737127 [Report] >>105737187 >>105739066 >>105739129 >>105740929
>>105733647 (OP)
The C++ committee is a demonic cult that empowers their rituals using the power derived from the suffering of millions of programmers.
Anonymous No.105737172 [Report]
>>105733647 (OP)
design by comitee is the root of all evil
its babylon
it is perversion of the soul
it should be punished harsher than pedophilia is
Anonymous No.105737187 [Report]
>>105737127
100% this
sepples is the cult of annihilation
it is everything evil in the world, but distilled
Anonymous No.105737197 [Report] >>105737214 >>105739159
>>105736263
I think header files are good for compiled languages. Module based languages seem less able to glue together random bits of code.

In regards to forward declaration. I am currently working on my own fork of c++. One change I want to make is to significantly loosen the forward declaration requirements. Specifically, I will delay parsing of function bodies. This will allow declaring functions within a translation unit in any order.
Anonymous No.105737214 [Report] >>105737676 >>105740013 >>105740064
>>105737197
>header files painful
how???
its just the explanation for the rest of your program what goes where and how we do things
>hurr durr what about self including header files/macros
what about em?
headers are a straightforward solution to a simple problem
idk whats about headers that people could hate, honest
im open to all critique bc i cant find none
Anonymous No.105737243 [Report] >>105737315 >>105737365 >>105737408 >>105739271 >>105742280
>>105734954
Explain std::move. I'll wait.
Anonymous No.105737315 [Report] >>105737442
>>105737243
the easiest way to understand is you change the scope of a stack variable. say i have a pointer that contains stack variables. you can move a local variable to that pointers memory location, so it doesnt fall out of scope and u dont have to allocate heap memory. also when you compile functions under the hood it does an std::move for any variable you return. this prevents unnecessary copies.
Anonymous No.105737365 [Report] >>105737442
>>105737243
static cast to &&, which tells compiler to use the && overloads of functions
Anonymous No.105737408 [Report]
>>105737243
i did a bad job explaining possibly if u have no idea what i am saying. here is a clear example.
#include <iostream>
#include <vector>

class C {
public:
std::vector<int> mem;
C() { };
~C() { };
};

void do_move(C& c)
{
std::vector<int> local = {1, 2, 3, 4};
std::cout << local.data() << "\n";
c.mem = std::move(local);
}

int main()
{
C c;
do_move(c);
std::cout << c.mem.data() << "\n";
}


without the std::move it will do a copy of the data.
Anonymous No.105737442 [Report] >>105737466 >>105738094 >>105739287
>>105737315
>>105737365
wrong. std::move is just a hint to compiler to attempt to turn the l-value into r-value. If the object supports copy, compiler might choose to do a copy instead of moe.

Next question:

what is the difference between:

SomeClass(SomeType&& bla) : bla(std::move(bla)) {}

and

SomeClass(SomeType&& bla) : bla(bla) {}

Does the std::move in this example matters?
Anonymous No.105737466 [Report] >>105737508
>>105737442
you're clueless
Anonymous No.105737508 [Report]
>>105737466
See. As soon as I start asking more intricate questions, your understanding crumbles. Sit down and listen: as soon as you assign r-value to a variable, it becomes an l-value. Doesn't matter that the type says &&. Therefore, the std::movie is necessary in the example above to for a move to actually be performed.
Anonymous No.105737676 [Report]
>>105737214
They suck. What other language do you have to edit a function signature in 2 places? It's the one thing that Rust does better than C.
Anonymous No.105737801 [Report] >>105742389
>>105733647 (OP)
>>105733874
>one fucking spiteful asshole literally fucked up the programming timeline for decades
Cringe, or based. Call it.
Anonymous No.105738094 [Report]
>>105737442
All these words when you could have just looked at how std::move is implemented to see you are wrong.
Anonymous No.105738115 [Report] >>105739257 >>105742646 >>105742760
What do you think std::hardware_destructive_interference_size does?

This is just them being unable to pick a reasonable name for something.
Anonymous No.105738309 [Report]
>>105733647 (OP)
Because its a piece of shit from the stone age with mountains of shit slapped onto it
Anonymous No.105739061 [Report]
>>105736814
Yeah. Code should be readable without comments. The comment should be in the value/function/type names.
Anonymous No.105739066 [Report]
>>105737127
This but ironically.
Anonymous No.105739129 [Report]
>>105737127
This but unironically.
Anonymous No.105739159 [Report] >>105739313
>>105737197
>This will allow declaring functions within a translation unit in any order.
Sounds good.
Anonymous No.105739257 [Report]
>>105738115
>std::hardware_destructive_interference_size
Holy fucking God!
Anonymous No.105739271 [Report]
>>>105737243
Cast to rvalue
Anonymous No.105739285 [Report]
>>105733647 (OP)
here is a movie of bjarne dabbing on you
Anonymous No.105739287 [Report] >>105740918
>>105737442
std::launder is a compiler hint, move has actual semantic meaning
Anonymous No.105739313 [Report] >>105739326
>>105739159
I have been working on a few other features too.

Allow the declaration of private class methods without forward declaration in the class body. This means you don't have to shit up the public interface with private methods.

Another feature which I am very proud of. Is a custom attribute for arrays. Which allows the array to be initialized with initializers of heterogeneous types. Typically used with byte arrays, this feature extracts the byte representation of any expression in the intializer list. Very useful for creating a constant byte array comprised of different struct types.

Another ancillary feature I am adding related to the a fore mentioned heterogeneous array initializer feature. Is the ability to assign names to array elements. This feature will be usable with __builint_offsetof such that you can build complex file formats at compile and have header fields in one part of the generated file format refer to the offset of other parts of the file.
Anonymous No.105739326 [Report]
>>105739313
it seems to me like c++ made a problem instead of solving one
Anonymous No.105740013 [Report]
>>105737214
Pointers were invented by mathfags. Eunuchs troons just copied them.
Anonymous No.105740064 [Report] >>105740794
>>105737214
Its easy when you only have 3 headers in your school project.
Try to manage a project with millions of lines of code and get it compiled under 10 minutes.
Anonymous No.105740794 [Report] >>105742512
>>105740064
It's really not that hard to use header files effectively. Stop including so many other headers in your headers. You can even avoid most forward declarations by giving your objects a private object.
Anonymous No.105740918 [Report] >>105740941 >>105742237
>>105739287
move is just a cast to && and has no semantic meaning, nothing is moved, RVO is the only case where the object is *gasp* moved out from a function back into the callee's chosen memory. C++ is a joke.
Anonymous No.105740929 [Report]
>>105737127
This. Bjarne has been going off on the committee lately for destroying his life's work.
Anonymous No.105740941 [Report]
>>105740918
caller's*
Yet, unironically, it could be callee, and nobody would find it weird, because it's C++.
Anonymous No.105742237 [Report] >>105742345
>>105733647 (OP)
C++ is a monkey's paw language, everything good has to be balanced out with a fuckup
>>105740918
It's not a cast to &&, it's a cast to rvalue and then an rvalue can bind to a && (an rvalue reference).
&& is a value type, rvalue is a value category
Anonymous No.105742267 [Report]
Anonymous No.105742280 [Report]
>>105737243
which one?
https://en.cppreference.com/w/cpp/algorithm/move.html
Anonymous No.105742292 [Report]
>>105733647 (OP)
https://en.cppreference.com/w/cpp/memory/gc/declare_reachable.html
Anonymous No.105742345 [Report]
>>105742237
which has nothing to do with move
Anonymous No.105742389 [Report]
>>105733874
>>105737801
https://www.stroustrup.com/bs_faq.html#IEEE
Not telling C++ is great or anything.
Anonymous No.105742512 [Report]
>>105740794
Of course but it has a cost on performance when you cant have value members in your classes.
Anonymous No.105742517 [Report] >>105742538
>>105733647 (OP)
C++ is a language strongly optimized for liars and people who go by guesswork and ignorance.
Anonymous No.105742533 [Report]
>>105733647 (OP)
Because you're ten times dumber than you need to be.
Anonymous No.105742538 [Report]
>>105742517
When you're know what you're doing, C++ is actually just superior incarnation of C. However, most nocoders have no idea what they're doing.
Anonymous No.105742570 [Report]
>>105733874
Hilarious but fake of course. I've heard him speak at length about C++ he'd never say these things.
Well except the rewriting Unix in C++ part I bet he'd say that.
Anonymous No.105742646 [Report]
>>105738115
I'll admit, even I didn't believe this existed.
Apparently it does.
(where hardware interference refers to cache lines)
Anonymous No.105742760 [Report]
>>105738115
Nothing, some hardware has it at 128 but C++ still claims 64
Anonymous No.105743287 [Report]
>>105733654
based