ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I just think that a lot of things in C++ are just plain stupid:
References. And the fact that you can't tell the difference between them and normal variables. Why not just use pointers?
Operator overloading. Is it really that hard to type a method call? Is it really worth adding so much confusion and complication to the language?
Duplication of C's features. WTF? Why do I need two ways of doing everything? The worst part is that if you use the (IMO better) C library, it's considered "evil".
Too much type casting. IMO the less type casting, the better.
Click here to see the post LQ members have rated as the most helpful post in this thread.
I just think that a lot of things in C++ are just plain stupid:
References. And the fact that you can't tell the difference between them and normal variables. Why not just use pointers?
Operator overloading. Is it really that hard to type a method call? Is it really worth adding so much confusion and complication to the language?
Duplication of C's features. WTF? Why do I need two ways of doing everything? The worst part is that if you use the (IMO better) C library, it's considered "evil".
Too much type casting. IMO the less type casting, the better.
Consider, for starters, 'cout' and overloaded '<<'.
Also consider string concatenation and '+'.
I would call operator overloading "dubious convenience".
FWIW, even in plain "C"/Perl/etc there is implicit operator overloading - strictly saying,
('fp' stand for floating point, 'int' stands for integer) are all different kind of 'plus', by the same token different underlying functions need to be called to perform the above additions, but for some reason in the above scenario implicitly overloaded '+' is taken favorably.
Last edited by Sergei Steshenko; 04-12-2010 at 09:33 AM.
...
Too much type casting. IMO the less type casting, the better.
Actually, it's the other way round - both C/C++ are too permissive. I would prefer them to be much stricter not allowing, for example, addition of 'double' and 'float' without am explicit type cast.
It's probably time for you to learn yet another colorful Russian expression: "You are too young and inexperienced and haven't yet burnt in a tank".
References. And the fact that you can't tell the difference between them and normal variables. Why not just use pointers?
One use of references is to reduce side effects, if you want a function to have access to data but not to modify it then you need to pass the data by value, rather than by reference. However for a large data structure passing by value is expensive and so the C++ reference was introduced. From the perspective of the function it is just normal data which is why it is treated the same in all respects, except for the function signature.
The overwhelming flaw of C++ is that the language rules are too complicated for even above average programmers with years of experience to really know the rules. It also has a lot of other flaws.
The overwhelming flaw in every other language, including C, is that it lacks the expressive power of C++.
If you are building a big, complicated project where performance matters, C is a very poor second choice and I don't know another language close enough to even be considered a third choice. C++ is the clear best choice.
Projects, such as Linux itself and GCC, prove that you can stretch C far beyond the realm where it belongs into areas where C++ is the only reasonable choice. But I don't think the fact that you can indicates that you should.
The way references work in C++ is not one of the flaws. If you have more experience in big projects, you will understand why that is the way references should work. It is especially not a flaw that passing by reference uses the same syntax as passing by value both at the point where the value is passed and at the point where the passed value is used, and the syntax is only different at the point where the passing method is declared.
Similarly, operator overloading is not a flaw but an important strength of the language.
By the time you make your imaginary preprocessor to be able to do what C++ can, guess where you've ended up.
C++ is indeed an "expert-friendly" language. To be even just *decent*, you need a strong grasp of the idioms as well as enough compiler theory to know how the code will shake out. If you need to care about performance, it's about the highest-level language you can use that'll still let you pull off ridiculous things when you need to.
Why do I particularly like C++? It's one of the few languages that I consider to have a sane resource management paradigm (and no, it's not "manual" at all).
Of course, if you're going to use operator overloading, you should use it right, and not do silly things like overloading a bitshift operator to print to a file.
One use of references is to reduce side effects, if you want a function to have access to data but not to modify it then you need to pass the data by value, rather than by reference. However for a large data structure passing by value is expensive and so the C++ reference was introduced. From the perspective of the function it is just normal data which is why it is treated the same in all respects, except for the function signature.
That's what a const reference is for, but why make the distinction between part of the language? Just have a calling convention in which large objects are passed by pointer.
For non-const references, it's not a good idea to make them look like normal variables.
Lately I've been thinking of just dropping to asm. Sure, programs will take longer to write, but at least I'll know what the !@#$ is happening in the most literal terms possible.
I probably should've learned asm first, then C/C++, but no, I wanted to be on the "fast track"! So now I've got this convoluted mash-up of concepts from C/C++ and asm in my head, and it's such a headache to mix 'n match between the two. And it doesn't help when I haven't finished reading that asm guide yet...
Lately I've been thinking of just dropping to asm. Sure, programs will take longer to write, but at least I'll know what the !@#$ is happening in the most literal terms possible.
I probably should've learned asm first, then C/C++, but no, I wanted to be on the "fast track"! So now I've got this convoluted mash-up of concepts from C/C++ and asm in my head, and it's such a headache to mix 'n match between the two. And it doesn't help when I haven't finished reading that asm guide yet...
I am actually glad I knew C first, because I could easily relate the asm code to how it's done in C and vice versa, also because a lot of things you can use in asm come from C (such as C library functions), and documentation for functions (such as Linux sys calls) often is written in C syntax.
I am actually glad I knew C first, because I could easily relate the asm code to how it's done in C and vice versa, also because a lot of things you can use in asm come from C (such as C library functions), and documentation for functions (such as Linux sys calls) often is written in C syntax.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.