Victor D.
tb
hello guys
tb
is in your opinion a good way to start learning c++ using the last iso iec 14886 (2020) standard?
Igor🇺🇦
is in your opinion a good way to start learning c++ using the last iso iec 14886 (2020) standard?
Do you mean like learning to use C++ from actual spec or just using C++20 features?
Sanchin
Hi am learning C++ thanks
coal
how?
coal
when?
Talula
how?
No, I'm asking for a reason, I mean if someone is learning C/C++ after they know other programming languages, great. If someone is learning C/C++ for college, great. If you want to program micro controllers, great. But if you are learning C/C++ as the only programming language for a job, then don't waste your time.
coal
that's good to know
coal
i think whatever the reason is, new knowledge is always useful
Jessy
Great. Personally, I'm a sophomore in CE and I'm into C/C++
coal
i just learnt programming for fun and im into pretty much everything that looks fun
Hsn
Some people dont get attracted to programming web, desktop, mobile applications 🌚
coal
it will be used as long as windows and linux exist
coal
and for embedded programming as well
coal
but rust may easily replace C in that field (this assuming that people want to move because of the safeties that Rust provides in comparison to C)
coal
its a matter of time
Talula
Hsn
but rust may easily replace C in that field (this assuming that people want to move because of the safeties that Rust provides in comparison to C)
I feel i need to cope with that .. is rust compilers available for free use for commercial for embedded? Usually chip vendors provide gnu gcc i didn't see rust .. is rust widely accepted in safety critical like medical or aerospace ?
Igor🇺🇦
but rust may easily replace C in that field (this assuming that people want to move because of the safeties that Rust provides in comparison to C)
C++ that's much closer to C and is safer and easier to use than C. C++ is more widely available on different platforms and has much higher number of users than Rust, but still didn't replace C. Why would Rust be any different?
CALVIN
Anyone with vast knowledge on c++ GUI......
Lion
Did you mean C++ is safer than Rust ?
It didn't implied this, did it?
\Device\NUL
Igor🇺🇦
\Device\NUL
https://pvs-studio.com/en/blog/posts/0733/
Lion
as for the difference between rust and c++, rust put those coding safety practice as default, while c++ needs rules and conventions to enforce them.
Lion
can c++ be safe? yes. safe as default? no.
Hsn
Safe is hard subject to discuss .. even compilers are made differently .. different compilers have different safety levels .. I dont know about rust compiler anything .. does it pass the finctional safety for critical applications? Is it really used in these applications?
Andrii
Why in member initializer list it's not allowed to use copy initialization? More precisely, I can't do the following thing: class Foo { int boo; double goo; public: Foo() : boo = 5, goo = 3.1 {} } I have to write boo(5), goo(3.1) or boo{5}, goo{3.1}
Anonymous
Anonymous
as for the difference between rust and c++, rust put those coding safety practice as default, while c++ needs rules and conventions to enforce them.
The difference actually is that Rust compiler helps the developer focus on the task at hand rather than worrying about thread safety and stuff while C++ actually puts the onus on the developer. So Rust makes the developer's task more easy (although the borrow checker can sometimes be a pain). This is what differentiates Rust from C and C++. Also macros and traits in Rust are much more thoughtfully designed and make programming in Rust much easier as compared to templates in C++. Even with concepts, the error messages in C++ are a pain. Also Rust embraces Functional Programming in a more direct way as compared to C++ making the code much more easier to reason about. And don't even get me started on the build systems for C++ but Rust disappoints a bit here as well even though cargo is so much more friendly and easier to use. The build times in Rust are painful but they are improving it.
Lion
don't get me wrong but, we are in the context about so-called safety
Anonymous
C++ that's much closer to C and is safer and easier to use than C. C++ is more widely available on different platforms and has much higher number of users than Rust, but still didn't replace C. Why would Rust be any different?
Are you serious? AFAIK C is available on a wider variety of platforms than C++. Not the other way around. Also Rust is different because it didn't attempt to be a better C or C++ but a better systems programming language instead. C++ on the other hand started off as C with classes and then added a whole bunch of new paradigms on top of it thus carrying the unnecessary parts of C baggage.
Anonymous
Lion
Differences between languages are big indeed, and no need to teach me how Rust is because I do know it.
Anonymous
Differences between languages are big indeed, and no need to teach me how Rust is because I do know it.
The point I was making is that Rust makes a programmer's job easier which you still have not refuted
Lion
Do I?
Anonymous
Do I?
Well if you agree with me, then there is no cause for an argument
Lion
Do I even argue
Lion
Is it too naive to put someone on the other side before knowing what he's thinking...😰
Hisam
if (system("CLS")) system("clear"); can anyone explain this if statement?
Lion
if (system("CLS")) system("clear"); can anyone explain this if statement?
Oh, Windows uses the former one, UNIX-like shell uses the latter one
Anonymous
Is it too naive to put someone on the other side before knowing what he's thinking...😰
I am not sure I understand what you are saying. You said Rust is safe by default while C++ requires rules and conventions to enforce them. My point was that Rust's safety by default makes it a better choice because it improves developer's productivity. And no amount of conventions and idioms in C++ can prevent bugs as developer's can't think about them all.
Anonymous
I know right, but LSP (clangd) barks, "Members have protected visibility"
It is probably just an eager warning which can be ignored
数学の恋人
So I can go ahead with first approach then
数学の恋人
Thanks for guidance senpai
Igor🇺🇦
Are you serious? AFAIK C is available on a wider variety of platforms than C++. Not the other way around. Also Rust is different because it didn't attempt to be a better C or C++ but a better systems programming language instead. C++ on the other hand started off as C with classes and then added a whole bunch of new paradigms on top of it thus carrying the unnecessary parts of C baggage.
Yes, I'm serious. I didn't say that C++ is available on more platforms than C. I said it's available on more platforms than Rust. You don't have to use "C baggage" if you don't need to, but you can expand your existing C code with C++. Making it easier to move from C to C++. And even that process not really happen.
artemetra 🇺🇦
if (system("CLS")) system("clear"); can anyone explain this if statement?
cls is a windows clear statement for clearing the console. it returns the exit code of 0 (false) if there's no error, but if this code runs on a unix-like machine, running cls will result in an error because there is no such command there, thus returning a non-zero exit code (which is implicitly casted to a bool true), and thus entering the if statement and running clear instead
artemetra 🇺🇦
hope this helped
artemetra 🇺🇦
artemetra 🇺🇦
it tries to execute cls first, and then if it fails executes clear
artemetra 🇺🇦
np :D
Anonymous
Yes, I'm serious. I didn't say that C++ is available on more platforms than C. I said it's available on more platforms than Rust. You don't have to use "C baggage" if you don't need to, but you can expand your existing C code with C++. Making it easier to move from C to C++. And even that process not really happen.
Well people sticking to C instead of moving to C++ is more because the new features that C++ adds are not exactly zero cost abstractions and C programmers prefer to see a direct translation between their code and machine code. This is why many good C programmers continue programming in C. If you are talking about integrating C and C++ code, Rust makes it pretty straightforward as well to interface with your existing C code base (maybe with a little more effort). I am not against C++. I have been programming in C++ for most of my career. I just butted in here to add why Rust has a better chance of becoming a preferred alternative to C/C++ than D or Go ever did.
Igor🇺🇦
Well people sticking to C instead of moving to C++ is more because the new features that C++ adds are not exactly zero cost abstractions and C programmers prefer to see a direct translation between their code and machine code. This is why many good C programmers continue programming in C. If you are talking about integrating C and C++ code, Rust makes it pretty straightforward as well to interface with your existing C code base (maybe with a little more effort). I am not against C++. I have been programming in C++ for most of my career. I just butted in here to add why Rust has a better chance of becoming a preferred alternative to C/C++ than D or Go ever did.
All features in C++ don't cost anything unless you use them. If you write old style C you'll most likely will get the same code. If you really think that your code is directly translated from C to assembly - you should get more familiar with modern optimizing compilers. With C++ you can continue using practically the same code and refactor it gradually to add other C++ features and make your code more readable, safe and sometimes faster. Rust doesn't allow gradual refactoring.
Anonymous
All features in C++ don't cost anything unless you use them. If you write old style C you'll most likely will get the same code. If you really think that your code is directly translated from C to assembly - you should get more familiar with modern optimizing compilers. With C++ you can continue using practically the same code and refactor it gradually to add other C++ features and make your code more readable, safe and sometimes faster. Rust doesn't allow gradual refactoring.
I am familiar with compiler optimizations but you are missing the point I am trying to make. When I say zero cost abstractions, I am using the phrase in the sense that it costs extra. Take unique_ptr for example. It is often said that unique_ptr is a zero cost abstraction over a raw pointer but it is not. Watch https://m.youtube.com/watch?v=rHIkrotSwcc&list=LLkSsu_JvG53vwdMNEDCLLqQ&index=10 Rust doesn't allow gradual refactorings? What exactly do you mean by that? What is it in Rust that inherently prevents refactoring? Do you mean the compiler forcing you to make changes?
Igor🇺🇦
I am familiar with compiler optimizations but you are missing the point I am trying to make. When I say zero cost abstractions, I am using the phrase in the sense that it costs extra. Take unique_ptr for example. It is often said that unique_ptr is a zero cost abstraction over a raw pointer but it is not. Watch https://m.youtube.com/watch?v=rHIkrotSwcc&list=LLkSsu_JvG53vwdMNEDCLLqQ&index=10 Rust doesn't allow gradual refactorings? What exactly do you mean by that? What is it in Rust that inherently prevents refactoring? Do you mean the compiler forcing you to make changes?
This talk is not related to the point you're trying to make. Don't use unique_ptr if you don't have. There is no inherent cost from moving from C to C++. It can be even more efficient, because compiler knows more information from type system. Rust doesn't allow gradual change because with C++ you can start from the same code and change it. Most code will work even without any change. Rust is a different language and its compiler can't compile C.
Anonymous
This talk is not related to the point you're trying to make. Don't use unique_ptr if you don't have. There is no inherent cost from moving from C to C++. It can be even more efficient, because compiler knows more information from type system. Rust doesn't allow gradual change because with C++ you can start from the same code and change it. Most code will work even without any change. Rust is a different language and its compiler can't compile C.
I beg to differ. That talk specifically points out that uses of unique_ptr is not a zero cost abstraction over a raw pointer. If I don't use the majority of features then what is the benefit of moving to C++? This is exactly what C programmers point out when asked why they don't want to move to C++. Basically they will be using the C parts of C++. This is exactly why embedded programmers turn off/don't use features like dynamic polymorphism, exceptions and a majority of standard library features when programming in C++ on embedded environments. The C++ guidelines btw recommend use of smart pointers. So I would be programming in C++ against the guidelines if I were to continue using raw pointers. Rust does allow gradual refactorings. I am still not sure what you mean when you say it doesn't. Infact the Rust lang book has a chapter on refactoring your code in micro steps and how to achieve the same. Can you give me an example code to show what prevents minor refactorings in Rust?
Prince Of Persia
Is there anyway to get access to MySQL database of localhost via C++ cgi?
Shvmtz
Why does bss segment show 8 bytes when there is no variable in the c code ?
\Device\NUL
if (false) { system("CLS"); } else { system("clear"); }
Maybe you can check the OS with predefined macros https://stackoverflow.com/questions/142508/how-do-i-check-os-with-a-preprocessor-directive
Hsn
Why does bss segment show 8 bytes when there is no variable in the c code ?
Maybe and im not sure its related to ctors and c startup/initilization functions? Would love to know the answer as well