klimi
#ot
Rose
#ot
Offtopic discussions should be done in the C/C++ Offtopic group. Please take your discussion/questions there.
Haa
If anyone have "lets us c" 18th edition book , can they share me the pdf format?
Rose
If anyone have "lets us c" 18th edition book , can they share me the pdf format?
Don't ask meta questions. In other words, don't ask to ask. Questions like "Does anyone know XYZ?", "Has anyone used XYZ?" or "Can someone help me?" are all considered meta questions because they don't specify what your actual problem is. These questions give the impression that you want people to approach you and offer their help as if they don't have any other work to do. Now doesn't that expectation make you look like an idiot? If you have a question ask it directly. You are more likely to get a response that way.
Chat Boss
MᏫᎻᎯᎷᎷᎬᎠ sent a huge message, it has been re-uploaded as a quote Something weird about auto constructors generation In this code: class A { public: A() = default; private: int a; }; int main() { A a{}; } In the assembly output(Link below) the constructor was not called and not even generated, although it's explicitly requested with default This behavior is similar to when deleting A() = default; line but with replacing A() = default with A(){} The constructor will be generated and called I thought that A() = default is similar to A(){} which is also similar to implicitly generated constructor in a non-aggregate class The link to assembly: https://godbolt.org/z/75r99cWxd
Pavel
Arghh
With = default it won't generate a constructor that would initialize a with zero (in this case, at least). For that you need to declare the member variable with assignment int a = 0; If you write your own constructor however, it is a different story, it would follow different rules. In the documentation, one of these constructors is called explicit default constructor (if you don't specify it, you can get implicit default constructor generated for you. The other one called user-provided default constructor. And then depending on the type of initialization you are doing, you can check the related page, e.g. https://en.cppreference.com/w/cpp/language/default_initialization All these different initializations is a weird and annoying part of C++, but this specific difference comes with benefits, that you can have classes that can be constructed without initializing their memory (which is helpful in some rare performance-related scenarios).
Pavel
This video comes to mind https://www.youtube.com/watch?v=7DTlWPgX6zs
MᏫᎻᎯᎷᎷᎬᎠ
Totally agree, it is a mess right now :D
Isn't there any efforts to resolve this? I mean like it's so annoying, it's hard to predict the generated output
MᏫᎻᎯᎷᎷᎬᎠ
I think the standard is trying to find a sweet spot between usability(like the code just works out of the box most of the times) and handling edge cases But ends up complicating the language From my side I'm okay with writing larger code but with clear picture and constructs that are easier to reason about
MᏫᎻᎯᎷᎷᎬᎠ
For example why introducing class if there is absolutely no difference from struct but going vice versa What's the big problem with public by default?
MᏫᎻᎯᎷᎷᎬᎠ
They allowed this syntax: int a(1); Because they want fundamental types initialization to look like user defined types
Jitender
Sorry for sending twice.
klimi
Sorry for sending twice.
It looks like you tried sending an advertisment
Jitender
O.k.
Pavel
Isn't there any efforts to resolve this? I mean like it's so annoying, it's hard to predict the generated output
So the problem right now is the backwards compatibility (including compatibility with C). We use includes, which include the text of the header files directly. A lot of applications have dependencies, and a lot of very important libraries still support old compilers, or even written in C. So to make sure that your app still compiles after updating to the new version of the compiler or enabling the new C++ standard, you have to support all the legacy code in the new versions/standards. This means that any ugly decision made in the past is going to be supported basically forever (there are some examples where backward compatibility was broken, but it was mostly features that nobody really used). There are half-solutions like using linters to prohibit of some ways of writing code, or static analysers that could detect that something is not initialized before use, or memory sanitizers and ub sanitizers that can signal about some bugs during runtime. I think everyone in the community right now is basically coping with the situation by using those. There are ideas for actual solutions. One is adding support for epochs in C++ modules: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1881r0.html Though modules aren't widely used, this could help C++ committee finally break things, and people will slowly follow. Another idea is to make a new language that can be used together with C++ in one way or another, two examples are: Carbon: https://en.wikipedia.org/wiki/Carbon_(programming_language) cpp2/cppfront: https://hsutter.github.io/cppfront/ Both propose an idea to have a language that will have backwards compatibility with C++ but in a very controlled manner, so you can write all the new code in this language, and eventually in a few decades get rid of the old C++ code.
Pavel
Good things come from unexpected places, and the recent news about "prohibiting memory-unsafe languages" may be a good motivation for the committee to do something about this.
MᏫᎻᎯᎷᎷᎬᎠ
So the problem right now is the backwards compatibility (including compatibility with C). We use includes, which include the text of the header files directly. A lot of applications have dependencies, and a lot of very important libraries still support old compilers, or even written in C. So to make sure that your app still compiles after updating to the new version of the compiler or enabling the new C++ standard, you have to support all the legacy code in the new versions/standards. This means that any ugly decision made in the past is going to be supported basically forever (there are some examples where backward compatibility was broken, but it was mostly features that nobody really used). There are half-solutions like using linters to prohibit of some ways of writing code, or static analysers that could detect that something is not initialized before use, or memory sanitizers and ub sanitizers that can signal about some bugs during runtime. I think everyone in the community right now is basically coping with the situation by using those. There are ideas for actual solutions. One is adding support for epochs in C++ modules: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1881r0.html Though modules aren't widely used, this could help C++ committee finally break things, and people will slowly follow. Another idea is to make a new language that can be used together with C++ in one way or another, two examples are: Carbon: https://en.wikipedia.org/wiki/Carbon_(programming_language) cpp2/cppfront: https://hsutter.github.io/cppfront/ Both propose an idea to have a language that will have backwards compatibility with C++ but in a very controlled manner, so you can write all the new code in this language, and eventually in a few decades get rid of the old C++ code.
Backward compatibility is understandable, C is a simple language, C++ can take advantage of that simplicity and accommodate new features instead of adding unnecessary complexity to the language The problem is with adding feature in order to make the language constructs work out of the box, but that will introduces rules that make the language more complex
MᏫᎻᎯᎷᎷᎬᎠ
So the problem right now is the backwards compatibility (including compatibility with C). We use includes, which include the text of the header files directly. A lot of applications have dependencies, and a lot of very important libraries still support old compilers, or even written in C. So to make sure that your app still compiles after updating to the new version of the compiler or enabling the new C++ standard, you have to support all the legacy code in the new versions/standards. This means that any ugly decision made in the past is going to be supported basically forever (there are some examples where backward compatibility was broken, but it was mostly features that nobody really used). There are half-solutions like using linters to prohibit of some ways of writing code, or static analysers that could detect that something is not initialized before use, or memory sanitizers and ub sanitizers that can signal about some bugs during runtime. I think everyone in the community right now is basically coping with the situation by using those. There are ideas for actual solutions. One is adding support for epochs in C++ modules: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1881r0.html Though modules aren't widely used, this could help C++ committee finally break things, and people will slowly follow. Another idea is to make a new language that can be used together with C++ in one way or another, two examples are: Carbon: https://en.wikipedia.org/wiki/Carbon_(programming_language) cpp2/cppfront: https://hsutter.github.io/cppfront/ Both propose an idea to have a language that will have backwards compatibility with C++ but in a very controlled manner, so you can write all the new code in this language, and eventually in a few decades get rid of the old C++ code.
This one got reject before and I don't think it will see light anytime
MᏫᎻᎯᎷᎷᎬᎠ
Good things come from unexpected places, and the recent news about "prohibiting memory-unsafe languages" may be a good motivation for the committee to do something about this.
I don't think this is about unsafety It's about a language that can be easily reason about C seems doing fine, while not providing much for safety As well as zig is having its trend these days
Pavel
I don't think this is about unsafety It's about a language that can be easily reason about C seems doing fine, while not providing much for safety As well as zig is having its trend these days
C++ is much more complex than C, and the permissiveness of C is hurting C++ more than it could help. But my thinking is, while addressing safety issues (which is something that you can't fix by the "git good" approach, compared to remembering all the initialization cases and how they work), the committee can also make it easier to break the compatibility in the future and also solve these inconsistency issues. Though, chances are, they will just slap some new features on top of the language, say "it is safe now, if you use only them", nobody will use them, and nothing will change.
Aurora
I have used many programming languages, and I feel that C++ can express my thoughts more effectively
Rose
Welcome Paa Kwesi! Please read the pinned message 🙂 Click the button below to unmute yourself.
Rose
User Priyanshi has 1/2 warnings; be careful! Reason: ad
Zeno
have i done anything wrong. i think i completed the captcha a while ago
Zeno
oof, don't get why my messages got deleted
Never Spam Bot
onezen0 is now approved by the group admin and can send messages without any restrictions there is no way this was considered spam. i don't get how this bot works See spam? Quote the spam message in the group and reply with /spam
klimi
oof, don't get why my messages got deleted
there you go: hello! i'm writing a piece of code in C to educate myself. it consists in a tui-like interface to the Conway's game of life, where each character slot represents the state of two cells (each cell being either on or off) using the U+258x characters. as of now, the state of the cells is rapresented using an array a of unsigned long (i'm trying to be mostly C89 compliant). the fact being, after i update thw state of the array according to the usual rules, i'm not sure how to output the game grid efficiently. it seems like there is a way to vectorize the reading of the array, writing it to a string to print using my tui's library of choice but i don't know how to do it
Chat Boss
Totally agree, it is a mess right now :D
MᏫᎻᎯᎷᎷᎬᎠ sent a code, it has been re-uploaded as a quote In this code: ```cpp struct A { A(){}; int a; }; int main() { A a{}; return a.a; //returns indetermined value since A constructor is empty and not default, so it's default-initialized as I assume } ``` But with adding B struct struct B { B() = default; A a; }; int main() { B b{}; return b.a.a; } In the last snippet, it returns 0, although A has an empty constructor, which is as in the first snippet, empty constructor does not zero initialize member fields
Chat Boss
This bot just go and discard any format in the message
Pavel sent a huge message, it has been re-uploaded as a quote I think they are both not initialized technically, though being inside another class may result in the memory being zeroed in some cases. Even though I mentioned the case with user defined default constructor is different, it doesn't initialize the value if the value is not in the initializer list. This how it should look struct A { A() : a(0) {} int a; }; Or like this struct A { A() {} int a = 0; }; Let's see what initialization is happening here. This case of A a{}; if default initialization: https://en.cppreference.com/w/cpp/language/value_initialization It says: * If T is a (possibly cv-qualified) class type: ** If the default-initialization for T selects a constructor, and the constructor is not user-declared(until C++11)user-provided(since C++11), the object is first zero-initialized. ** In any case, the object is default-initialized. I think what happens in the case of B is that it technically need to zero-initialize it (though, I would expect the compiler to be optimizing this part away here), so it zeroes the memory of the class, and then calls your constructor. I would not rely on that here though, I don't think it is guaranteed to always be true.
Ludovic 'Archivist'
This one got reject before and I don't think it will see light anytime
The specific proposal was, it is up to people that use the language to propose new things. It is not easy to satisfy everyone, much less the vested interests that are the compiler vendors (Microsoft in particular tend to refuse proposals out of being lazy bums) The commitee has a good number of assholes squatting it for political clout too. It is hard to make anything move in those conditions; some of the most active and beloved by the community are just leaving or going dark over the bullshit
Ludovic 'Archivist'
Why those investors tear down the language while using another languages because it has better options and design than C++ which they themselves contributed to? Like Microsoft is introducing Rust to their windows codebase
Rust is not inherently better, or inherently a model to follow. The reason why Microsoft has incentives here is that maintaining a compiler is expensive. Microsoft is not making their own Rust compiler. Keep in mind that Microsoft will not make a Rust interface for Windows and that interaction will still happen through C and C++ for the purpose of hiding internal datastructures, hiding which Rust doesn't allow (no partial compilation in Rust or precompiled libraries)
MᏫᎻᎯᎷᎷᎬᎠ
I believe safety by default is not the issue, it's about a language being easier to reason about for example Zig is getting a lot of attraction, and it's not safe by default
Ludovic 'Archivist'
So all this is because of maintaining a compiler is hard, that's why the language has to take steep turn
No it is because Microsoft runs their compiler division with a skeleton crew thinner than Google's OS division
Ludovic 'Archivist'
If Sean Baxter could make a C++ compiler alone, with all the enhancements he proposed, it just proves Microshit is just being a bunch of lazy bums
Ludovic 'Archivist'
I believe Rust as well is easier than C++, but with the cost of being kinda restricted
Making simple software is easy, but when trying to make something complex or self referencial, it becomes incredibly annoyingly complicated unless you are entirely OK with abandoning all the benefits of safe Rust
Ludovic 'Archivist'
The thing is, when you write database code or parsers or almost anything even moderately complex, you hit self referential trees very fast
Ludovic 'Archivist'
and while making and manipulating those safely in C++ is easy (even more now with std::any and smart pointers, before I had a type erasure for "destructible" which was extra load I needed to bring on any project), In safe Rust expressing the different lifetimes will be confusing and will appear more complex than it needs
Rose
User ~~ has 1/2 warnings; be careful! Reason: ad
Rain Bow
hi im using esp32 with flow sensor and monitor it using lcd 16x2 i2c. It just show flow rate a second then become zero. Anyone can help me 🥲
Never Spam Bot
🖤฿Ⱡ₳Q̬̂🖤 Ŝ̬B̬̂T̬̂ sent multiple messages that looks like a spam. Why was my message deleted? Spam deleted in this group: 2917
Never Spam Bot
Vishal Choudhary 🚜🌾 sent multiple messages that looks like a spam. Why was my message deleted? Spam deleted in this group: 2923
Rain Bow
Rose
Welcome Alok! Please read the pinned message 🙂 Click the button below to unmute yourself.
GUVOX
Hello friends! Has anyone configured this plugin in Vim 9? https://github.com/yegappan/lsp If you have any example settings to share, it would be helpful. Thanks
Tony
Do you have a good tutorial for C?
Rain Bow
Yes
Pm done
Rose
Do you have a good tutorial for C?
Please check out this channel - @Resources for information on learning sources for C and C++ (books and videos) and Frequently Asked Questions.
Ludovic 'Archivist'
Do you have a good tutorial for C?
Jens Gustedt's Modern C is also available for free on the author's website
Jojo
Do you have a good tutorial for C?
My response to this would be, as someone learning or relearning C, get the syllabus or course outline, will seek a sample image as am using one, the get to know the mentioned points in the outline. Currently, I downloaded 2 books that am following through to know about the outlines listed. Finally I guess memory is what makes humans better than the others🤔🤔🤔, I guess flies, as if you can't remember why use scanf or getchar or fgets and their structure or usage then one keeps relearning, why am relearning is another story though see even how to improve memory
Tony
#res
What?
Pavel
What?
Look one message below that
Rose
Reported to admins.​​​​​​​​​​
Tony
Sir, Where are you from?
Pavel
Sir, Where are you from?
This is not a good chat to talk about that, let's go to #ot
Rose
Sir, Where are you from?
Offtopic discussions should be done in the C/C++ Offtopic group. Please take your discussion/questions there.
klimi
removed, thanks for report
Doraemon
can direct initialization call copy-constructor? i asked chatGPT, it said YES
Suka
can direct initialization call copy-constructor? i asked chatGPT, it said YES
afaik it can. std::string a="hello"; std::string b=a; b+=" nice\n"; std::cout«a«" "«b; cmiiw.
Abbasi
can direct initialization call copy-constructor? i asked chatGPT, it said YES
struct S { S() = default; S(const S&) { std::cout << "copy ctor called\n";} }; int main() { S s; S s2(s); }copy ctor called
✨✿͜͡𝄟 🇨𝐔𝐓𝐄🇧𝐅𝐅𝄟 ≛⃝ ࿐✨
Plz help me
Rose
Reported ♡ ▷ ◉───❤───── 00:00♪ ♡ ▷ ◉───❤───── 00:00♪ [755182629] to admins.​​​​​​​​​​
harmony5 🇺🇳 ⌤