Thread: How do I make a GUI interface?

  1. #31
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Welder View Post
    You say why not just use assembly? Well, as far as speed goes, C is the fastest mainstream language next to assembly. I find myself incorporating assembly language into many parts of my programs. But how many of you have had to read over thousands of lines of assembly code written by someone else? Or even yourself months before. I have. I was lucky enough to be the person in charge of converting about 10,000 lines of PowerPC assembly code and several thousand more of ARM7TDMI into C. I tell you, by the time I was done I was eating, sleeping/dreaming, crapping assembly code. I don't care how documented that code is, it leaves you staring and jumping around quite a bit to figure out what is going on. Even for the best assembly language programmers. On top of that, what happens when Microsoft decides to adopt a completely new processor such as Apple did when merging from the 68000 to the PowerPC, and then from the PowerPC to Intel's x86 series processors. Your nearly unreadable code is now completely worthless.
    But I do agree with you that assembly doesn't necessarily need to be faster than optimized C/C++ code. Just remember, kids: the language only does what YOU want it to do! If you want speed akin to assembly or C in C++, then you can have it!

  2. #32
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'm with Elysia on this. I have worked on C++ projects that are WELL optimized and would be very hard to manage to do with C - one involved emulating the exact behaviour of a chip, where a 5-bit register had to be a 5-bit register. Doing this:
    Code:
       int5 x, y;
       ... 
       x = getsomething();
       y = getother();
       x += y;
    in C and maintaining a 5-bit value would not be nice.

    I was asked by one of the senior managers if I thought we could speed it up by using C instead. My answer was "Probably less than 5%, and it would take far longer to achieve that, than it would take to save 5% by optimizing certain parts of the code". I spent several weeks profiling, analyzing the profiles, and improving the performance. One of the biggest gains was to put if-statements around certain logging calls [that normally didn't get output, so we'd check the output limit FIRST, then call the logging function ONLY if there was actually going to be an output. Just "calling a function that would just return" caused a whole lot of overhead].

    C++ as such is not slow. It can be written in a way that produces slow and bulky code. Using STL is a choice that often introduces extra code and extra execution time - which is fine if your application is not terribly time critical, where time-to-market is more important, etc. As usual, it's often just a small portion of the code that is really performance criticial, and if necessary, you could always write THAT BIT in Assembler, plain C or whatever you think will give sufficient benefit.

    --
    Mats
    Last edited by matsp; 11-29-2007 at 04:15 AM.
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #33
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    The benefits in clarity, maintainability, and extendability that C++ offers to your project far outweigh any small performance degradations you may get.

    I had really thought this debate was over a long time ago but I keep seeing it time and time again. IMO C++ has proven itself to be fast enough for the performance based applications. Nearly all of the video games at your local store were coded in pure C++. I doubt seriously anyone is still hanging on to their C API's.

    I'm finding more often than not the people who make this claim are the same bunch that love to reinvent the wheel.

  4. #34
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    Quote Originally Posted by Bubba View Post
    I'm finding more often than not the people who make this claim are the same bunch that love to reinvent the wheel.
    That's what engineers do best!

  5. #35
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I'm with you Bubba. There was a time, a long while back, when I thought you couldn't write C++ OS code, but I'm convinced now that it's perfectly possible. It just requires a good steady skill of OOD, and some good thinking [and the latter is definitely needed if you want to do an OS in C too!]

    Quote Originally Posted by Bubba View Post
    I'm finding more often than not the people who make this claim are the same bunch that love to reinvent the wheel.
    Either that, or the people who have yet to do some serious programming in C++.

    And I think, because C++ offers a richer set of functionality to the user, it can be confusing to new users. You definitely need more experience as a C++ programmer than you do as a C programmer, to write and maintain code well. At least, that's my opinion.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #36
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    On the other hand, C++ code can be much easier to read than eqalient C code, so it's a good thing.

  7. #37
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Elysia View Post
    On the other hand, C++ code can be much easier to read than eqalient C code, so it's a good thing.
    Depends on who wrote it, I'd say - and that goes for both C and C++. You can write messy code in both languages - in fact, it's probably easier to do in C++ [just look at the examples with virtual functions and default arguments for some ways to obfuscate the code].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #38
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, I just saw how messy it can be - C++ almost as C, when making a game -_-
    But I think that with polymorphism, classes and C++ functionality, written properly, the code will become easier to read and maintain rather than hard-to-read C. Of course, if using functions properly, you can write clean C, too, but I do think C++ is a little better in that department.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. First time GUI program tips and help needed.
    By naja77 in forum C Programming
    Replies: 1
    Last Post: 08-01-2008, 08:28 AM
  2. How do you make a program to interface with another?
    By Finchie_88 in forum C++ Programming
    Replies: 6
    Last Post: 08-24-2007, 03:48 AM
  3. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  4. Trying to make a menu screen
    By circle in forum C Programming
    Replies: 0
    Last Post: 12-07-2004, 06:06 AM
  5. gui interface tutorials?
    By gamer in forum C++ Programming
    Replies: 2
    Last Post: 11-22-2004, 02:36 PM