Thread: How do I make a GUI interface?

  1. #16
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Welder View Post
    That is a silly question. You may as well ask why people use C++ instead of VisualBasic or C#. I've been using straight C since 1998 and have never been limited on resources or code production times. Plus it creates smaller and faster executables.
    Well VB & C# aren't portable. But if you want really small & fast programs, why not go a step further and program in assembly?

    I'm not saying there's no use for C. Sometimes you have to use C (or assembly), but since C++ gives you so many more tools to write and manage your code, why wouldn't you take advantage of those tools when the option is available to you? For example, in C you have to write way too much code to check if malloc() failed, free memory before returning, checking errno...

  2. #17
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    That's just a complaint against C in general. Hardly worth noting for GUI programming more than for CUI programming.

  3. #18
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Well VB & C# aren't portable
    And C is more portable than C++ - be consistent in your arguments
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #19
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by vart View Post
    And C is more portable than C++ - be consistent in your arguments
    Barely. Unless you're using a brand new platform that doesn't have a C++ compiler yet.

  5. #20
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    A lot of the embedded systems, as in A LOT. There's nothing to gain by using C++ with Win32 just as there's nothing to lose by using C with Win32.

    >Preferance, I guess. I can't see how someone wants to write a C program seeing how it lacks OO and good functionality such as smart pointers, vectors, etc.

    I can't see how someone doesn't want to drive an automatic car with power steering.

  6. #21
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by zacs7 View Post
    A lot of the embedded systems, as in A LOT. There's nothing to gain by using C++ with Win32 just as there's nothing to lose by using C with Win32.

    >Preferance, I guess. I can't see how someone wants to write a C program seeing how it lacks OO and good functionality such as smart pointers, vectors, etc.

    I can't see how someone doesn't want to drive an automatic car with power steering.
    That's a bit of a contradiction. First you say there's nothing to be gained by using C++ with Win32, then you say you can't see how someone doesn't want to drive an automatic car with power steering (i.e. C++).

    As for embedded systems, how many developers actually write software for those compared to real computers (i.e. boxes with a keyboard, hard drive, monitor...)? Also, how often would you need to write software for both embedded systems and normal computers? Most of the time server software is written for Windows & UNIX (and sometimes also z/OS & AS/400), while end user software is made specifically for Windows or Mac.

  7. #22
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    A lot of the embedded systems, as in A LOT. There's nothing to gain by using C++ with Win32 just as there's nothing to lose by using C with Win32.
    Actually, I recall some guy who argued that "embedded programmers could build much better systems using C++ rather than C", and thus asked Why are you Still Using C? (Warning: PDF)
    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

  8. #23
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > That's a bit of a contradiction. First you say there's nothing to be gained by using C++ with Win32, then you say you can't see how someone doesn't want to drive an automatic car with power steering (i.e. C++).

    I put your argument metaphorically, because it's silly. The fact is, manual cars are cheaper and some people find them nicer to drive (not to mention they're cheaper to run). You basically said, why bother with gears? And all that shaz, if you can get the car to do it for you.

    I still don't know what you're arguing about, C has a purpose just as C++ does. Whether those purposes overlap is relative to the job. Even if you could write must better embedded systems with C++, it doesn't change the fact that C is still widely used for the job.
    Last edited by zacs7; 11-23-2007 at 09:26 PM.

  9. #24
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    I believe it started with me asking why you'd want to write a Windows program in C. Although the Windows API calls would be C function calls, the rest of the program would be easier and safer to write in C++ where you can use RAII objects...

  10. #25
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by zacs7 View Post
    I put your argument metaphorically, because it's silly. The fact is, manual cars are cheaper and some people find them nicer to drive (not to mention they're cheaper to run). You basically said, why bother with gears? And all that shaz, if you can get the car to do it for you.
    But the thing is, even with C++, your "car" can still be made to drive on manual. In other words, you don't need to add "auto" functionality. And to further that silly argument, why do you think there are automatic cards? Because it's convenient, I tell you. People like that.
    And even with an automatic car, what's to stop you from doing everything a "manual" car can? This argument is silly. C++ is pretty much better in all kinds of ways than C. C++ can do everything C does and it can also DO C!
    Not to mention that I find it silly when you can create more robust code, getting things out of the door faster, etc. And an "auto" car doesn't necessarily need to cost more or draw more power to run - it's all up to how the design was made.

    All in all, I find that argument very silly.

  11. #26
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Don't turn this into a C vs C++ argument, it's stupid. It's like comparing pears and apples. A pear can do anything an apple can do (except roll ). I know auto's are convenient, but people also like to do things manually... cut out the middle man. FYI, no matter how you put it, the same car in auto vs manual will most likely cost more, more expensive to maintain and reduced performance. Why else do you think 'race' cars' aren't auto?

    The car argument was purely a metaphor, don't take it literally. And no I'm not saying C is higher performing than C++, as you said it depends how the design was made. It's like comparing a hammer with a screw driver, sure you can hammer nails in with a screw driver, but why would you?

    I'm only arguing that it's perfectly fine and viable to write your Win32 program in C, and there's no reason why you shouldn't. If you say C++ is easier for windows programs, blah blah blah, then why not use C# or even... Visual Basic?

    Okay enough of the metaphors

    I'm gonna go mourn the downfall of my country now... Labor won -- sigh.
    Last edited by zacs7; 11-24-2007 at 05:00 AM.

  12. #27
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by zacs7 View Post
    I'm only arguing that it's perfectly fine and viable to write your Win32 program in C, and there's no reason why you shouldn't.
    Well, the only thing I can say is that there's plenty of reason to write Win32 programming with C++. Even though the API is C, C++ gives you a lot of benefits still. Again, it's just a matter of preferance, but let's not state it's silly to not write Win32 programming in C, which, I believe, was the original argument.

  13. #28
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Please don't tell me we are really arguing over C vs C++? Unfortunately I cannot close a thread on the grounds of it being absurd.

    Standard options for GUIs under Windows:

    • MFC - Microsoft Foundation Classes
    • Pure Win32 code
    • C++/CLI


    1. MFC is very easy but also very picky. If you are not an adept C++ programmer MFC will give you nightmares (and even sometimes if you are ).

    2. Pure Win32 is not much better and is fairly hideous looking code.

    3. C++/CLI - C++ for .NET essentially. The CLI is easy to use but may confuse you when you come back to ISO C++ since C++/CLI is about as far from ISO as you can get. It's not bad for GUIs, it's still inherently C++, and it's very portable across Windows platforms or platforms that support .NET

    In short your options for GUI's written in C/C++ are extremely limited and those written in pure C is nearly non-existent. I recommend using C# for GUI apps but if you are deadset on C/C++ I would favor MFC even though it's quite old.
    Last edited by VirtualAce; 11-24-2007 at 10:40 AM.

  14. #29
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    That's just the thing - let's stop arguing by saying it's silly to write something in C++ simply because it's based in C. It works just as well in C++ as C. And let's leave it at that. Preferance.

  15. #30
    Registered User Welder's Avatar
    Join Date
    Oct 2007
    Location
    Washington
    Posts
    100
    The reason I use C is because the software I write ALWAYS needs to be fast. I rarely if ever find myself wishing I had OO capabilities. The software I write (or used to when I was in my prime as a programmer) were compilers, emulators/simulators, image/video optimizers and such. In many tests done at my old company C had been proven faster. If you have an app that is all GUI with very little CPU intensive code then C++ is perfect. You won't notice millisecond slowdowns here and there. But when writing a compiler to compile millions of lines of code in the shortest amount of time with the maximum readability of the source code, C is the best choice.

    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.

    With that said, I am learning C# and Visual Basic .NET as we speak. I have written some code that needs to be fast and have use of pointers in C. I compiled it into a .dll and am writing my interface in Visual Basic and may merge my code over to C# as I am really enjoying it's similarity to my beloved C and C++. Then I just call up my .dll and all is good.

    But if I had it my way, we would all be using the original object oriented programming language, FORTH. The OOP that was designed years before OOP was even thought about.
    Last edited by Welder; 11-29-2007 at 01:20 AM.

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