LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2010, 07:57 PM   #61
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Rep: Reputation: 34

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.
Old 04-14-2010, 08:02 PM   #62
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Nether, make the choice yourself.
 
Old 04-14-2010, 08:09 PM   #63
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by icecubeflower View Post
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.
 
Old 04-14-2010, 08:12 PM   #64
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Just always take Sergei Steshenko's posts with a grain of salt.
 
1 members found this post helpful.
Old 04-14-2010, 08:15 PM   #65
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by icecubeflower
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++.

But in the end, the choice is still yours.
 
Old 04-14-2010, 08:17 PM   #66
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Rep: Reputation: 34
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.
 
Old 04-14-2010, 08:22 PM   #67
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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?

Build on your knowledge incrementally.
 
Old 04-14-2010, 08:24 PM   #68
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Rep: Reputation: 34
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.
 
Old 04-14-2010, 08:34 PM   #69
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Rep: Reputation: 34
Quote:
Originally Posted by graemef View Post
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.
 
Old 04-14-2010, 10:06 PM   #70
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Quote:
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.
 
Old 04-15-2010, 02:22 AM   #71
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by tuxdev View Post
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.
 
Old 04-15-2010, 06:46 AM   #72
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by icecubeflower View Post
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 View Post
And actually, why would anybody care what window manager somebody else uses? Computer programmers are fippin' weirdos.
Maybe.
 
Old 04-15-2010, 08:28 AM   #73
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
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
 
Old 04-15-2010, 08:38 AM   #74
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
Quote:
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).

Last edited by tuxdev; 04-15-2010 at 08:41 AM.
 
Old 04-15-2010, 09:09 AM   #75
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
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.)

Last edited by manu-tm; 04-15-2010 at 09:11 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration