Thread: Moving from C to C++

  1. #31
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    >> I backed up my my reasons for beleiving C++ is largely a waste of time and space,
    Show me where.

    >> without being insulting, which I believe is against the rules here.
    you made a baseless attack on C++ and by extension those who use it. I found that insulting.

    >> That article started this whole debacle?
    no esbo's accusation (which he has yet to provide anything resembling a logical argument to back up) started this whole debacle.

    >> C's a great language
    no, it's really not anymore. It has it's uses in certain fields (embedded development mostly), but (in the general case) these days the only reason to C is if the only other alternative is assembly. It's not that it's a bad language, it's just been superceded by better alternatives. Unless you are working in a severely memory constrained environment, there is nothing you can do in C that cannot be done better in C++.

    >> neither of us were alive in the 70's
    hey some of us were!

    At this point, I've better things to do than waste anymore time trying to educate esbo. I comfort myself with the fact that I'll hopefully never have to interact with his code.

    "Never argue with an idiot, they drag you down to their level and beat you with experience"
    Last edited by ChaosEngine; 05-03-2006 at 06:08 PM.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  2. #32
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Well I have knocked up a program in C to analyse poker hands (similar to Pokertracker
    if you are an online poker player), it has to parse over 30,000 hands (text files).
    I dread to think how long it take to run in C++.
    I can't really think of any benefits C++ would have offered me in writing it and the
    few that can think of would probably slowed it down considerably. I can't think of a single
    think which could be an 'object', or of any uses for any of the other more bewildering
    concepts in C++.
    This is not a forum entitled 'praise C++', criticism is equally valid, if you want a forum
    purely to sing the praises of C++ then you should make that clear. I am entitled to my opinion of C++ and you are entitled to disagree with it. However I don't need to use
    personally insults to back up my arguements, because in reality they don't back up
    an arguement, they weaken it.

  3. #33
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by esbo
    Well I have knocked up a program in C to analyse poker hands (similar to Pokertracker
    if you are an online poker player), it has to parse over 30,000 hands (text files).
    I dread to think how long it take to run in C++.
    I can't really think of any benefits C++ would have offered me in writing it and the
    few that can think of would probably slowed it down considerably.
    I know I shouldn't but...

    that is not presenting an argument. You have made 2 baseless assumptions about a language you admittedly know nothing about apart from some vague fear that it'd be slow.

    Quote Originally Posted by esbo
    I can't think of a single think which could be an 'object',
    You're joking, right? This is an easy candidate for an OO design.
    I thought of 3 when you said "poker":
    card, deck, hand. Any of those sound like "objects" to you?

    Quote Originally Posted by esbo
    or of any uses for any of the other more bewildering
    concepts in C++.
    I'll presume since you're pretty much ignorant of C++ as a language you're not talking about any of the truly scary C++ stuff (e.g. template metaprogramming) and focus instead on things like templates and the STL.

    Here's a start for you: you probably have some sort of array or linked list to represent a deck or hand? You could use a vector for this. Presumably you have an algorithm to shuffle the deck? STL has random_shuffle that'll randomly reorder your deck WITHOUT causing duplicates.

    I can almost guarentee your poker hand analyser could be re-written cleaner, shorter and quicker in C++.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  4. #34
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    Quote Originally Posted by ChaosEngine
    >> C's a great language
    no, it's really not anymore. It has it's uses in certain fields (embedded development mostly), but (in the general case) these days the only reason to C is if the only other alternative is assembly. It's not that it's a bad language, it's just been superceded by better alternatives. Unless you are working in a severely memory constrained environment, there is nothing you can do in C that cannot be done better in C++.
    as you said C has a very distinct use still in some fields. C++ on the other hand hasnt because in fields where you would say it can be better done in C++ it can always be done even better in another more high level language. IOW, C has been superceded by C++ in terms of application development, but C++ has long since been superceded by even better languages

    C++ is more an academic toy, I use it just for hobby

  5. #35
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    /* grabs popcorn */


    You use a car to navigate land, and a boat to navigate water. You can also use a car to navigae water and a boat to navigate land, but undefined behaviour will result. Esbo the old fisherman is arguing against the usefulness of cars and everyone else are arguing against the usefulness of boats. I'll just sit back, grab a soda and enjoy the show.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

  6. #36
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Actually, I made the mistake of talking. I just wanted to make my opinion and my preference known. A programmer doesn't even get to choice how he gets his job done. You will code in whatever your boss wants you to code in. So it would be good to know a lot of languages; making everything we're yelling about moot.

  7. #37
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    C++ is more an academic toy, I use it just for hobby
    It is obvious from that stupid idotic statement that you are absoletly clueless about the topic. Go home and play with your craylos.

  8. #38
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    Quote Originally Posted by Ancient Dragon
    It is obvious from that stupid idotic statement that you are absoletly clueless about the topic. Go home and play with your craylos.
    I used it at work for 7 years only to find out app development can be done way faster and just as performant in other languages.

    let bjarne stroustroup and his buddies discuss the merits of
    partial templatized function arguments with default arguments with protected inheritance from pure virtual baseclasses with default implementations. Then others can make actual programs
    Last edited by Laserve; 05-04-2006 at 05:53 AM.

  9. #39
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    let bjarne stroustroup and his buddies discuss the merits of
    partial templatized function arguments with default arguments with protected inheritance from pure virtual baseclasses with default implementations. Then others can make actual programs
    I admit there are some features of c++ that I hate and never use -- templates is one of them. Sure, I'll use a few from stl but I don't bother to write my own or use template from other sources (at least not that I know of). By the time I figured out how to write the template I could have had the whole program written! But that doesn't mean the whole c++ language is something to be ignored and used only as a toy.

  10. #40
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> everyone else are arguing against the usefulness of boats.
    Actually, "everyone else" is only saying that in many cases (such as navigating land) cars are better than boats by explaining that a car has wheels, for example, built-in that make maneuvering over land easier. Nobody is arguing against the usefulness of boats in certain situations, just defending and explaining the usefulness of cars.

  11. #41
    Registered User
    Join Date
    Oct 2005
    Posts
    271
    Interesting thread.

    I consider myself a low-intermediate programmer, and I'd like to ask the pros on the board a question.

    I am interested in finite state automata/transducers, and I'm curious which you guys is think is better for developing such stuff. C or C++?

    And if you think there's an even better language than C/C++ for developing fsa, please enlighten me.

  12. #42
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    We use a FSM for our embedded development here. One of the developers recently refactored our FSM code to be a heirarchical FSM. During this process he replicated several C++ features (mostly polymorphism) in C using virtual function tables. He reckoned he could've done it in about half the time in C++.

    As for an even better language, it depends. If you're not particulary resource constrained, (i.e. you're not looking at anything soft-realtime), I generally believe Python is a better language for most things.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

  13. #43
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Quote Originally Posted by cunnus88
    Interesting thread.

    I consider myself a low-intermediate programmer, and I'd like to ask the pros on the board a question.

    I am interested in finite state automata/transducers, and I'm curious which you guys is think is better for developing such stuff. C or C++?

    And if you think there's an even better language than C/C++ for developing fsa, please enlighten me.
    I would say the safe option is C if you don't know C++, or maybe
    use C++ and ignore it's more bewildering concepts?

    C++ is fine is you ignore the bits which are not C

  14. #44
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    "multi-paradigm"
    C++ is a language for salesmen.
    When explaining OO concepts to my juniors, I describe the various terms as 'marketing hype'
    That said, if not for the marketing hype, it would be more difficult to express the concepts.

    Anyway, esbo, note that you need to introspect when you write that you "don't need to use
    personally insults to back up my arguements, because in reality they don't back up
    an arguement, they weaken it."

    Did you not insult both C++ programmers and salesmen?

    use C++ and ignore it's more bewildering concepts?
    You have not addressed ChaosEngine's points.

    C++ is fine is you ignore the bits which are not C
    Unless there are exceptional reasons otherwise, using C++ and avoiding the Standard Library is just giving yourself a handicap.

    As for an even better language, it depends. If you're not particulary resource constrained, (i.e. you're not looking at anything soft-realtime), I generally believe Python is a better language for most things.
    Sorry, ChaosEngine, Python is a language for salesmen too :P
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #45
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Location
    Chch, NZ
    Posts
    597
    Quote Originally Posted by laserlight
    Sorry, ChaosEngine, Python is a language for salesmen too :P
    if so, call me a salesman.

    Can I interest you in productivity gains? you'll shed days off your deadline and your code will be readable as never before! but wait, there's more! call today and receive free platform independance! Pay by credit card and we'll throw in a massive StandardLibrary(tm)!
    and if you're still not satisfied, fire up Boost.Python and integrate with C++! See http://www.python.org for more details

    warning: use of python may cause depression when you're forced to go back to other languages.

    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Moving Average Question
    By GCNDoug in forum C Programming
    Replies: 4
    Last Post: 04-23-2007, 11:05 PM
  2. moving median function
    By supermeew in forum C Programming
    Replies: 0
    Last Post: 05-04-2006, 02:37 PM
  3. Replies: 4
    Last Post: 01-16-2006, 05:58 PM
  4. 3D moving
    By bluehead in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2005, 05:46 AM
  5. Simple program i cant get (dot moving)
    By Lupusk9 in forum C++ Programming
    Replies: 4
    Last Post: 09-14-2004, 08:04 PM