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 hate when people who are smarter than me and know more about programming argue about this stuff. How am I supposed to know who to listen to? I guess I don't have any more ambitions of becoming a programmer, it will probably just be a hobby. But I've got my big blue Bjarne Stroustrup book where he teaches all about C++ and he says it's better to skip C and just learn C++. And then Linus Torvalds says C++ is evil. If it was one of them vs. Britany Spears or something I'd know who to listen to but Torvalds vs Stroustrup? Beats me.
So then for my little projects should I stop trying to do C++ stuff and just code it all in C? Or can I basically code like a C programmer but use new and delete? Or should I just not bother thinking about and just do whatever to get my project done and then look back after I am done and realize how I should have done it? I don't know.
Click here to see the post LQ members have rated as the most helpful post in this thread.
I hate when people who are smarter than me and know more about programming argue about this stuff. How am I supposed to know who to listen to? I guess I don't have any more ambitions of becoming a programmer, it will probably just be a hobby. But I've got my big blue Bjarne Stroustrup book where he teaches all about C++ and he says it's better to skip C and just learn C++. And then Linus Torvalds says C++ is evil. If it was one of them vs. Britany Spears or something I'd know who to listen to but Torvalds vs Stroustrup? Beats me.
So then for my little projects should I stop trying to do C++ stuff and just code it all in C? Or can I basically code like a C programmer but use new and delete? Or should I just not bother thinking about and just do whatever to get my project done and then look back after I am done and realize how I should have done it? I don't know.
Torvalds might be right, but from a different point of view.
When I think about C++, I'm becoming a conspiracy theorist. Here's my take on it.
Let's first consider "C". We have CPP -> pure "C" conversion, and we can see the intermediate result (pure "C").
Further along the way with "C" - it is translated into assembly, and we can see the intermediate result (assembly).
Let's consider Perl and its 'Inline::C' module. We can see the intermediate result ("C" from within Perl translated into XS and then in pure "C").
Now let's consider C++ and its template engine. We can NOT see the intermediate result, though there is no real obstacle on the way. So it feels like C++ designers made debugging intentionally difficult. I don't know why - job security ?
Last edited by Sergei Steshenko; 04-14-2010 at 08:10 PM.
Or should I just not bother thinking about and just do whatever to get my project done and then look back after I am done and realize how I should have done it?
That's how I do it: get the dirty work done first, optimize later. If the initial draft of the program was done in C, and you think it could be done better in C++, then change it (or rewrite it if necessary) to be in C++.
It's funny Torvalds is so hot headed in that post. I saw him on Charlie Rose once and he was acting like some real level-headed guy. And he was talking about how he didn't understand people like Steve Jobs and Richard Stallman who are always so driven and positive that they are right. But in his post he seems exactly the same way. Or maybe he was just having a bad day. I don't know.
Whilst not wanting to dismiss everything that was raised by Torvalds it was more of a rant than anything else. On to Stroustrup, I don't have his book at hand but if I recall correctly his argument is more about learning to code the C++ way. With that in mind it is better (he argues) to forget C and immerse yourself in C++.
What is best for you? Find out whatever it is that works for you. However, I would make one suggestion if you are coding in C++ try and add to your understanding with each little project. For example look at classes, start using those. Even if you only place your functions within the class structure that will be a start. Think about the questions, which classes do I need? Which function goes in which class?
Hey wait wasn't there a big deal about how Gimp and the GTK library were made with C instead of C++ and lots of people think it is inferior because of this? And then the QT library and KDE is C++ all the way, isn't it? But doesn't Torvalds tell everybody to use KDE? Wtf. That don't make no sense.
And actually, why would anybody care what window manager somebody else uses? Computer programmers are fippin' weirdos.
For example look at classes, start using those. Even if you only place your functions within the class structure that will be a start. Think about the questions, which classes do I need? Which function goes in which class?
Build on your knowledge incrementally.
Yeah I guess. I pretty much know all that stuff already. I mean I do information hiding and I invent structures and I can make linked lists and stacks myself or use the STL. I just don't have much experience doing big projects so when people start talking about "abstracted programming models" I get kind of lost. I'm thinking it's probably something you can't really understand until you make some big projects and maybe do it the wrong way once or twice.
You know what's funny is at gamedev.net everybody swears by C++. Once I said not too seriously that "private member variables are useless" and everybody jumped on me. Once they told me to read a book on design patterns. I actually got the book: http://www.amazon.com/Design-Pattern.../dp/0201633612
It's pretty old, mid 90's, I guess it's still good. I don't know. I figure I should do a big project first and then read the book so it will make more sense to me.
Now let's consider C++ and its template engine. We can NOT see the intermediate result, though there is no real obstacle on the way. So it feels like C++ designers made debugging intentionally difficult. I don't know why - job security ?
I don't know what you mean by "debugging intentionally difficult".. A long time ago I realized that templates are really just macros that don't stomp all over the language and *everything* about them made sense, including compiler messages
Also, the equivalent C out of pretty much every C++ compiler on the planet would make your brain explode from the name mangling alone. I manage anyway because I know what it would be without all the details I really don't care about because of the feature mismatch between C++ and the underlying C-biased toolchain.
Also, comparing C and C++ is rather silly anyway, they are separate languages and should be treated as such. "C/C++" is an utter abomination.
As for Linus's rant, he has some good points.. because in his particular domain, writing "proper" C++ doesn't really win you that much in terms of maintenance. I've been doing something with that property myself lately.
I don't know what you mean by "debugging intentionally difficult".. A long time ago I realized that templates are really just macros that don't stomp all over the language and *everything* about them made sense, including compiler messages
...
Look, if we are talking about parsing/compilation, we are talking aboput so called "rewriting rules". So, "show me the text", i.e. results of rewriting. Show me "in real time" how templates are expanded.
I can do this in my own template engine written in Perl, for example.
Hey wait wasn't there a big deal about how Gimp and the GTK library were made with C instead of C++ and lots of people think it is inferior because of this? And then the QT library and KDE is C++ all the way, isn't it? But doesn't Torvalds tell everybody to use KDE? Wtf. That don't make no sense.
I, personally, don't judge a program by the language it's written in. If it's written in a language I don't like, nobody says I have to modify the code. As long as the program's developers like it, it's fine.
And another thing that I saw somewhere was that Torvalds said that KDE4 is such a mess that he hates KDE now.
Quote:
Originally Posted by icecubeflower
And actually, why would anybody care what window manager somebody else uses? Computer programmers are fippin' weirdos.
If you want to compare Torvalds and Stroustrup, compare what they *really* achieved (I mean projects, not books) and you'll get your answer. BTW, think of one platform where c++ is widely used.
Just my personnal opinion
Look, if we are talking about parsing/compilation, we are talking aboput so called "rewriting rules". So, "show me the text", i.e. results of rewriting. Show me "in real time" how templates are expanded.
I believe there's a way you can ask CLang for that.. Useful for debugging the compiler, and utterly useless for debugging actual programs.
Quote:
Hey wait wasn't there a big deal about how Gimp and the GTK library were made with C instead of C++ and lots of people think it is inferior because of this? And then the QT library and KDE is C++ all the way, isn't it? But doesn't Torvalds tell everybody to use KDE? Wtf. That don't make no sense.
QT and KDE aren't really written in C++. It's written in C++/moc. Besides, the issue with GTK is that it hacks up C to the point where it's not even recognizable as C anymore because it tries to implement OO features that are built into C++.
Quote:
If you want to compare Torvalds and Stroustrup, compare what they *really* achieved (I mean projects, not books) and you'll get your answer. BTW, think of one platform where c++ is widely used.
Just my personnal opinion
C++ is used pretty heavily on the Joint Strike Fighter (aka F-35). C++ is also a major language behind Fortran for scientific computing (due a lot to the kind of optimizations possible with Expression Templates).
For graphics or scientific computing, OO programming is ok, I agree with that. The problem is when people use C++ for everything (there is an interesting point of view from Eric S. Raymond here.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.