Thread: Now that I'm used to C++, printf() >>>>>> cout >> endl;

  1. #31
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Now that I'm used to C++, printf() &gt;&gt;&gt;&gt;&gt;&gt; cout &gt;&gt; endl;-12953d1379367011-now-i%u002527m-used-cplusplus-printf-cout-endl%u00253b-paris_tuileries_garden_f-jpg
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #32
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Whoa, this topic grew a lot in my absence O_o

    Well, I only made this topic because I was coding a Delaunay triangulation. If you are unfamiliar with this algorithm, the idea is, take a set of points in 3D and then triangulate. Create a tetrahedron out of every possible 4 points such that there are no collisions AND the resulting tetrahedra are composed entirely out of the closest possible points. This is used commonly in computer graphics and modelling.

    But it's even making its way into physics as well. I'm not gonna get into right now but you can use the Delaunay triangulation to create a Voronoi tessellation which you can then use for finite volume hydrodynamics which means, I'm going to use this do computational fluid dynamics. These are buzz words, yes, but it's a lot shorter than me describing it in layman's terms. Plus, wikipedia has pretty pictures.

    But yeah, I was coding this and I was like, Oh my God, debugging is sooooo tough.

    The good news is, I solved all my bugs and I did it, guys. The dude with a BS in physics can actually code a Delaunay triangulation. I only say that because I've gotten flack about physicists not being programmers but this one is. I earned my stripes. I tore into code I never thought I'd be capable of understanding, let alone complete. I might be crying right now but it's only because it was such a journey.

    What was my huge bug? Oh yeah, I had to scan the address of everything. Literally, when my code ran it spent like half the time running, printing. I printed out everything, omg. I tracked violating addresses (basically, where's this math violation start? Okay, I'ma just backtrace it.) Doing that, I found several errors in my programming and I learned that the order in which you allocate points for a tetrahedron matters soooo much. Mostly colliding tetrahedra and points not being in the mesh anymore, were my two largest problems.

    Ironically enough, the only debugger I used was valgrind and my IDE was gedit, blue theme. Plus the handy ctrl+v and ctrl+f which I used for backtracing.

    But yeah, I don't know if that means I'm super bad or not but I like my dinosaur tools. I was stubborn about learning C++ but I'm glad that I did because I used vectors like a boss to write my code.

    I can't help but wonder if this'll be true of debugging as well but I like using gedit. It's so simple and without these extra tools, I'm forced to actually think about my code. I almost drove myself insane but I like the way I do things. I like looking at code's guts up close and personal and deciding where I should put print flags.

    Aside from that, I have no idea where this topic went...

  3. #33
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I think I just hate the idea of manually printing out every address, and manually doing backtracing in order to go bug hunting like you say. I mean, an hour, tops, with a competent tutorial, and you would have had a program dump out all that information. Plus, especially with the advent of GUI front ends, it is the kind of thing you learn once, and then you understand 99% of the features of any debugger ever. It all comes basically free of charge and you don't necessarily have to write code to do it. I guess what I want to say is you could have been free to reason about the problem instead.

    I don't want to knock people who use printf() or whatever. I've done it, but I've done it in the same way you complete a prison sentence, and now I'm an intellectually free man.

    Yeah, I went there.

    As for where the topic went, I have no idea. I think it's a combination of misunderstandings, exaggeration, and strong, misplaced feelings.
    Last edited by whiteflags; 09-18-2013 at 02:40 AM. Reason: better tutorial

  4. #34
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    Another part of this is probably code size too, a lot of the stuff I write is very small, and interpreted at that. Python pretty much has built in debugging as it does the tracing and whatnot. Even for small C programs though, I'll throw in the printfs. A debugger is a necessity for larger code. For example, Snes9x-GTK crashes when you try to open a ROM after deleting the .snes9x folder. I'm going to have to compile with debug flags and pull out the debugger, no way would I try otherwise.

  5. #35
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Wow, that gdb tutorial is actually useful. I'm reading about how to examine memory because that's honestly all I need gdb for. Very neat stuff and I really like what I'm seeing.

    And Epy, you're so right. The longer the code, the harder it is to debug and as of now, my entire project is 1730 lines. That's actually kind of hard to maintain. I've never written anything so big before but it was hard to manage just this. I couldn't possibly imagine something like 5000 lines or even up to 10000.

    Okay, I'm starting to see the brilliance of a debugger.

    Man, this really is just like C++. Who am I? Using C++ and debuggers? When did this happen?

  6. #36
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by MutantJohn View Post
    Man, this really is just like C++. Who am I? Using C++ and debuggers? When did this happen?
    February, 2013
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cout code, endl, and \n help?
    By ZezXion in forum C++ Programming
    Replies: 5
    Last Post: 11-15-2012, 06:16 PM
  2. printf to cout
    By crzy in forum C++ Programming
    Replies: 9
    Last Post: 04-28-2008, 03:05 PM
  3. cout << oct << -12 << endl; ?
    By manav in forum C++ Programming
    Replies: 1
    Last Post: 04-16-2008, 03:39 AM
  4. cout << SunTradingLLC << "is looking for C++ Software Developers" << endl;
    By sun trading in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 04-02-2008, 11:48 AM
  5. printf/cout
    By Ivan! in forum C++ Programming
    Replies: 4
    Last Post: 03-02-2003, 03:23 PM