Slashdot Mirror


Qt vs MFC

Philippe Fremy writes: "I have just published and translated into English a comparison between Qt programming and MFC programming, which was written by Pascal Audoux (a fellow coworker). I am interested in feedback and would love to add quotes from developers that have used both toolkits." Here is the English version ("Qt vs MFC") as well as the French one ("Qt contre MFC").

126 comments

  1. Why would you use Qt? by Anonymous Coward · · Score: -1, Troll

    .. when MFC is much faster and has been industry proven.

    1. Re:Why would you use Qt? by pmz · · Score: 2

      .. when MFC is much faster...

      And not portable. Remember, it is becoming more practical to take off the blinders and support other operating systems. Writing a new application to support both UNIX and Windows, for example, not only results in a better application architecture (abstracted for portability) but also distributes risk (so what if either Microsoft or Apple or Linux falls by the wayside; I'm covered).

      ...and has been industry proven.

      ...to be a kludge.

      So, to fight a troll with a troll:

      Why use MFC...when Qt provides better risk mitigation and has been industry proven.

    2. Re:Why would you use Qt? by Blob+Pet · · Score: 1

      And not portable

      You could always recompile with the help of MainWin, but the performance is horrible. This is essentially what Microsoft uses to port IE to UNIX. That's why wxWindows and Qt are very appealing to me right now.

      --
      "...today consumers have been conditioned to think of beer when they see a bullfrog..."
    3. Re:Why would you use Qt? by LWATCDR · · Score: 1

      Frankly MFC is a pain. It is pretty buggy in places. I did not like this artical all that much. It was pretty shallow to asy the least. wxWindows looks very interesting and there is a very good artical on porting MFC code to it in IBMs website.

      --
      See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
    4. Re:Why would you use Qt? by Anonymous Coward · · Score: 0

      > MFC is much faster

      I have never seen any facts in one direction or the other, could you point me to your references ?

      My experience is that both MFC and Qt are fast. With usually less flickering in Qt.

      One thing that is sure however, is that MFC is not faster in term of development speed.

    5. Re:Why would you use Qt? by slustbader · · Score: 1

      Why is MainWin's performance so slow? Is it slower than porting with winelib would be?

    6. Re:Why would you use Qt? by ClosedSource · · Score: 1

      "Writing a new application to support both UNIX and Windows, for example, not only results in a better application architecture (abstracted for portability) but also distributes risk (so what if either Microsoft or Apple or Linux falls by the wayside; I'm covered)."

      I think your second point is valid, but your first, not always. If portability is not a requirement, the architecture is not improved by the introduction of an abstraction that doesn't model the problem. In addition, comprehensive compatibility would require that the application be portable to other operating systems in addition to those based on Windows or Unix.

    7. Re:Why would you use Qt? by elflord · · Score: 1
      I think your second point is valid, but your first, not always. If portability is not a requirement, the architecture is not improved by the introduction of an abstraction that doesn't model the problem.

      Qt doesn't use abstraction in the same sense of (for example) AWT. It implements its own widgets for each target "look and feel". The down-side is that you possibly end up with something that looks slightly different from the target platform (no emulation is perfect), but you don't suffer the same performance impact or awkwardness (for example, the logical intersection of all targets problem)

  2. The Horrifying Stench Of Open Source Programmers by Anonymous Coward · · Score: -1, Flamebait

    Slashdot admits the truth here.

    As we already know open source programmers stink, both at their jobs, and in general. Take RMS for instance. He can't get a job as a real programmer so he starts the FSF. He also hasn't taken a bath or shower in over 20 years making him stink in general. Living in a dark cave doesn't help either. I don't want to know what is crawling around in his hair.

    I'm sure there are people at your office who are just like RMS if they can hold their jobs. You know they are close because you can smell them. You are spending hours of overtime fixing their code.

    For anyone reading this post none of this is a suprise. However, Slashdot is a bastion of open source programmers. That is why the code is so bad, and its the only website that you can smell over the internet because it reeks!!!!

    What was suprising to me (and to you I'm sure) was that Slashdot admitted in the above linked article that open source programmers stink.

    I commend Slashdot for admitting the brutal yet honest truth.

  3. A linux user goes back by poopbot by Anonymous Coward · · Score: -1, Offtopic

    A Linux user goes back.
    By Tony âoekNIGitsâ Collins.

    Introduction...
    In much of today's online news, we hear of how many people are migrating to GNU/Linux. What we don't seem to hear much of, is users going back to their old operating systems. The reason for this article is to say that I've done just that.

    Yes, I've gone back. After three and a half years of trying to make GNU/Linux work on the desktop, I've decided that it's simply too hard for the average home user. Before I go into my reasons for going back, let me outline what I believe an 'average' home user is. Mr Joe Average is someone who wants to install their OS, boot it up, and it works. He wants to be able to upgrade his PC , and have the hardware work in a few short minutes. He wants to read email, browse the web, talk to his mates online, and play some games. Feel free to disagree with me, this is merely how I see myself. Note: I'm not referring to Grandma using Linux, or even my mum using it. I'm referring to average users who know a little about their computer.

    Three and a half years; that's how long I've been trying to make Linux work on my desktop computer. Right about now, I'm sure that you are now screaming that I didn't try hard enough, or that I'm just plain stupid. Let me assure you that this is not the case. Stupid users don't doggedly stick at something for three and a half years, trying distribution after distribution in the hope of finding the holy grail of Linux desktops. They give up in less than a few hours of trying to (unsuccessfully) install RedHat Linux. Hear now my sad tale of why Linux isn't suitable for my desktop.

    Some background...
    The year is 1998. I've had my Windows '95 computer for around six months. Frustrated with the constant crashes, I desperately asked an online mate for help. Even though he was a windows user, he calmly suggested that I try something I'd never come across before...

    âoeLinux, eh? Never heard of it.â

    âoeOh, it's a free OS that you can download. Apparently it doesn't crash much. Just do an online search for it.â

    Armed with this meagre knowledge, I set out on my quest for the ultimate stable operating system. I searched online, and found places where you could even buy copies of Linux! So, I left the comfort of my warm study, and returned forty minutes later with my first Linux boxed set â" RedHat Linux 5.2. After initially balking at the very basic installer (and few false starts), I had it up and running on my lovely AMD K6-233. I even got X working in no time at all. Then the system booted up for the first time.... and it was dead ugly. I had a very stable new OS, but I didn't even want to look at it. I was happy that I had several installed interfaces to choose from, but none of them appealed to me whatsoever. Wanting to download a nicer interface led me to my next problem.

    I had absolutely no idea how to even get this nice, stable OS onto the internet! After reinstalling windows and RedHat in a dual-boot configuration, I got the help I needed by using Windows and USENET. Strangely enough, I can still remember the name of the long-suffering person who helped me get RedHat online, but that's another story. After looking around online, I discovered KDE. Only up to version one, it was the closest thing I had to a completely useable Linux system. I downloaded all the KDE packages for RedHat 5.2, only to discover another distro called Mandrake, that came with KDE preinstalled and configured. Back to my local distributor, and I was set.

    Mandrake with KDE was exactly what I needed at that stage in my Linux using life, and I stuck with it for over a year and a half. Always seeking the 'perfect' desktop OS, I followed releases from version 5.3 all the way through to 7.0. Eventually I became dissatisfied with Mandrake, and briefly tried a number of other distros until I finally settled on Debian. I was impressed by the simple power, configurability, and the ease of upgrade that is apt-get. I felt good about being among the uber-elite Debian user community. Needless to say, I learned a lot about how to configure hardware under Linux during my time with Debian. I learned to sift through the old HOWTOs on Linux Doc until I found something suitable and accurate, I learned to utilize the power of USENET and IRC. Life was good.

    Right now you must be wondering; âoeWhere is this leading? This guy seemed quite happy with Linux!â. True, I was. After a while, I decided I didn't want to have fine-grained control. I wanted something simple. I was getting tired of the 'stable' Debian release being so out of date, and the 'unstable' distribution being so... well... unstable. I got tired of having to recompile my kernel every time I got new hardware. I got tired of using command line to talk to my PC. It was time for a change. I had good experiences years ago with Mandrake, so I figured I'd try it again. As good as Mandrake 8.1 was, it wasn't what I was after. SuSE Linux 8.0 Professional (boxed set) was installed onto my PC instead.

    I have to stop at this point, and say that SuSE Linux 8.0 (Pro) is the best Linux distribution that I've ever used. It has an easy installer, reasonable hardware support, and comes with the very good KDE 3.0. The box contains seven CDROMS, one DVD and three decent books that would help even the most inexperienced user get up and going. YaST2 is a decent graphical system configuration tool. When (not if) I go back to Linux, I'll definitely try SuSE again. However, there are quite a number of things that have improve (or change completely) before I'll consider going back. Read on for my brief list of things that must must get better before I'll switch back from the Microsoft camp.

    Where GNU/Linux needs to improve...
    X11

    The X Window System is an awesomely powerful, network transparent graphical subsystem. It's perfectly suited to running applications from remote servers. However, this is NOT what a home user needs. My experience with X is that it's too big, bloated, slow and unstable to be any good to the home user. Most crashes that I ever experienced with Linux have been X's fault. My servers don't run X, and they never crash.

    What home users need is something small and fast, so they can run local applications efficiently. I would like to see the X Window System dumped in favour of a hardware accelerated framebuffer, running something like directFB or Qtopia. Home users need a small, fast graphical subsystem, with built in 3d support. BeOS seemed to be on the right track before they went under.

    Fonts are truly awful under X. Most distributions ship with appalling fonts, and there is no standard way to add additional (nicer) fonts to the system. Even after extra fonts have eventually been added, many applications (eg Abiword, Staroffice) refuse to use the new fonts anyway. Perhaps the framebuffer-based graphical subsystem I suggested could incorporate decent font support, and use a readable naming scheme as well.

    Drivers

    While having access to the latest version of the kernel is a good thing for developers, for home users it can be a nightmare. Got RedHat Linux 7.3? Perhaps you run SuSE 7.3 or Debian 2.2. You'll have to download a binary package specific to your distro. (I'm assuming that home users won't change their default kernel, but if they did, that binary package wouldn't even work!) Hardware manufacturers should be able to provide one single driver that works on all minor versions of a major kernel release. This way it would work will all current distros, instead of having to provide multiple binaries or source code. Hardware manufacturers don't want to give out the source, as this often gives away trade secrets about how their hardware is designed.

    The solution seems to be to make binary drivers work on a variety of kernel versions. I'm not sure if this is even possible with the way the kernel is designed (I'm no kernel hacker), but it would go a long way toward making Linux more accessible to the home user. Even if the kernel needs to be redesigned to support this, then in my opinion, it should be done. Linux users are always clamouring for drivers... perhaps if the kernel had something like this, it might one day become a reality.

    Hardware setup

    While SuSE Linux 8.0 gave me some good experiences with hardware detection (such as automatic download of NVIDIA drivers), it also let me down as in this area.

    The good: I recently borrowed a digital camera from a mate at work, to take photos of my case mod. Imagine how happy I was when I plugged it into my nearest USB port, and it was automatically configured (as a SCSI device) and mounted! SuSE even added it to my /etc/fstab file so that it always automounted when plugged in. I was very impressed.

    The bad: Along came my new IDE CDRW drive. At AU$99, I couldn't pass up the purchase. Plugging it in gave me no joy. I was very disappointed that a device so common couldn't be detected and automatically configured under a modern operating system. The instructions on the SuSE support site said to add lines to lilo.conf and reboot. While this is a perfectly acceptable way to get hardware working for a geek familiar with *NIX, I believe that a home user shouldn't have to do more than plug it in. It's an IDE device, it's not that complicated!

    The ugly: Once the hardware was finally working (as a pseudo-scsi drive), the next hurdle was to find decent graphical tools to burn and copy CDs. I finally settled on CDBakeOven, an above average KDE application. It burned CDs from data on the hard drive, but for some reason cdrecord (the command line backend) refused to allow me to copy a cd directly. Yes, it was installed SUID root. CD copying is such a basic function nowadays, why is it so hard to do under GNU/Linux?

    Software distribution

    I'll put this simply. I'm a home user, not a programmer. Why on earth should I have to compile the software I want to use? I know that having the source available is a good thing, but I'll say it again: I'm no programmer. I just want to install software and run it.

    This leads to another point. Although having package databases (such as the rpm and deb systems use) is great, there should definitely be seperation between system packages and additionally installed software. There needs to be a standard installer and database for user-installed applications such as word processors, email clients and games, and it should be seperate from the rpm or deb databases used for system software such as lilo, init and cron. This will make it much easier for home users to know what applications they have installed on their PC, and to easily uninstall them if necessary, without knowing some arcane commands and weird package names.

    Support

    There is a huge wealth of knowledge among the thousands (millions?) of people that run GNU/Linux around the world. If you have a problem, odds are that someone out there can help you, often for free. This is one of the linux platform's greatest strengths. However, Linux users are also its greatest weakness. This may not apply to most of the community, but there is a very vocal minority that gives Linux a bad name. To every Linux user that has ever helped a newbie, I thank you. I have been helped by many a guru, often when I've been asking the simplest of questions. It's the remainder that are a problem.

    I once heard a song by Three Dead Trolls in a Baggie called Every OS Sucks, where Linux users were described as 'elitist nerdy shmucks'. Sadly this is true for much of the 'community'. Too many consider themselves better than the rest of the world because they run Linux. Can you believe that? It's just a computer operating system, but somehow they think that it makes them better than those people who run systems such as Microsoft Windows! Elitism drives people away, as does saying âoeRTFMâ or belittling people who choose a different distro from yourself.

    'Nuff said about that.

    So what now?
    Well, I decided to go back to a Microsoft platform. Initially being paranoid after reading things about DRM and spyware, I bit the bullet and installed Microsoft Windows XP. Like every OS, it has good and bad points; most of which you can learn about from online reviewers. I'll just point out several things that make me want to keep using it instead of GNU/Linux.

    Fast graphical subsystem: Windows has lighting quick graphics, both 2d and 3d. There's no denying it. When I move a window, it refreshes so fast that I don't miss X11 at all. While not quite as nice as some other operating systems, font support is outstanding compared to XFree86.

    Drivers: Point and click to install (as a superuser, of course). Windows warns you if the driver isn't likely to work properly, and can roll back to working drivers if you deliberately choose to install one that hoses your system.

    Hardware setup: My CDRW worked right away, without a hitch. I am able to drag and drop files from the Explorer file manager to the CDRW icon and they get added to the list of things to burn. A quick install of Nero Burning Rom, and I was able to make a backup copy of my game CDs. (I don't like taking originals to LANs where they can get destroyed or stolen).

    Software distribution: All windows software comes in binaries, either with an installer or in a zip file. I hope to never compile an application ever again. Software designed for a different version of windows is 99% guaranteed to run, but if not, there is always 'compatibility mode'. One thing to note, however: Applications designed for single user versions of windows usually only run properly as a superuser, and this includes 3d games. I expect this to be rectified as the rest of the Windows world catches up to a multi-user environment.

    I can't comment on the Windows using community yet. I've not yet had a problem that a simple point and click couldn't fix. However, I will say that my original concern with Windows '95 has been addressed in Windows XP. The stability is finally there.

    Final Notes
    In conclusion, I'd just like to make it known that I haven't completely abandoned the Linux community. My home server still runs Mandrake, and IPCop on my gateway/firewall. There is no way I'd ever put any form of Windows on my server, nor would I ever connect a Windows PC directly to the internet without a *NIX gateway in between. Microsoft has a history of poor security, so I protect myself the only way I know how; using Linux. I will continue to advocate the use of GNU/Linux in the server arena. This is where its strength lies at the moment.

    Because of their history of spreading virii, I don't use the applications that Microsoft has provided with Windows XP. My wife and I use Mozilla for web browsing and email, OpenOffice.org for word processing, and Psi (Jabber client) for instant messaging. All of these are true multi-user win32 programs, and are perfectly interoperable with their Linux counterparts.

    I expect that the Linux community will have something to say about this article; I welcome comments and constructive criticism. Flames will be automatically sent to the Windows equivalent of /dev/null, once I find where that actually is.

    By Tony âoekNIGitsâ Collins

    - posted by poopbot: providing truth in a deceitful world

    2TloJkTYEM Post #348

  4. Why is this on slashdot? by oever · · Score: 1

    Well, that's obvious. From the article:

    The conclusion drawn from our personal experience is obvious. Qt is far better than MFC. You'll produce better programs with less hassle.

    I do agree though. ;-)

    --
    DNA is the ultimate spaghetti code.
    1. Re:Why is this on slashdot? by pmz · · Score: 2

      Qt is far better than MFC. You'll produce better programs with less hassle.

      Very true. Literally within an hour or two, by following TrollTech's tutorial, a person can write and understand working GUI applications. One of Qt's strengths (and a tribute to its design) is how its learning curve is really quite low.

    2. Re:Why is this on slashdot? by RupW · · Score: 1

      One of Qt's strengths (and a tribute to its design) is how its learning curve is really quite low.

      For simple applications, MFC's learning curve is also low - the wizard will generate all the glue code and provide // TODO comments where you plumb in your own code. You can have a simple, fucntional MFC-dialog-application up and running very easily, invoking the MFC API only a few times yourself.

      For an experienced Win32 programmer, MFC's learning curve is pretty much zero (flat?).

    3. Re:Why is this on slashdot? by pmz · · Score: 1

      ...the wizard will generate all the glue code...

      Qt doesn't need wizards, because the API really is quite clean. A person who has never programmed a graphical interface but knows C++ is good to go. The only real impurity in Qt is that the moc preprocessor needs to run as an extra step in the build. However, moc enables the rather simple signal and slot mechanism, which is intuitive and serves its purpose very well.

    4. Re:Why is this on slashdot? by bmwm3nut · · Score: 1

      yes, this is true. but i believe the parent poster said something about "understanding" the gui code. i used to be a programmer for ms apps and it took me about a month to get a handle on all the things that were going on in the mfc. unfortunately i have not done any qt programming, but i don't think it could be any harder to get started with than the mfc. even after i became an "expert" with the mfc, i still didn't write very clean code. there's just something about the mfc (maybe all the macros and no templates) that makes it hard to write nice code.

  5. Create() and exceptions by dfgdfgdfg · · Score: 1

    In Qt, objects are always open. There is not "Create()" function. What is when opening fails in the contsructor, does Qt use exceptions? If yes, then correct Qt code has to use "try {...}" on every creation of widgets. In other toolkits, "Create()" returns a BOOL, and you must use "if (Create()) {...}". I think the KDE developers admitted they didn't like exceptions. There's no problem in using exception, but if you write a Qt program, and derive classes from Qt classes, your classes will also throw exceptions in their constructor. Not everyone writes their code like that, and proting existing C++ apps may be difficult for that reason. The other way around, if a library uses "Create()", then wrapping around your own code which calls Create() in the constructor is not hard.

    --
    -- 1.e4 c6 2.d4 d5 3.Sc3 de4: 4.Se4: Sd7 5.Sg5 Sgf6 6.Ld3 e6 7.S1f3 h6 8.Se6:
    1. Re:Create() and exceptions by Curien · · Score: 2

      Ummm... no. Qt may or may not report errors via C++'s exception mechanism, I don't know. But insinuating that exceptions are the *only* way to report errors encountered during a ctor is patently false. For a counter-example, one need look no further than the standard IOStream library:

      #include <iostream>
      #include <fstream>
      #include <cstdlib>

      int main() {
      std::ifstream file("file.txt");
      if(!file) { // look ma, no try block!
      std::cerr << "file.txt could not be opened for reading.\n";
      return EXIT_FAILURE;
      }
      return 0;
      }

      --
      It's always a long day... 86400 doesn't fit into a short.
    2. Re:Create() and exceptions by Anonymous Coward · · Score: 0

      I'm pretty sure he was refering to the creation of Qt objects only.

    3. Re:Create() and exceptions by Thatman311 · · Score: 1

      So what happens if the ifstream can't be created on the stack because file.txt is too large? oh...ifstream allocates memory in its constructor to handle that problem. What happens if you are in a low memory condition and the memory can't be allocated?

      Exceptions aren't the only way to report errors. Return values from a function is another way. Also using a global error object is another. Problem is in your example the program has no way to know why ifstream couldn't be created. Also ifstream has no way to communicate that to the program except through exceptions. That is because it uses its constructor to do it initialization. Since there are no exception handlers wrapping the creation of ifstream an exception would stop all execution of this program and the OS would provide a nice little popup to the user that makes no sense (on windows at least).

      So next time...think about the code you are writting and why functions like Create() exist.

      --
      Silly Rabbit...Sig's are for kids.
    4. Re:Create() and exceptions by Curien · · Score: 2

      If ::new fails then it will throw, sure. But the object is free to catch std::bad_alloc inside the ctor and transpose it onto some other error-reporting schema. Just because something *in* the ctor throws, doesn't mean that the ctor has to propogate the exception.

      As far as ifstream is concerned, you can't tell *why* the file couldn't be opened because ifstream is abstracted that way. You could easily have some sort of "error state" (similar to badbit, eofbit, and failbit) which can be reported to the client only when the client asks for it. Simplest way I can think of to do that is with a get_last_error() member function that simply returns the error code of the last operation the object performed.

      Sure, exceptions can be helpful in RAII, but they are by no means required by it. To assume so is not only incorrect, it diminishes C++'s lack of paradigm bias.

      The only time I can think of when you're *forced* to propogate exceptions is when you have a polymorphic class whose base class's ctor throws. But then, you made a design decision to inherit from a class that throws.

      --
      It's always a long day... 86400 doesn't fit into a short.
    5. Re:Create() and exceptions by Anonymous+Brave+Guy · · Score: 2
      The only time I can think of when you're *forced* to propogate exceptions is when you have a polymorphic class whose base class's ctor throws.

      Any subobject (base class or data member) that throws during construction will result in the object itself failing with an exception. You can wrap the c-tor's initialiser list in a function try-block if your compiler supports it, but that only allows you to change the type of exception thrown, not the fact that some exception is thrown. If you think about it, that's the only model that makes sense, and it's also very clean and tidy.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    6. Re:Create() and exceptions by Curien · · Score: 2

      Yes, that's the only way the object model can make sense *if you're containing actual objects*. You can easily get around that by changing the contained object(s) to a contained pointer to object. Same goes for private inheritance: change it to a contained pointer to object. If all your after is interface inheritance w/o polymorphism, just use a contained pointer plus forwarding functions. Like I said before, the only time you're *forced* to propogate exceptions from a ctor is when a polymorphic base class's ctor throws.

      --
      It's always a long day... 86400 doesn't fit into a short.
    7. Re:Create() and exceptions by Anonymous+Brave+Guy · · Score: 2

      I think what you're trying to say is that if you don't want to allow a constructor to fail, you can change your design so that you can trap the exception that would be thrown by a base class or data member under normal circumstances. That's not what you actually said, though.

      Of course, whether you want to have a design that carefully works around a system that's there for your own good is another question. Most of the time I've seen designs that went out of their way to ignore exceptions in a system that used them, the design was broken. Two-stage construction with Create() and Destroy() methods is a Bad Thing(TM) under almost all circumstances, and is responsible for more programming bugs in C++ than almost anything else I've come across (apart from naff use of pointers and arrays when smart pointers and container classes were the right tools for the job, of course).

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    8. Re:Create() and exceptions by Curien · · Score: 2

      Sort of, but not quite. It's not a *design* change, it's an *implementation* change. Big difference. My only exception (polymorphic base class ctor throws) is the only situation where avoiding a throw in the ctor would actually require a design change.

      I think we're pretty much in agreement, though. Don't know why anyone would go through all that trouble just to avoid a try block anyway.

      --
      It's always a long day... 86400 doesn't fit into a short.
    9. Re:Create() and exceptions by Anonymous+Brave+Guy · · Score: 2

      OK, fair point, your change is implementation rather than design. And yes, we agree; exceptions and try-blocks are there for a reason, and it's usually easier to use them as they were intended than to fight against them.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  6. wxWindows comparison... by eyepeepackets · · Score: 2

    ...would be nice too since wxWindows is growing in popularity. Any one have experience using both wxWindows and MFC? Maybe a comparison between wxWindows and QT would be useful and interesting as well..

    Perhaps the most useful of all would be a comprehensive somparison of all the various toolkits/libraries.

    --
    Everything in the Universe sucks: It's the law!
    1. Re:wxWindows comparison... by noselasd · · Score: 1

      ohh. Someone a while ago told me about wxWindows. So ahead I went an tried to make my first small test app. During that hour I decided that wxWindows is crap. While abit better than MFC, theres much of the same. And i truly dislikes MFC.

    2. Re:wxWindows comparison... by Anonymous Coward · · Score: 0

      You don't belong here. This is an article to slag Micro$oft. Please bring up your whatever-Windows toolkit when it's more appropriate and will allow us to slag Microsoft with it.

      Thank you.

    3. Re:wxWindows comparison... by neroz · · Score: 1

      To the AC who didn't bother to look at wxWindows, it is cross platform.

  7. "MFC programming", what the heck? by noselasd · · Score: 2, Insightful

    I've been doing lots of Qt, GTK and Java programming, a few months ago I needed to start hacking on a MFC project. I tell you, never ever again. I'm now having a cronic headace, thanks alot MS. And what is it with those API's on Windows, do they have to typedef _everything_ for every different occasions, I'm sure I encountered 20 different typedef s for "unsigned int" just browsing through some MSDN pages. Not to mention the joy of unwinding a structure so you can get to business. Theres a structuer with a structure, member, with a member,with... And they each have members of type unsigned int, WORD, p_WORD, uint32. If somone know how to make apis and code even more unreadable I'm sure there is an open job somewhere near Redmond.

    1. Re:"MFC programming", what the heck? by dthable · · Score: 2, Insightful

      And what is it with those API's on Windows, do they have to typedef _everything_ for every different occasions...

      Could it be to support more than a single machine architecture? Windows NT used to run on Alpha boxes and now, the move to IA-64 means that an unsigned int is going to change size. They typedef everything to ensure that no matter what platform they move to, the framework doesn't require major changes.

    2. Re:"MFC programming", what the heck? by noselasd · · Score: 1

      Strange I dont encounter this that much in the posix world, which runs everywhere, atleast not within the sae library/API. I rather suspect their mess comes from the fact that they have to keep binary compability. And that MFC mostly a wrapper a round the Win32 API, to which they change their internals with virtually every build(or so it seems). Its though a pretty bad excuse, the thing is to do it right from the beginning.

    3. Re:"MFC programming", what the heck? by RocketJeff · · Score: 2

      Actually, a lot of the mess in MFC is not due to the changing Win32 API, but left over from the switch from 16-bit Windows (i.e. 3.11) to 32-bit Windows (95/NT & later).

      It's this backwards compatablity that hampered MFC through too many years. Unfortunately, the only way to get rid of it now would be to start over (which will never happen now that .net is MS's future).

    4. Re:"MFC programming", what the heck? by dthable · · Score: 1

      I actually see the WinForms aspect of .Net as a starting over point for programmers on the Windows platform. Microsoft has known for a while that the old API was showing it's age. .Net is less about developing a new technology, but refactoring the existing technologies and products for stability, security, performance, and all other sorts of good stuff.

    5. Re:"MFC programming", what the heck? by RupW · · Score: 1

      And what is it with those API's on Windows, do they have to typedef _everything_ for every different occasions...

      Could it be to support more than a single machine architecture?

      I think also to support both 16-bit Windows and Win32 together, although that's more relevant for the base windows headers than MFC.

      I don't mind a little opacity on the OS interface. And you often gain meaningful type names too.

      (There are a number of examples on Unix, too: e.g. uid_t, pthread_t, etc. But certainly not to the same degree.)

    6. Re:"MFC programming", what the heck? by Ben+Hutchings · · Score: 2

      uid_t and pthread_t are useful - they are the types used to hold a user ID or a thread ID. They can and do vary between implementations. Likewise types such as uint32_t and int_least16_t (from the C99 standard) are useful.

      The WORD and DWORD types do not provide an abstraction and do not obviously have any particular numeric properties. I happen to know that the names WORD and DWORD come from x86 assembler and are signed 16-bit and 32-bit quantities, but a portable API should be using names like INT16 and INT32 for such types instead. Some of the other types are more reasonable, but the API is not that consistent.

      All the pointer-to typedefs should be got rid of; they may have been somewhat useful under Win16 but are no longer relevant. UINT and ULONG are likewise fairly pointless.

      In a few places the Win32 API could do with more use of typedefs, for example for process and thread IDs (currently DWORDs).

  8. Review? by miklernout · · Score: 1

    This is a bit of a strange review:

    I always thought that comparisons had to be done with some kind of objectivity, if only for the purpose of decency... Apparantly this is not the case: MFC was produced by hordes of rabid monkees while God himself came down and Created Qt.
    Even not a C/C++ developer myself, I don't see a lot of proof / illustration to the MFC side and way too much positive adjectives on the Qt side: "genious", "excellent", ...

    The best one was probably:
    "One of the stated goal of Trolltech is "The product and the documentation should be so good that no support is needed".
    QED...
    Qué?

    --
    ----
    --
    [insert witty one-liner here for your own pleasure]
  9. Good conclusion, poor article by uradu · · Score: 5, Insightful

    While I wholehartedly agree with the conclusion, I must say that the article is a mess and feels like it was written by a 16-year old. It's barely comparative, sticking to the format that feature X is messy in MFC and much easier in Qt, and here's an example of just how easy. He doesn't give any MFC code examples, mainly limiting himself to explaining the horrors of Unicode and resources. An objective reader could hardly take this for a serious comparison of the two frameworks.

    Besides, it's really comparing apples and oranges. Anyone who's used the MFC at all knows that it's hardly OO. A much fairer comparison would be that of Qt to Borland's VCL. In many respects they're very, very similar, but it seems that the nod of more consistent OO design would go to the VCL. I base this mainly on the event-handling semantics of both toolkits. While Qt falls back to straight C (or possibly even a macro? shudder!) for connecting an event handler to a component, the VCL stays faithfully OO, implementing event handlers as method pointers (exposed as properties) on components.

    Continuing the example used in the article, Qt reads:

    connect( button, SIGNAL( clicked() ), SLOT( action() ) );

    while the VCL would read:

    button.OnClick = action;

    Anyway, as I said, while I support the conclusion of the article, based on its lack of maturity I wouldn't use it to try to convert existing MFC programmers.

    1. Re:Good conclusion, poor article by Anonymous Coward · · Score: 0

      yeah. I was wondering if trolltech was paying him for the "comparison". But I don't think they'd want to be associated with something so blatently inaccurate and unprofessional

    2. Re:Good conclusion, poor article by oever · · Score: 1

      While Qt falls back to straight C (or possibly even a macro? shudder!) for connecting an event handler to a component, the VCL stays faithfully OO, implementing event handlers as method pointers (exposed as properties) on components.

      There are some comments in the Qt documentation why the approach isn't always strictly OO.

      while the VCL would read:
      button.OnClick = action;


      Just curious: if button.OnClick and action are both method pointers, how can you have more than one action in response to a click?

      --
      DNA is the ultimate spaghetti code.
    3. Re:Good conclusion, poor article by uradu · · Score: 2

      > Just curious: if button.OnClick and action are both method pointers,
      > how can you have more than one action in response to a click?

      Well, you're right, you couldn't in the current implementation. The simple method pointers on the components would have to be replaced by some sort of object with Add and Remove methods of its own, which would then insert the event handler assigned into some notification data structure. Basically you'd be "OO-fying" what connect() does in Qt. It would likely have more overhead than the Qt approach, so it's a matter of what you value more, OO-ness or performance.

    4. Re:Good conclusion, poor article by Anonymous Coward · · Score: 0

      [ Philippe Fremy ]

      > He doesn't give any MFC code examples

      The problem it that it is hard to isolate a MFC example. You usually use the resource editor, so you don't actually build your buttons. And you use the editor to assign an action for button clicks. So you rely on events. Unfortunately Some [events] are redundant, some are not emitted, some are not documented. You end up trying one after the other because you don't know which one does what.

      With Qt, you may choose to use Qt designer but you are not forced to. It is obvious which signal and which slot you have to use.

      > An objective reader could hardly take this for a serious comparison of the two frameworks.

      Okay, this was not clear in the article but I say it: this is a report of our experience of building a product with MFC and with Qt. Not an analysis of the strengths and weaknesses of MFC and Qt. So this is highly subjective, but it reflects our experience.

      > A much fairer comparison would be that of Qt
      > to Borland's VCL.

      I encourage you to write it, that would be interesting. But my article is about Qt and MFC, not about VCL. And I don't see your point with fairness.

    5. Re:Good conclusion, poor article by BdosError · · Score: 2
      Well, you're right, you couldn't in the current implementation. The simple method pointers on the components would have to be replaced by some sort of object with Add and Remove methods of its own, which would then insert the event handler assigned into some notification data structure
      Actually, you could (and they might) handle this by overloading the assignment operator (assuming VCL is in C++, I'm not familiar with it) so that it did in fact do an Add(). There are issues with this, and it would need to be fleshed out (and you'd have to figure out how to make a semantically similar Remove(), which is problematic), but it's possible. Mostly I'm arguing for pedantry's sake.
      --
      Complexity is Easy. Simplicity is Hard.
    6. Re:Good conclusion, poor article by uradu · · Score: 2

      > The problem it that it is hard to isolate a MFC example.

      You've got a point, but you can still give the steps required to hook up a buttong to an event handler. Doing that would have actually strengthened the argument considerably, precisely because VS is such a mess.

      > I encourage you to write it, that would be interesting.

      Hey, it's easier to criticise than to create, so I'll restrict myself to that, thank you very much.

      > And I don't see your point with fairness.

      I meant that as in Qt towering head and sholders above the MFC in the criteria chosen, finding faults in the MFC was almost like taking candy from kids. I was just thinking about comparing Qt to a similarly OO framework.

    7. Re:Good conclusion, poor article by TulioSerpio · · Score: 1

      Actually the CLX library, used in the lasts Delphi and Kylix and CBuilder versions, (very similar to the VCL) is based in the Qt library. If you code for CLX in Delphi you are coding for windows AND Linux, thanks to Qt.
      You can't link many events handlers to a single event, but you can link a single handle to many events, if they have the same event type.
      When do you need to link an event to many handles? please give an example.

      --

      I'm from Argentina: Tango, Asado, Mate, Gaucho, Maradona, YPF

    8. Re:Good conclusion, poor article by uradu · · Score: 2

      > Actually, you could (and they might) handle this by overloading the
      > assignment operator (assuming VCL is in C++ [..])

      It isn't, though, it's in Object Pascal, which doesn't support operator overloading. You could still do it by changing the event handler method pointers to pointers to a singleton object that did the same work as connect() via an Add() method, without incurring any memory overhead per event handler per component.

      > you'd have to figure out how to make a semantically similar Remove()

      Well, in C++ you could simply overload the following operators:

      += : add this event handler
      -= : remove this event handler
      = : clear event handlers, then add this one

      I believe that's the mechanism they're using in C# with delegates (except maybe for the third one).

    9. Re:Good conclusion, poor article by uradu · · Score: 2

      > Actually the CLX library [...] is based in the Qt library.

      True, but that should be thought of as an implementation detail. You code to the CLX, not to Qt. Theoretically Borland could in the future rewrite the CLX on each platform straight to the metal without using Qt, and your programs should still compile. In practice they probably did surface some Qt here and there, maybe data structures taken as parameters of some methods, same as they did with win32 in the VCL.

    10. Re:Good conclusion, poor article by Bytenik · · Score: 1

      You could make a MultiAction class that you can Add and Remove any number of actions to/from.

      Granted this would be nicer integrated directly into the framework, but you can still do it yourself if necessary.

      --

      "Scientists prove we were never here."
      -- Devo

    11. Re:Good conclusion, poor article by Lord+Omlette · · Score: 2
      Anyway, as I said, while I support the conclusion of the article, based on its lack of maturity I wouldn't use it to try to convert existing MFC programmers.
      As an MFC programmer who has discovered the glory of WinForms, lemme tell you: if we're not getting paid for it, we don't need any convincing to move from MFC to greener pastures.
      --
      [o]_O
    12. Re:Good conclusion, poor article by sd4l · · Score: 1

      > A much fairer comparison would be that of Qt to
      > Borland's VCL

      I would actually be interested in seeing a good comparison of Qt vs GTK vs VCL. I used to be a VCL programmer (C++Builder and Delphi) so would be interested in seeing how they compare.

      Cheers,

      sd4l

      --
      -- Andy Jeffries Scramdisk for Linux (Change the orgy to org to reply)
  10. Advocacy, we never knew thee. by Zapman · · Score: 3, Insightful

    This guy doesn't seem to understand much of what he's talking about.

    The most glaring clue is this:

    For example, to swap two variables, the author used the non commented following line:

    a ^= b ^= a ^= b;

    This is a cool hack which does not belong to a professional product.

    If you don't recognize this, you probably need to go back to school. It's fast, and it doesn't require a temp variable.

    Any time you look at low level libraries, you're going to see things like this. They NEED speed. They NEED low memory impact. These things are going to get called in tight loops with a million iterations. Look at QT's code, and you'll see the same thing.

    Also telling is the fact that he has nothing positive to say about MFC. I've run across some VERY talented developers, and while I haven't heard them singing MFC's praises, they do have some nice things to say. Advocacy really needs to show balance. Acknowledging MFC's strong points is important.

    When he's talking about an add on library called 'codejack', he mentions that tab views are impossible in MFC, yet codejack provides it. Apparently it is NOT impossible in MFC then. It probably isn't a prebuilt widget for the developer to use (which is unfortunate, I'll admit)

    QT is a good library, I have no doubt. But please learn how to find good things in other libraries. It will only make your code better. It will only make your advocacy better.

    --
    Zapman
    1. Re:Advocacy, we never knew thee. by Curien · · Score: 1

      Nope, that's *not* the correct way to code that, even in a high-performance section of code. The correct way is:

      using std::swap;
      swap(a, b);

      If you want to have a nifty hack, then provide a specialization for swap. And don't bother complaining about function-call overhead. If it's really a one-line hack like above, any half-decent compiler will optimize the call away. And if the compiler doesn't, then there's no point in using it to write optimized code in the first place.

      Anyone who can figure out why I used a using-declaration instead of explicitly specifying the namespace (ie: "std::swap(a, b);") gets a cookie.

      --
      It's always a long day... 86400 doesn't fit into a short.
    2. Re:Advocacy, we never knew thee. by uradu · · Score: 2

      > But please learn how to find good things in other libraries.

      That's hardly a sign of a well-balanced comparison. You can completely blast a product and still have a fair review--IF the product really sucks in the criteria chosen, and you can fully document why and how it sucks. Unfortunately this author didn't do that, blasting the MFC on generalities without giving specific code examples, which OTOH he was more than eager to provide for Qt. Within the criteria used--OO design and ease of use--the MFC would pitifully fail against Qt, but you wouldn't know it reading this article.

    3. Re:Advocacy, we never knew thee. by SilentStrike · · Score: 1

      "Anyone who can figure out why I used a using-declaration instead of explicitly specifying the namespace (ie: "std::swap(a, b);") gets a cookie." Or probably should get beaten for spending way too much time reading about an overly complex langauge. My guess is that A. overloading std::swap may be illegal B. swap without the namespace involves an arguement dependant ("Koenig") lookup, so that, if an optimized version of the swap between a and b exists in the namespace that encloses either of them, it will be choosen instead std::swap.

    4. Re:Advocacy, we never knew thee. by Anonymous Coward · · Score: 1, Informative

      [ Philippe Fremy speaking ]

      > It's fast, and it doesn't require a temp variable.

      Yeah, great. But I better have them fix their bugs, their crashes and their memory leaks than spare a temp variable. Besides, the code appears in a function that is not optimised at all.

      You are focusing on the one the example I gave. Does a 500 lines method looks acceptable to you ? Do you think this is also to spare the cost of function calls that they use so many of them ? Or that having private members declared public is good ?

      Their code is crap. It is good in the sense that it makes it a lot easier to build powerful GUI applications and that it works most of the time. But it is crap when you read it.

      > Look at QT's code, and you'll see the same thing.
      The big difference is that in three years of Qt programming, I had just to look once at Qt's code to be sure I understood the doc properly. With Codejock, there are stuff that are simply not documented, and stuff that you can not use if you do not look at the source code.

      > Acknowledging MFC's strong points is important.

      I am sorry, I haven't ran into them, except for the fact that it comes free with Visual Studio. But I'll add any if you have one to propose.

      I recognised we are not good writers. And we made one mistake in this article. We did not point out that we did in no way pretend to be objective. We were just sharing our experience of Qt programming and MFC programming. I'll add a disclaimer in that direction tonight.

    5. Re:Advocacy, we never knew thee. by Anonymous Coward · · Score: 2, Insightful
      a ^= b ^= a ^= b;

      This is a cool hack which does not belong to a professional product.
      If you don't recognize this, you probably need to go back to school. It's fast, and it doesn't require a temp variable.
      Uh. I hope you don't really think that. Otherwise, I think it's time for you to go back to school. And no, nothing like that is to be found in Qt. Because its completely wrong, unpredictable, and best of all, the result is undefined. Have you ever read the C FAQ? Or comp.lang.c.moderated? No? I didn't think so.

    6. Re:Advocacy, we never knew thee. by pong · · Score: 2
      Also telling is the fact that he has nothing positive to say about MFC. I've run across some VERY talented developers, and while I haven't heard them singing MFC's praises, they do have some nice things to say. Advocacy really needs to show balance. Acknowledging MFC's strong points is important.
      Actually I totally agree with you - the author of the article is completely biased. None-the-less it is extremely interesting to note the number of applications Microsoft itself has released that uses MFC.

      According to Don Box (COM guy, now works at Microsoft) the number is 0 - zero! nil! (He mentioned it in his keynote address at Microsoft Developer Days 2001 in Copenhagen)

      Food for thought!
    7. Re:Advocacy, we never knew thee. by swillden · · Score: 3, Informative

      a ^= b ^= a ^= b;

      If you don't recognize this, you probably need to go back to school. It's fast, and it doesn't require a temp variable.

      Bull.

      It's an overly clever hack that doesn't belong in a professional product. Why? Four reasons:

      1. Speed: It is not fast. It's far slower than the typical:
        c=a;
        a=b;
        b=c;
        Don't believe me? Grab a compiler, compile to assembler and check it out.
      2. Storage: It requires exactly the same amount of storage, since the temp will always be in a register anyway (and the same register is required to store the result of computing a^b). Again, if you don't believe me, compile both to assembler and check 'em out.
      3. Correctness: The line as written is *wrong*. It may work with some compilers, but the C and C++ standards both say that the result of the line is *undefined*. Why? You can't apply multiple operations including assignments to the same variables without an intervening sequence point (which, usually, means a semi-colon). The following is correct, although still slower than using an explicit temp:
        a ^= b;
        b ^= a;
        a ^= b;
      4. Clarity: It is not immediately intuitive to anyone. Anyone who has seen the "cool hack" somewhere else will probably recognize it, true, but the use of a temp, or, even better, the use of std::swap() are guaranteed to be understandable at a glance. And there is no real, educational reason why anyone *should* have seen this hack, since it's really not useful.

      The "comparison" article is poor at best, but in this aspect it is 100% correct. XOR-swapping is a cool hack but has no redeeming values other than its coolness, and cleverness for its own sake has no place in professional code.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    8. Re:Advocacy, we never knew thee. by abdulla · · Score: 1

      There are benchmarks showing that using a temporary variable is a ton faster. Should I post a url?

    9. Re:Advocacy, we never knew thee. by spongman · · Score: 2

      Don is wrong. The IDEs for Visual C++ (versions 2 through 6) were all MFC apps. In fact, the original creators of MFC were the ones that wrote the 'new' shell for VC2.0 (the one with the dockable windows). The Doc/View architecture of MFC was derived from the framework for an unreleased product codenamed Sequioa that was destined to become VC2.0, but which was canned in '92 to free resources for shipping VC1.0. I believe PictureIt! was also an MFC app, as is WordPad.

    10. Re:Advocacy, we never knew thee. by CoolVibe · · Score: 2

      I did some tests:

      sh-2.05a$ ./swapbench
      xorswapping 10 secs: 6999572 iterations
      tmpswapping 10 secs: 7785816 iterations


      The code for this is here. I know it's not really a representative benchmark, but it does show the point somewhat. And yes, using a temp variable is hella faster.

    11. Re:Advocacy, we never knew thee. by Ben+Hutchings · · Score: 2

      Microsoft used MFC quite a lot, mostly in their developer products (AFAICS). If you go to the Microsoft DLL information pages and enter the filename of a DLL you'll get a list of released versions; then by selecting "More Information" you can get a list of products that included that version. For MFC, try filenames mfc30.dll, mfc40.dll and mfc42.dll. Many versions of Windows include MFC, perhaps to support programs like WordPad. Various other products include an updated version of one of these DLLs.

    12. Re:Advocacy, we never knew thee. by sir99 · · Score: 2
      Please pardon my sloppy HTML.

      1. Well, that depends on your compiler. Testing with gcc 3.1 with -O3, I found that gcc has a special optimization for the standard swap construct (I also tried using the Intel compiler, but it produced nasty code that I had no desire to dissect). It assembles to something like this, where the bold variables are registers, and the others live in memory:
        ax = a; //read
        bx = b; //read
        a = bx; //write
        b = ax; //write

        This code has 2 memory reads and 2 writes, whereas the xor construct assembles to a monstrosity with far more memory access than necessary. So yes, on gcc the normal swap is much faster, but a well-assembled xor construct, with just the 4 required memory accesses, would probably only be a few cycles slower, rather than a few hundred. The memory accesses contribute the great bulk of time consumed.
      2. You're not quite right here. Most assembly operations are like operation= in C. There is no temporary register used to store the result of a^b, because the operation is done in hardware as a^=b. You're right in this case that they both use the same amount of storage, but that's only because gcc recognized a common construct and optimized it.
      3. No comment.
      4. It's almost intuitive to people who have learned assembly, but probably not to anyone else. In fact, in light of gcc's particular quirks, hand-written assembly, where the variables are already in registers, is probably the only place xor-swapping should be used. It may be an advantage there, because it only uses two registers instead of three for the normal swap, and on x86, registers are at a premium.
      --
      The ocean parts and the meteors come down
      Laid out in amber, baby.
    13. Re:Advocacy, we never knew thee. by swillden · · Score: 2
      1. That's precisely the code gcc should emit, and that's what every decent C compiler I've used in the last 12 years has emitted. I don't think it's so much that they recognize the swap construct as the optimizer sees a simple and obvious optimization. Try writing the unoptimized code and look at it as though you had no idea what the original C code said: you'll find the optimization is still obvious.
      2. In fact, I was wrong, for the obscure reason that I had forgotten the x86 has no memory to memory variant of mov, which means that the standard approach does require one more register than the XOR version. Here, to make confusion impossible, consider the following (comments show timings for 386/486 processors -- sorry, only manuals I have handy).

        Standard version

        mov ax, [a] ; 4/1
        mov bx, [b] ; 4/1
        mov [a], bx ; 2/1
        mov [b], ax ; 2/1

        Total: 386: 12 cycles, 486: 4 cycles.

        XOR version

        mov ax, [a] ; 4/1
        mov bx, [b] ; 4/1
        xor ax, [b] ; 2/1
        xor [b], ax ; 6/3
        xor ax, [b] ; 2/1
        mov [a], ax; 2/1

        Total: 386: 20 cycles, 486: 8 cycles

        The XOR approach does have the advantage that it requires only one register, but it consumes so many more cycles that it would still be faster to add a pair of mov instructions to save and restore the contents of bx and then use the standard approach. This would bring the total timings of the standard approach up to 18/6.

      3. This was actually my most important point. A compiler is free (and not unlikely) to emit code that is uses the original values of a and b in every step of the process, which will probably be boiled down by the optimizer to:
        mov ax, [b]
        xor [a], ax

        Now, of course that would certainly be *efficient*....

      4. You almost make a good point here. If a and b are already in ax and bx, respectively, then the XOR swap can be done without involving another register.
        mov cx, ax ; 2/1
        mov ax, bx ; 2/1
        mov bx, cx ; 2/1
        vs.
        xor ax, bx ; 2/1
        xor bx, ax ; 2/1
        xor ax, bx ; 2/1

        So, identical performance (on these processors) but one less register. Here, the XOR swap is a win. It would be a win even if it took a few more clock cycles.

        Now for the explanation of the "almost": Swapping the contents of two general-purpose registers is completely stupid. Instead, the compiler should "mentally relabel" the two registers and go on about its business. Now, some x86 registers all do have special meanings with respect to some of the higher-level instructions, but swapping values around to prepare for execution of, e.g. a REP instruction is something that the C programmer should never even dream of being concerned about.

      I see no realistic situation on any platform I'm familiar with where XOR swapping is a performance win over standard swapping. That's not to say it isn't a win somewhere on some platform, but choosing to write C code that XOR-swaps is a bad idea, because most of the time you won't end up with a better result and you will probably confuse the poor bastard who has to maintain your code later.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    14. Re:Advocacy, we never knew thee. by sir99 · · Score: 1
      Now for the explanation of the "almost": Swapping the contents of two general-purpose registers is completely stupid.
      Ack. That's what I get for getting caught up in defending a neat hack; I overlooked the fact that the only useful situation I could think of wasn't sane. However, in a vain attempt to regain my dignity, I'll mention that x86 "general-purpose" registers aren't completely general purpose. You might want to exchange esi or edi with other registers, for use with the REP instructions you mentioned.
      --
      The ocean parts and the meteors come down
      Laid out in amber, baby.
    15. Re:Advocacy, we never knew thee. by swillden · · Score: 2
      Been There, Done That ;-)

      And, yeah, I know the x86 registers aren't completely general purpose, which is why I mentioned the REP instruction. I do agree that the cool hack is occasionally useful for assembler programmers who need to swap a pair of regs to set up some other instruction but don't want to use another register.

      I, myself, was never clever enough to use it that way, so I learned something here, too. Not that I expect to write much assembler these days; compilers are too good and processors, non-embedded processors at least, are too fast and too danged complicated for hand-optimized assembler to be cost-effective anymore... more's the pity, that stuff is fun.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
  11. MSDN by Screaming+Lunatic · · Score: 2

    That is one thing i have to disagree with the article. MSDN is quite good. And if you are using MFC, then you are using VC++. That means help is usually just an F1 click away.

    1. Re:MSDN by Anonymous Coward · · Score: 0

      Yes, I click F1 and I get hundred pages. Only one of them is relevant to the thing I am looking for. 90% of them are for another language. Why the hell do they show up ?

    2. Re:MSDN by Dalroth · · Score: 2

      No way, MSDN is terrible. All the information is there (if you can find it), but it's highly scatterbrained and disorganized. Half of the usefull information is locked up in the Knowledge base which is just a listing of sequential articles with no organization to it at all (you have to SEARCH for everything).

      If you compare the API defintions of one API (say ADO) to the API definitions of another (say RegExps) the API documentation is often in COMPLETELY different formats, and we won't even talk about where some of those API docs are located.

      The API documentations frequently don't explain what parameters are supposed to (or allowed to) contain, and even if they do their frequently listed on a seperate page without any explanation of the meanings for the various values.

      Oh, and good, standardised documentation about those COM/COM+ error codes located in a single and easily accessible location? Forget.

      I hate to rant here, but I've been dealing with MSDN's limitations for well over 6 years now and it's hardly better now than it was 6 years ago.

      In all honesty, I can find the solution to my problem 10x faster by going straight to groups.google.com. I find information in the MSDN archive quicker from groups.google.com than I ever do searching for it directly.

      SUN's Java documentation is an example of how things should be documented. It's not perfect, but it's 1000x better than what MSDN offers.

    3. Re:MSDN by RupW · · Score: 1

      All the information is there (if you can find it), but it's highly scatterbrained and disorganized.

      The index and search are usually good. You very rarely have to browse the contents for stuff.

      Grepping the windows API headerfiles is also very useful.

      The API documentations frequently don't explain what parameters are supposed to (or allowed to) contain, and even if they do their frequently listed on a seperate page without any explanation of the meanings for the various values.

      I've always found them good in that respect - often equal or better than Solaris man pages, say. (IMO, at first glance the QT docs don't look quite as good, but I will give them a better look.)

      Oh, and good, standardised documentation about those COM/COM+ error codes located in a single and easily accessible location? Forget.

      You can get most of them from winerror.h (with some description). Alternatively, there's always the error lookup util installed with Visual Studio.

  12. Development tools? by allanj · · Score: 4, Insightful

    As others have mentioned, the article is really badly written. I cannot comment on the merits of Qt, since I've done practically nothing with it. But I've done my fair share of MFC, and it's quite ugly - I find it hard to believe that *anything* solving a comparable problem can be much worse.
    But my main point is this: When dealing with stuff like MFC you need to factor in the quite helpful development tools that the Visual Studio suite consists of. I have yet to see something of that quality from anyone else (except possibly Borland), and so far I've found only KDevelop to be reasonably useful. The MFC library (I flatly refuse to call it an object model) is ugly, but to some extent this is ameliorated by the IDE. I *know* this is not the way it should be done, but it's there and it DOES help...

    --
    Black holes are where God divided by zero
  13. You go back to school by Anonymous Coward · · Score: 0
  14. TEST by Anonymous Coward · · Score: -1, Offtopic
      • WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
        Q
        W
        E
        R
        T
        Y
        U
        I
        O
        P
        A
        S
        D
        F
        G
        H
        J
        K
        L
        Z
        X
        C
        V
        B
        N
        M
        Q
        W
        E
        R
        T
        Y
        U
        I
        O
        P
        A
        S
        D
        F
        G
        H
        J
        K
        L
        Z
        X
        C
        V
        B
        N
        M
        F
        U
        C
        K
        !
        You heard me. I was going through security at Fort Lauderdale airport, and this guy was really scrutinizing me. Fine, I had no problem. Until he reached down my pants. He said it was because of my belt buckle. The problem is, the security screeners barely speak English. For people who do this all day, they are pretty bad at giving clear instructions. He mumbled something, and I thought he was telling me to sit down. So I sat down. Then he said "no no no, stand up." He went over me with the wand, and my belt buckle set it off. Then he asked me to undo my belt, and he stuck his hand down my pants! So I said, "What the hell are you doing?" He didn't have an answer, he mumbled something. Fucking people responsible for our security should not be illiterate perverts. I think it's about time to dump the bar. I am sick and tired (and tired always follows sick). But that's a small thing in the end, I guess. Right now, I'm waiting to find out if I have to do the jury duty thing. I won't find out until 11:00 or so. Until then I can "entertain" you guys with my weekend. Bear with it. There's light at the end of the diary... So, Friday night felt like a complete clusterfuck. I was down a man (a family reunion in Abilene, poor guy) and training 2 new guys. It just felt like everything that could go wrong went wrong, but that wasn't the real topper to my weekend. Friday night, one of my Underlings (specifically Jigsaw, frequently referred to as Underling1) told one of the managers and told me that he would be calling in on Saturday and wouldn't be coming in. You see, Jigsaw asked me a couple of weeks ago to get Saturday off for a family thing. I couldn't give it to him because the other guy who was off asked first, gave me more then a month's warning and I could only spare one person. So Jigsaw just decided to "tell" me that he wasn't coming in. Specifically, he said that no job was worth disappointing his family. Noble sentiment that was going to piss me off. So Saturday night, I had one experienced person, two newbies and myself working. It was a little packed but manageable for the first couple of hours until "They" arrived. And by "They," I mean Vinny and Dimebag from Pantera. That's when the pooch got screwed. People started calling all their friends to come to the bar because Vinny and Dimebag were there. People started drinking because they were hanging and being bad asses with Pantera. Truth be told, I couldn't give a fuck about them, but when celebs show up, it's my job to take care of them. Being a man short made that job difficult, but doable. Being another man short made it next to impossible. But the real topper was that there was a fight in another part of the club and I didn't even find out about it until it was long over and done with. Turns out that one of my Underlings went to toss a guy, and the guy turned on him and none of us (Security) was there to back him up because we were spread so thin. So a couple of the bartenders came from behind, got the guy out, told him to go away, got swung at and chased him into the street to get him gone. I played no part in this at all because while all this was happening, I was at the door carding people. If Underling1 had been there, I wouldn't have been at the door. I would have been able to go where the trouble was. I was not happy at the end of Saturday night. So I took Underling1 off the schedule for a couple of days. Did I act hastily? Maybe I did, but I'm not going back on this decision. I could say some kind of thing about people being the fingers of a hand or the cogs of a machine, but all that's crap. What it comes down to is one of my people let me down. It wasn't even because he was sick or something. I know it was a family thing, but I have bent over backwards to accommodate him and his family. I figure just because I don't have a good relationship with my family doesn't mean I should begrudge him his. But I've done it far too many times. And he's just going to inform me that he's not coming in? Well, I can inform him that he's not coming in also. Truth be told, I should have fired his ass, but unfortunately, I need him because we're already short of people and he's going to fuck up and get fired eventually because he's done it before. The thing that really pisses me off is that his absence kept me from doing my job as well as I could. And that's why I should probably drop the bar. I can't do the job as well as I would like because I'm only working there two days a week and it's not worth the money or the risk to my person. That and I have a lot of trouble caring about some facets of the job, too. But I seem to have an overdeveloped sense of responsibility. I don't want to leave them in the lurch. I've already had people tell me that when I leave, they think things will go back to shit. I don't have the hubris to think that the entire place will fall apart without me, but I know that I do a lot there and they'll never get another person like me anytime soon even if the double what the position pays. I should be replaced and soon. I did get one uplifting thing this weekend. A friend of mine and his wife finally legally changed her son's last name to his (and her married) name. They finally gave him a middle name, too. And the named him after me. Aeren Marcellus Throgmorton. I was and am completely touched. That just kinda makes all the other stuff just not matter doesn't it? This is without a doubt the biggest honor of my life. Heck, this even beats when Bob asked me to be his Best Man. I rule. I really do. In this essay we shall explore an alternative to the use of vector algebra for representation of physical objects in the sciences. It is not the purpose of this essay to make converts of the readers. It is enough to demonstrate how geometric algebras can be used to do many of the same tasks as the vector algebras along with a few additional ones usually reserved for other mathematical tools. In a previous work, the topic of how we choose to represent physical objects in our theories was discussed. Three postulates were laid out defining the concepts of completeness, rendition, and identity. This work will focus mostly upon the second term by offering geometric algebra as an alternative to vector algebra and matrix algebra. A Brief History The concept of a geometric algebra can be traced back to 1797 to a Norwegian surveyor named C. Wessel who interpreted the unit imaginary number as a directed line segment perpendicular to the unit real number. Making the complex numbers geometric has proven to be quite fruitful in a number of fields In 1843, W.R. Hamilton created the algebra of quaternions as an extension of complex numbers with the intent to represent three-dimensional physical objects. Around the same time, H. Grassman invented exterior forms. His algebra would eventually be developed into differential geometry. Both of these tools are powerful, but Grassman's contribution is better known today. In 1878, W.K. Clifford generalized and reinterpreted the algebras of Hamilton and Grassman. Some will refer to one of the algebras as biquaternions, but in their general form they are named geometric algebras. Clifford's algebras restricted themselves to simpler definitions for multiplication and addition similar to Hamilton's approach but including Grassman's exterior product within the general product. These operations were defined that way in order to obtain geometric meaning. Clifford died of tuberculosis a year later. Clifford's results have been rediscovered a few times by more recent researchers. Sauter, Sommerfeld, and Eddington all noticed that Dirac's gamma matrices were generators of a four dimensional geometric algebra with a space-time metric. These are the gamma matrices from Dirac's first order relativistic theory for electrons. Several other authors have noted that classical electrodynamics can be easily written in the same geometric algebra generated by a suitably defined set of gamma matrices. In the early 1880's, J.W. Gibbs wrote about his vector algebra. Gibbs' algebra and his notational approach were a limited form of Grassman's ideas. The system was adopted by those developing the theory of electrodynamics at the time and won the battle for the approach taught to students. The vector algebra taught to students today largely derives from Gibbs' system, though the notation has been changed a little. Between 1891 and 1894, in the journal Nature, long letters defending various notions can be found between the proponents of both sides of the representational conflict. On one side were Gibbs, and O. Heaviside. P.G. Tait supported the other side. By this time, the main creators of the quaternionic approaches were long dead. The creators and proponents of the vector algebra were alive and well. The actual argument in the journal was a little lop-sided but it went on outside the print media for some time. Anyone interested in what a 19th century flame war looks like is encouraged to do a little digging in the library for volumes 43 through 46. Gibbs first letter was published April 2, 1891 and Tait's first response appeared four weeks later. Definitions To start, we offer one formal and one informal definition of a geometric algebra. The formal one has a few parts and is meant for those readers with the mathematical background to understand them. In the truest mathematical sense, this definition could be made more formal. This version will suffice for this work. The informal definition, however, is the one most likely to help build an intuitive understanding of how to use these algebras as tools. Formal Definition of a Geometric Algebra 1. Binary Operation A binary operation on a set is a rule that assigns to an ordered pair of elements of the set some other element of the set. 2. Group A group is a set together with a binary operation on that set such that the following holds true. * The binary operation is associative. (a.b).c = a.(b.c) * There is an identity element in the set relative to the operation. * For every element in the set, there is an inverse element such that the operation on both of them always produces the identity element. (An abelian group is one where the binary operation happens to be commutative. a.b = b.a) 3. Ring A ring is a set together with two binary operations (called + and *) on that set such that the following holds true. * The set and the + operation form an abelian group. * The other operation (*) is associative. * The * operation is distributive over + from the right or the left. a*(b+c)=a*b+a*c and (b+c)*a=b*a+c*a 4. Field A field is a commutative ring under * with a unity element under * where all elements except the + identity have * inverses in the ring. 5. Vector Space A vector space consists of an abelian group under an addition-like operation, a field, and an operation (x) between elements of the field and vector space where the following holds true. * (x) produces and element of the group. * (x) is associative * (x) is distributive in the field AND in the group * There is an identity element within the field for (x) 6. Algebra An algebra consists of a vector space together with a binary operation (.) on the elements of the group such that the following holds true. * (.) is associative with elements of the group * (.) is commutative with the scalar multiplication of the vector space. * (.) is distributive with respect to the + operation in the group on the right and left. (Generators of an algebra are a set of elements such that all possible products produce a basis for the associated vector space. Linear combinations of the basis elements cover all possible elements of the algebra.) 7. Geometric Algebra A geometric algebra is a type of algebra with a set of generators where the following holds true. * products of two different generators under (.) anticommute * products of two identical generators under (.) are defined (The generators of a geometric algebra are the elements to which geometric meaning is attached.) That is a formal enough definition along with the terms that provide the underpinning that makes the definition work. There are two multiplication-like operations, a single addition-like one, a set of elements that starts this all off, and some rules they must all obey regarding commutativity, associativity, distributivity, and a variety of types of operational identity elements and inverse elements. This cloud of formalism is important in the mathematical sense. For our purposes, however, it is more instructive to approach the tool informally and discover these definitions through usage. Remember the existence of these formal definitions, though. Some of the seemingly magical qualities of geometric algebras discussed later can be shown to be obvious by the fact that they are designed into the tools from the start. Informal Definition of a Geometric Algebra Start with a set of objects we choose to use to represent directed lines. We will call them vectors later, but for now they are generators. With these generators, we shall construct everything in our geometric algebra. Note the following. 1. The number of generators in our set defines the meaning of 'dimension.' 2. The field for our algebra will be assumed to be the Real numbers unless otherwise stated. 3. Experience the reader already has regarding the operations + and x from vector spaces will continue to apply here. The concept of 'linear combination' still works here too. 4. We shall define (.) by providing the multiplication table involving all generators and their products. 5. All elements found on the (.) multiplication table form a set that is sufficient to span the vector space found within the algebra. 6. With (.) we introduce the term 'algebraic combination' as an extension of linear combination and allow both (.) and (+) operations. A two dimensional example. Let's call our generators X and Y. We need to define a multiplication table for the (.) operation to be defined. Here it is written out. X . X = 1, X . Y = XY, Y . X = -XY, and Y . Y = 1 With this list, we have a two-dimensional algebra where 1, X, Y, and XY span the related vector space. Elements of the geometric algebra can be represented as linear combinations of the set that spans or as algebraic combinations of the generators. Here is an example. (Remember that x is the scalar multiplication with the field.) M = (A x 1) + (B x X) + (C x Y) + (D x XY) 1 is interpreted as a point. The field element 'A' changes its magnitude. X and Y are interpreted as directed line segments. (The vectors) Remember that a directed line is a one-dimensional object with a sense of forwards or backwards. XY is interpreted as a directed plane segment. (A bivector) A directed plane is a two-dimensional area with a sense of rotation clockwise or counterclockwise. A three dimension example. Let's call our generators X, Y and Z. The multiplication table for the operation is as follows. (Assume a.b = -b.a where a, b are any generators.) 1.X=X, 1.Y=Y, and 1.Z=Z X.X=1, Y.Y=1, and Z.Z=1 X.Y=XY, X.Z=XZ, and Y.Z=YZ XY.X=-Y, XY.Y=X, and XY.Z=XYZ XZ.X=-Z, XZ.Y=-XYZ, and XZ.Z=X YZ.X=XYZ, YZ.Y=-Y, and YZ.Z=Y XYZ.X=YZ, XYZ.Y=-XZ, and XYZ.Z=XY XY.XY=-1, XZ.XZ=-1, and YZ.YZ=-1 XY.XZ=-YZ, XY.YZ=XZ, and XZ.YZ=-XY Elements in this algebra can be written as follows. M = (A x 1) + (B x X) + (C x Y) + (D x Z) +(E x XY)+ (F x XZ)+ (G x YZ)+ (H x XYZ) XYZ is interpreted as a directed volume segment. (A trivector) A directed volume is a three-dimensional object with a sense of rotation (left-handed or right-handed) around a parallelepiped. (The limitations of HTML or the author's knowledge of HTML in K5 articles makes this table somewhat hard to read. Imagine a square table with the eight elements running across the top and down the left. Fill in the products like one was taught to do with multiplication tables involving real numbers to get the table described above.) Other examples are possible and worth considering. The reader is encouraged to think about how the multiplication tables would change in both examples if X.X = -1 instead of +1. Such a change makes one of the generators begin to behave like a time-like vector instead of a space-like vector. A later example will show a four-dimensional algebra where one of the generators has a negative square. Such an algebra begins to behave like a Minkowski space, though it is geometrically richer. If both X and Y, in our two-dimensional case, were changed to produce negative squares in the two dimensional example, we would reproduce the algebra of quaternions. Why learn another paradigm? A reasonable concern for anyone currently using vector algebras and not familiar with geometric algebras is whether this new approach to representing objects is worth learning. The answer to this concern comes in two forms. The first is that an alternate approach to the representation of objects uncovers some of the techniques we use in rendering those representations. The second comes from the fact that some of the elements of our geometric algebras do not have analogs in the vector algebras commonly used to represent physical objects. These unusual elements may be worth exploring in case they help uncover new mathematical structures that imitate unexplained experimental evidence. Geometric algebras permit the sum of objects of different geometric rank. What is a vector + plane? Readers familiar with vector algebras know that such an object simply can't be constructed without violation of the transformation rules that maintain the concept of identity. Geometric algebras lead to no such violations, so there is a difference. Representation Techniques The interpretations for object within a geometric algebra depend on their rank and on their position relative to one of the operations. This is very similar to how we do things in other mathematical tools. A simple example will be shown for real numbers and then expanded to cover a three dimensional, Euclidean geometric algebra. Consider the equation (2 times 3 is 6.) The binary operation is the familiar one of multiplication of real numbers. This same equation could be written as times(2, 3) is 6. Any programmer would recognize the operator and the operands as distinct. However, because the operands of a binary operation are ordered, we could also write the equation with a unary operation as double(3) is 6. If the first operand of the binary operation were held constant, the unary version would be equivalent and more efficient to boot. This example shows that the operand can also be considered as part of the operation. This ambiguity is the one that leads to two possible interpretations for the same thing. One version treats the object as an input while the second treats it as an operator. In a three dimensional Euclidean algebra, we have three generators named X, Y, and Z. From these we can create 5 other objects using the multiplication operation alone. The objects are {1, X, Y, Z, XY, XZ, YZ, and XYZ}. Their interpretations as operands are relatively simple. Each is a directed element of rank n where n is equal to the number of generators it takes to represent the object. 1. The object '1' is of rank zero and represents points with magnitude. It is not the real number we usually label with a '1' symbol. 2. X, Y, and Z are directed line segments similar to basis vectors. 3. XY, XZ, and YZ are directed plane segments 4. XYZ is a directed volume segment. Note that no matrices are necessary for these interpretations. Each of these eight objects and their related interpretations is as 'real' as any interpretation of the unit imaginary number. The interpretation of these eight objects as operands takes a bit more work. 1. The object '1' is a scaling operation. By itself, it scales other objects by unity. When it is scaled by a real number from the Field, it transfers that scaling to the operand. 2. The generators are reflection operators if the operation is done in a bilinear fashion. Consider a linear combination of the generators. V = a x X + b x Y + c x Z. If you multiply on both sides by X, the result is XVX = a x X - b x Y - c x Z. Notice that the parts of V that were perpendicular to X changed sign after the operation was done from both sides. 3. If the generators are reflection operators, then the bivectors must perform two reflections. It is possible to write two reflections about different lines as a single rotation, so the bivectors when operated in a bilinear fashion are rotation operators. 4. The last one, XYZ, is a parity operator. All three generators get reflected, but the affect cancels out on the bivectors. With these two types of interpretation, we can address physical situations. Consider a room full of warm air. We could represent the temperature at every location in the room with a function of scalars (1's) that are scaled to match our readings. We could represent the movement of air molecules with a function of vectors (linear combinations of generators). The size of each directed line is linked to the momentum of the molecule. We could represent the spinning of each molecule with a function of bivectors. The magnitude of each directed plane is linked to the angular momentum of the molecule. In a vector algebra, we would keep these functions separate in order to avoid violations of the transformation rules that define identity. In a geometric algebra, this distinction is not needed. No matrix representation of the generators and the other objects is needed for the geometric algebra version as long as we keep the multiplication table handy. The matrix form can also be avoided for the vector algebra version, though it is seldom done. Our freedom to add objects of different ranks in a geometric algebra leads to some unusual constructs one does not normally encounter if one sticks with vector algebras. Consider the following objects. M = 0.5 x ( 1 + X ) and N = Y ( 1 + X ) The object M has the curious property that when squared you get it back again. The object N has the curious property that when squared you get the additive identity named 'zero.' M is an example of a set of elements of the algebra referred to as idempotents while elements that behave like N are referred to as nilpotents. These constructs are not possible in vector algebras, so if there is anything that could support or demolish the usefulness of geometric algebras as a representational tool in physics theories, it will probably lie with these constructs. Examples An example or three will demonstrate just how similar geometric algebra can be to the current vector algebra. The rendering of objects in both systems is very close and easily confused. The difference all rests in how the reference frame is written when rendering real objects. Example 1 Imagine our room full of warm air again. Each molecule in the room is moving around at some velocity and, therefore, with some momentum. Imagine tagging each molecule with a directed line segment representing that momentum. With a little sleight of hand we could pretend your tags actually referred to a small volume of some continuous fluid and avoid the discrete nature of the air. This step isn't strictly necessary, but it does make writing a function for the momentum of the fluid easier. That function would appear as follows. Momentum density P (position) = sum [coefficient of P x a basis element] where the basis elements are the eight objects that can be generated from the basis vectors. Obviously, most of the coefficients will be chosen to be zero in order to ensure that P is a vector density. That works just fine. In a vector algebra we would write the same equation as follows. Momentum density P (position) = {Px, Py, Pz} where the coefficients are part of a 3-space vector. The reference frame to which those coefficients apply is implied in the equations and usually gets described somewhere nearby in the text explanation. Some people will start with an equation that looks like the first one but limit it to a sum over only the vector coefficients. Then, when a calculation must be performed, they switch to the matrix notation for vectors and proceed. These people are living halfway between the two systems and probably find some intuitive advantage to the geometric approach whether they know they do or not. Example 2 For another example, imagine a planet orbiting the sun. That planet is at a distance R and moves with a momentum P. We shall write the angular momentum of the planet using both approaches. In the vector algebra, we would use a cross product defined by the right hand rule to get the following. L = R X P (R cross P) L is a vector defined as perpendicular to R and P at the same time. Since there are two possible directions for this 'vector', the right hand rule is used to choose the right-handed one. The magnitude of L is the product of the magnitudes of R and P times the sine of the angle between them. It turns out that the cross product defines a different kind of vector from R and P. It is important for users of this system to distinguish polar vectors from axial vectors, as they are not really the same thing even if they appear to be. In the geometric algebra, we would use the general product defined in the algebra to get the following. L = R ^ P = 0.5(R.P - P.R) (^ is the antisymmetric part of (.) in this case) The geometric nature of L is dependent on the (.) product and not defined to be a vector. As it turns out, L is a bivector. In a three dimensional, Euclidean space, L has the same number of coefficients whether it is described as a bivector or as a vector, but its nature under parity transformations is quite different. A little more exploration would show that all the axial vectors from the other system are bivectors in a geometric algebra. Keeping the polar vectors separate from the axial vectors is done automatically since they are of different ranks. Example 3 The last example involves an operator that rotates other objects. This example will be restricted to two dimensions in order to make it easier to understand. There is only one plane in two dimensions, so there is only one kind of rotation operator. Imagine a two dimensional vector described as V = A x X + B x Y. Suppose we want to rotate it by 45 degrees swinging the X direction up toward the Y direction a bit. The left sided operator that does this is as follows. R = cos(45) x 1 + sin(45) x XY Multiply them as follows. Vprime= R.V = * = (cos(45)1+sin(45)XY)(AX+BY) * = cos(45)AX + sin(45)AXY.X + cos(45)BY + sin(45)BXY.Y * = cos(45)AX - sin(45)AY + cos(45)BY + sin(45)BX * = [cos(45)A+sin(45)B]X +[cos(45)B-sin(45)A]Y Thus far, we have shown enough material to demonstrate how to use the tool for classical theories of physics. With a bit of practice, the reader could use geometric algebras to see why special relativity is built into the fabric of their solution space if they pick the right algebra and the right metric. For the physicists, though, this is not enough. A better mathematical tool to do what we already know how to do is only of pedagogical interest. Whether geometric algebras provide engineers and software developers more efficient approaches to writing solutions remains to be seen. For the physicists and physics students, then, we shall provide one more example that needs more work on a theoretical and experimental level. To do this, we must provide one more definition. 8. Left Ideal A left ideal is a set of elements from a ring that behave as follows. If M is an arbitrary element of the ring and L is an element of the left ideal, then M.L is an element of the left ideal. Our geometric algebras are rings, so a left ideal in one of them has the property that any element multiplied from the left with an element of the ideal is still in the ideal. This has the curious property of ensuring that operators that can be written in the same algebra as the operands will not take you outside the left ideal if you start there. Why this is interesting to the physicists is best shown by an example in a four dimensional algebra with a space-time metric. Example 4 Consider an algebra whose generators are CT, X, Y, and Z. Let the first generator have a negative square while the others have positive squares. Also let the algebra be defined over the complex numbers for the field. From this algebra it is possible to write an idempotent that looks as follows. I = 0.25 (1 + iCT)(1 + CTXY) or = 0.25 (1 + ip/m)(1 + E5.S) where p is a time-like four-vector, S is a space-like four-vector and E5 is the quadvector. It turns out that if you try left multiplying any element of the algebra against I you will not cover all the possible elements in the algebra. Only a subset can be reached through left multiplication, so I can be said to generate a left ideal. In a four dimensional algebra, we start with four generators and create sixteen basis elements through multiplication. This sixteen-element set is the basis of the more familiar vector space associated with the algebra. If we use our idempotent described above, we can create a smaller vector space spanned by four elements that can be written as follows. Basis elements of the left ideal are 0.25(1 +/- ip/m)(1 +/- E5.S) Anyone with any exposure to early relativistic quantum theory will recognize this ideal as having the same 'states' as a four-component bispinor. Since these elements span a left ideal, left-sided operations on them from other elements of the algebra ensure the resulting element is still in the ideal. This is very much like saying that an electron is an electron no matter what state you happen to find it in. Therefore, the left ideals ARE renderings of the particles that an algebra can describe. No appended spinor space is required to get spinor-like behavior from these algebras. The behavior is already there. The really cute thing is that spinor-like behavior can also be found in the classical theories written with these algebras. There is no way to get it out, really. Future Work The bulk of the work that is occurring today using geometric algebras is being done at the post-graduate level by academic researchers. Their results get discussed at conferences and published in peer-reviewed journals. As a consequence, it is not that easy for someone outside the immediate field to break in as a beginner and learn to be productive. This is mostly due to the fact that the physics problems being research are complex, post-graduate problems. The usage of the geometric algebras is not all that complex. There are two open source projects managed by the author that make use of geometric algebras. The first supports the creation of a java library to be used much like a library that supports matrix and tensor objects and their operations. The second project is a solar sail simulation application that makes use of the library from the first project. Anyone curious about the topic of geometric algebra is invited to check out these projects and see geometric algebras in action. Clados Project = http://clados.sourceforge.net SailAway Project = http://sailaway.sourceforge.net References Representation of Objects: http://www.kuro5hin.org/story/2002/5/7/1345/25152 Clifford Algebra Society: http://www.clifford.org D. Hestenes Book: New Foundations for Classical Mechanics. ISBN 90-277-2090-8 D. Hestenes website at ASU: http://modelingnts.la.asu.edu/GC_R&D.html Cambridge Group: http://www.mrao.cam.ac.uk/~clifford/
  15. wrappers by Anonymous Coward · · Score: 0
    Adding more wrappers to hide problems is usually not a good solution

    Qt is a wrapper around the native calls (Windows API, X API, Macintosh WindowMgr/ControlMgr API, etc).

    So why is it bad for MFC (where you go from EnableWindow(window, verb) to window->Enable(verb)), but good for QT?

    1. Re:wrappers by Anonymous Coward · · Score: 1, Informative

      Qt wraps completely the win32 api, and then relies on its own model. So it can and in fact, it did clean things up. And they rely on very low win32 calls, where most of the problems do not appear.

      CodeJock integrates with MFC, so it can not get rid of many of MFC pitfall. And it is not a very well engineered product.

      > you go from EnableWindow(window, verb) to window->Enable(verb)

      If it was just that, that would not be a problem. Unfortunately, many MFC calls are usually more complicated, with obsolete arguments and strange naming.

      You know when using it that the product is old and that they have tried to improve it over the time. Now, they have dumped it for .NET

  16. Speaking of being beaten by SilentStrike · · Score: 1

    Perhaps I deserve it for not previewing and seeing that the formatting was all screwed up :).

  17. Oreos or chocolate chip? by Curien · · Score: 2

    Beaten... why? I think it's fun :-}

    You're right on both counts. See this Usenet post for a little more detail.

    --
    It's always a long day... 86400 doesn't fit into a short.
    1. Re:Oreos or chocolate chip? by SilentStrike · · Score: 1

      Fun is solving problems. Learning idiosyncrasies of some overly complex langauge is something that could be done instead in solving problems. It's not fun, it's mental overhead.

      The more C++ I learn, the more I begin to appreciate more elegant langauges like Python or even Java. I think it's nice to look at code and not having to worry about the countless rules, exceptions, etc, that are in C++.

      I wonder how many things like that above I should use my own code. Perhaps I've been doing do much of it, and I should just "dumb down" my code so I can actually get people to help me develop stuff.

    2. Re:Oreos or chocolate chip? by Anonymous Coward · · Score: 0

      Before you get too enamoured of Python or Java, perhaps you should check out a really elegant language like Common Lisp, particularly the CLOS bits if you're an OO fan - CLOS is OO done right...

      Makes Python look medicore, Java look silly, and C++ look like the spawn of satan (in a bad way).

      The really strange thing though, is that CL might have the best object system in the world (CLOS), but it is arguably the language that needs OO least, thanks to lisp macro processing and functional constructs :-)

    3. Re:Oreos or chocolate chip? by Anonymous Coward · · Score: 0
      It is official; Netcraft now confirms: *BSD is dying

      One more crippling bombshell hit the already beleaguered *BSD community when IDC confirmed that *BSD market share has dropped yet again, now down to less than a fraction of 1 percent of all servers. Coming on the heels of a recent Netcraft survey which plainly states that *BSD has lost more market share, this news serves to reinforce what we've known all along. *BSD is collapsing in complete disarray, as fittingly exemplified by failing dead last in the recent Sys Admin comprehensive networking test.

      You don't need to be a Kreskin to predict *BSD's future. The hand writing is on the wall: *BSD faces a bleak future. In fact there won't be any future at all for *BSD because *BSD is dying. Things are looking very bad for *BSD. As many of us are already aware, *BSD continues to lose market share. Red ink flows like a river of blood.

      FreeBSD is the most endangered of them all, having lost 93% of its core developers. The sudden and unpleasant departures of long time FreeBSD developers Jordan Hubbard & Mike Smith only serve to underscore the point more clearly. There can no longer be any doubt: FreeBSD is dying.

      Let's keep to the facts and look at the numbers.

      OpenBSD leader Theo states that there are 7000 users of OpenBSD. How many users of NetBSD are there? Let's see. The number of OpenBSD versus NetBSD posts on Usenet is roughly in ratio of 5 to 1. Therefore there are about 7000/5 = 1400 NetBSD users. BSD/OS posts on Usenet are about half of the volume of NetBSD posts. Therefore there are about 700 users of BSD/OS. A recent article put FreeBSD at about 80 percent of the *BSD market. Therefore there are (7000+1400+700)*4 = 36400 FreeBSD users. This is consistent with the number of FreeBSD Usenet posts.

      Due to the troubles of Walnut Creek, abysmal sales and so on, FreeBSD went out of business and was taken over by BSDI who sell another troubled OS. Now BSDI is also dead, its corpse turned over to yet another charnel house.

      All major surveys show that *BSD has steadily declined in market share. *BSD is very sick and its long term survival prospects are very dim. If *BSD is to survive at all it will be among OS dilettante dabblers. *BSD continues to decay. Nothing short of a miracle could save it at this point in time. For all practical purposes, *BSD is dead.

      Fact: *BSD is dying

  18. Qt vs .NET? by ClosedSource · · Score: 2, Insightful

    I don't think there are many Windows programmers using MFC for new development. A comparison of Qt and .NET would be more relevant.

    1. Re:Qt vs .NET? by alyandon · · Score: 1

      I wouldn't discount MFC yet for new development (unforutantely). Microsoft released a big update to the core MFC libraries with Visual Studio .NET so they are obviously expecting new development to occur.

    2. Re:Qt vs .NET? by ClosedSource · · Score: 1

      I wouldn't assume that an update to MFC would imply a lot of new development. The update is useful for legacy MFC applications many of which are unlikely to be ported to .NET.

      I guess if a SW team has lots of experience in MFC and likes it, they might use it for new projects, but I think most Windows developers would prefer to use .NET since that's where future Windows development is going.

    3. Re:Qt vs .NET? by Anonymous+Brave+Guy · · Score: 2
      I don't think there are many Windows programmers using MFC for new development.

      That's an interesting perspective. Personally, I don't think there are many Windows programmers using .NET for new development.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    4. Re:Qt vs .NET? by ClosedSource · · Score: 1

      "Personally, I don't think there are many Windows programmers using .NET for new development"

      Well, I can't prove that there are, but there were about 5000 programmers who traveled to Orlando back in July of 2000 to learn about .NET (and paid a lot of money to be there). So, I think there is some evidence of interest.

      I can't imagine why anyone writing a new Windows only application would not at least consider .NET.

    5. Re:Qt vs .NET? by Anonymous+Brave+Guy · · Score: 2
      "Personally, I don't think there are many Windows programmers using .NET for new development"
      Well, I can't prove that there are, but there were about 5000 programmers who traveled to Orlando back in July of 2000 to learn about .NET (and paid a lot of money to be there). So, I think there is some evidence of interest.

      Sorry, I couldn't resist the cynical one-liner. In all seriousness, though, I think .NET is much hyped but, so far at least, little used. There are always those who will go with whatever Microsoft produces. They went for Visual Basic first, they went for COM first, and they'll got for .NET and C# first. The remainder of the Windows programming world -- the vast majority -- is more interested in making a product and getting paid for it, and will therefore probably stick with tried and tested solutions like VB6, VC++6 w/ MFC, and so on for a long time to come.

      Microsoft is trying the same trick with the programming world that it's attempted with Windows and Office users recently: produce a new version, with limited new features applicable to a few users only, and hope the bigger version number and hype is enough to get everyone else moving as well. It hasn't worked well so far with office users, and I doubt the programming world (for all their natural instincts to use the latest and greatest) will be any more easily fooled.

      To give credit where it is due, .NET does seem to offer genuine advantages for those writing certain types of application, notably anyone interested in web services. (I don't know why anyone would write for it in "Managed C++", though; if you're doing new development for .NET, you might as well use C# or VB.NET so you can take advantage of it cleanly.) For the average desktop application, though, .NET seems to offer little other than a whole new class library to learn and a whole new massive overhead to install.

      You're right that anyone programming for Windows should probably consider it in their own circumstances, of course. I spent quite some time looking into it during the months running up to its release, from the point of view of writing a typical desktop Windows application. I found no compelling reason to move to the new technology, with all the retraining and redevelopment of libraries and tools that necessarily requires.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    6. Re:Qt vs .NET? by ClosedSource · · Score: 1

      I guess everyone has their own way of looking at it. Most of my Windows development has been using the raw API from C++ and (unfortunately) Ada. Perhaps if I had invested a lot of time in VB6 and MFC I might look at it differently. We also didn't do any library development, so that's not a roadblock.

    7. Re:Qt vs .NET? by Ben+Hutchings · · Score: 2

      Most of those people were getting a trip to Orlando at someone else's expense. I probably wouldn't mind doing that whether or not I was interested in .NET.

    8. Re:Qt vs .NET? by ClosedSource · · Score: 1

      "Most of those people were getting a trip to Orlando at someone else's expense.I probably wouldn't mind doing that whether or not I was interested in .NET."

      July in Orlando? No thanks!

      In any case, if their company sent them, that still indicates an interest in adopting .NET. It doesn't really refute my argument.

  19. MFC vs wxWindows discussion more interesting by LoveMe2Times · · Score: 1

    We had an MFC vs wxWindows discussion, where Qt and others were of course brought up, and it was MUCH more informative. See here.

  20. QT vs MFC by LOSER+*me · · Score: 1

    I personally use QT, its feature rich and the cross platform ability is obviously a large benefit.

    As a previous poster mentioned the VCL is really nice too, its just a shame that I have to use Object Pascal to use it I hear a C++ version is coming to Linux though.

    As for MFC I don't really like it, it just doesn't feel object orientated enough!

  21. MFC not *that* bad by RailGunner · · Score: 2
    The author's right, QT is far superior to MFC. Cross platform support and a nice, easy to use slot / signal architecture makes my life as an application developer much easier.

    However, MFC isn't that bad. If you're developing a Windows application in C++, and you're forced into using MS only technology cause your boss won't pay the $1000+ per developer license for QT, and your choices are between using MFC and the base Win32 API, then MFC is the way to go. Granted, the Document / View Architecture is uh... well it's *odd*, but once you get the hang of it you can whip out a reasonably good GUI quickly.

    MFC does do some nice things for you, mainly serialization and treating controls as objects, and the Message Maps are a vast improvement over the 10 page switch statements for Message Handling in Win32..

    However, since MFC is "dead", I'd rather see a comparision between C# and Windows Forms vs. C++ and QT.. (and a lot of this I posted on Microsoft's own news groups.. hehehehe)

    Seriously, If you want to see something that's godawful, look at C# and Windows Forms.

    The below is from a post I submitted to Microsoft's own news groups.. to date, I have not gotten any kind of response from Microsoft. A couple of "Wait for Borland C++ Builder.NET" responses.. but nothing from Microsoft. Since MFC is "dead" and .NET is the "way" for Microsoft now, it makes sense to post this..

    Especially if you have an option between QT and .NET... PICK QT FOR THE LOVE OF GOD.

    While trying to develop a dockable tool window (much like the ones found in Visual Studio.NET) I've done a lot of research and had a lot of grief. Out of the box, you can't create a dockable window.

    No one seems to know of any royalty free, open source solutions, and the .NET Magic library doesn't count. Look closely at the source and you'll find that there's an awful lot of Win32 API calls being made via PInvoke, which, per Petzold on page 237 of "Programming Windows with C#", is "no longer writing managed code, and certainly not platform-independent code."

    So for the .NET Magic library users, what's the point of even bothering to use C# and Winforms if all you're using it for is to wrap Win32 API calls? Why not just use C++ compiled as a Win32 app and get the performance increase and greater toolset? I know that making it a dockable window is just a window style, (FWS_something, too lazy to look it up right now, which you would think would just be a property of a Control type, since Control seems to Map 1 to 1 to a Window.)

    Which brings me to the largest gripe I have about the .NET framework: The Winforms really suck. The overly simple UI controls it exposes are simply not acceptable in today's enviroment. First, I'll give Microsoft credit: Visual Studio.NET's UI is absolutely stunning, and the C# language has some nice features....

    However, it is seemingly impossible to create any form of advanced UI unless you derive your own controls or use PInvoke to create GenericPane window classes. And according to Spy++, those nice dockable, resizable windows are of Window Class GenericPane. Seriously, take Docking toolbars for example - we've been able to do this in MFC for years, so using "pure" C# really seems like two steps back instead of the leap forward the PR machine would have you believe. For any kind of advanced UI are we really forced to pony up money for third party libraries or roll our own? (And again, for the goal of "pure" C#, using PInvoke doesn't count.)

    What's really maddening is that there's so many other language / RAD toolkits that do this much better. C++ / MFC, C++ / QT (for cross platform), Java / Swing, to name a few.

    Even the Menus aren't dockable / moveable. What's the point of using managed code if the only applications you can quickly produce look like crap?

    1. Re:MFC not *that* bad by mheine · · Score: 1

      Serialization in MFC is only nice until you uncover one of its bugs. Like a CArchive of a CList with two to the x plus 10 items is corrupt and can't be reloaded. Where x is 5 or greater by the way.

  22. Great, if this was 2-8 years ago... by malakai · · Score: 2

    (my apologies to Wired Magazine)

    Tired: MFC
    Wired: System.Windows.Forms

    Anyone creating an app from scratch right now, or porting an app not written in MFC, should _not_ be even considering MFC. New MFC enhancements are usefull for maintaing the (large) base of MFC apps written in it over the last ?10? years. It's time is over though.

  23. MFC is NOT replaced by Windows Form by edyu · · Score: 3, Informative

    I don't know why everyone is claiming MFC is no longer in the picture after .Net. It's like claiming Newspaper was dead after TV came out. Here is an excerpt from MSDN:

    It has been three years since the last major update to MFC and ATL. With all the press on Microsoft® .NET, MFC and C++ developers may be feeling left out. But don't worry--with the upcoming release of Visual Studio .NET, not only do developers using Visual C++® get a brand new IDE with tight integration for server-side development and a much improved C++ compiler, MFC and ATL have also received significant new features. The clear message is that MFC continues to be a great framework for developing sophisticated, rich client applications for all Windows® platforms. In this article, we'll provide you with a survey of the new features that you can use in your MFC applications.

    There's a new MFC DLL (MFC70.DLL) that is no longer backward binary-compatible with MFC42.DLL, but your source is still compatible (although message maps have been made more type-safe, so that may break some code).

    MFC and ATL are much better integrated, and common classes such as CString are now shared between the two libraries.

    Header files are synchronized with the latest Platform SDK, supporting UI features in Windows 2000 and Windows XP such as themes and manifest resources, Active Accessibility®, and new common dialog boxes.

    Many new UI classes have been added, including support for using DHTML in dialog boxes and enhanced bitmap support with CImage.

    New utility classes can be used in both MFC and ATL applications, such as regular expressions, performance counters support, and security.

    Now there's support for consuming Web Services in MFC applications and writing Web Services and applications with ATL Server classes.

    High-performance access to databases has never been easier using the new OLE DB attributes and classes.

    STL has been updated.

  24. Notes from a 6-month MFC coder by davidmccabe · · Score: 0, Flamebait

    I haven't used QT, but my experience with MFC has been:

    MFC is the most confusing, bloated, needlessly complex, poorly-designed API in the world.

    First, you use this little program called 'AppWizard', that asks you a few question like if you want toolbars, if you want database support (database support?), if you want OLE, etc. Then it spits out this hulk of code that has all these weird constants and macros in them with names like '__AFX_DEFINED_DDLXCI_AXWEC_UBER_MACRO_EXCHANGE_DD FC' scattered all over it. And you can just pull values out of a dialog box; you have to use this thing called "Direct Data Exchange" that I never really figured out, and you have all these magic cookies that get defined in some header file somewhere and you don't even get to write main() and all the functions have weird names and at least we have a good String class but all the classes start with the letter 'C' and everything is in hungarian notation and all those weird macros and WHERE DO I DRAW STUFF IN MY WINDOW?! and BLAH BLAH BLAH!!!

    I write in Java now.

    1. Re:Notes from a 6-month MFC coder by nikonrr · · Score: 0

      thank you for writing this, it expresses all that is evil about mfc.

    2. Re:Notes from a 6-month MFC coder by RupW · · Score: 1
      Then it spits out this hulk of code

      with // TODO comments where you should put your code if you don't want to delve too deeply

      that has all these weird constants and macros in them with names like '__AFX_DEFINED_DDLXCI_AXWEC_UBER_MACRO_EXCHANGE_DD FC' scattered all over it.

      They're the header include guards - which are sensibly long (they contain a GUID) and easily recognizable.

      And you can just pull values out of a dialog box; you have to use this thing called "Direct Data Exchange" that I never really figured out,

      Yes you can; you can call 'GetWindowText()' on any control. If you didn't associate a control variable with your dialog then you can call a method on the CDialog object to get an MFC you can call these methods on.

      DDX is just a convenience:
      • you associate a simple variable with a control (easiest with the ClassWizard0
      • before you start reading data you call UpdateData(TRUE)
      • you access data in your DDX-associated simple variables
      • you call UpdateData(FALSE) if you changed values and want to reflect them back to the display.
      It's that simple.

      and you have all these magic cookies that get defined in some header file somewhere

      The Win32 API is constant-heavy. You can't completely escape it and MFC does well to not try.

      and you don't even get to write main()

      You use InitInstance() in your CWinApp derived object if you need a main() alike. Alternatively, just write UI response code.

      all the classes start with the letter 'C' and everything is in hungarian notation

      Such is the Microsoft coding convention.

      WHERE DO I DRAW STUFF IN MY WINDOW?!

      Override OnPaint() in your view object if you really need to - this exactly corresponds to WM_PAINT in non-MFC apps.
    3. Re:Notes from a 6-month MFC coder by davidmccabe · · Score: 1

      Apparently every one of my five MFC books are defective. Or at least very incomplete.

      Anyway, I still love Java.

    4. Re:Notes from a 6-month MFC coder by Anonymous Coward · · Score: 0

      If you seriously want to give MFC a chance I'd recommend some of the Microsoft Press books.

  25. A bit *too* nice about Qt by Anonymous+Brave+Guy · · Score: 3, Insightful

    I can't help feeling that, whatever its position on MFC, the article was unjust in its uniform praise of Qt. Some of the container classes there (QMap?) appear to be somewhat inferior versions of the STL equivalents, in case the C++ library in use doesn't support the STL parts properly, but doesn't support all the template guff required to use them(?!) To their credit, they do at least try to support the standard interfaces so you can use their containers with standard algorithms, which is a definite improvement over MFC.

    The article also seems to praise QString, which is yet another string class with a Big Bloated Interface(TM) (doh!) that thinks using only mutable strings is the way forward (double-doh!) and reference counting/copy-on-write of a mutable string is a Good Thing (double-plus-doh!). These are well-known design flaws with both approaches, relating to efficiency, thread safety, etc. If they wanted an improvement, they should have provided an immutable string class with a suitable set of operations, and a string-building framework to go with it where it's genuinely the appropriate tool. Oh, and being in native Unicode isn't particularly clever. Why not just use std::wstring, anyway?

    As for the graphics, sometimes I want to lay out my dialog controls in exactly the positions I decide to put them in. Dynamic generation can be a good thing, but don't mandate it, because sometimes it's simply wrong.

    I also have quite a bit of experience of i18n, and I'm all-too-familiar with the pain of translations, etc. For those who don't know, l10n (the opposite to i18n, i.e., making your location-generic application work in a specific locale) is about 10% translation and 90% integration, fixing up all the dialogs, ensuring that your UI can cope with reordered sentences (hope you don't like the IOStreams approach; printf had it right years ago) and so forth. A simple tr() function is not the silver bullet here, contrary to what the article seems to suggest.

    Don't get me wrong, I think Qt is a nice library, and much better than many of the alternatives. But some of the claims in the article are just downright false.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:A bit *too* nice about Qt by Anonymous Coward · · Score: 1, Interesting

      > These are well-known design flaws with both approaches, relating to efficiency, thread safety, etc.

      In 3 years of development with Qt, I haven't met any of the problems you describe. Maybe I am not writing the right programs.

      > If they wanted an improvement, they should have provided an immutable string class with a suitable set of operations,

      You mean a QConstString

      > Oh, and being in native Unicode isn't particularly clever.

      This is a comparison with MFC. You are telling me that their choice is really stupid and I agree. In comparison, the other choice looks clever.

      > As for the graphics, sometimes I want to lay out my dialog controls in exactly the positions

      You can do it if you want, even with Qt Designer. But I don't see when you want to do that. Could you give an example ?

      Anyway, in the big majority of case, you want things to layout automatically and it is easy to do that with Qt.

      > ensuring that your UI can cope with reordered sentences

      QString can deal with reordered arguments.

      > A simple tr() function is not the silver bullet here, contrary to what the article seems to suggest.

      Yes it is. gettext() had it right from years. This approach allow the developer not to worry too much about translation, allow the translator not to cope with compiling stuff and get automatic update, and allow the user to add new language without hassle and to switch easily from one language to another.

      Qt uses exactly the gettext() approach, with their own tools.

    2. Re:A bit *too* nice about Qt by Anonymous+Brave+Guy · · Score: 3, Informative
      These are well-known design flaws with both approaches, relating to efficiency, thread safety, etc.
      In 3 years of development with Qt, I haven't met any of the problems you describe. Maybe I am not writing the right programs.

      Maybe you've been lucky. Who knows? The fact remains that there are demonstrated problems that can occur when using COW strings in a multithreaded C++ system, and further, the advantages of using such a design are mostly illusory anyway. It seemed like a good idea at the time, but on reflection, it turned out not to be. (BTW, I have watched an application fall over for no good reason because its string library wasn't multithread-safe when it should have been, and I've watched the development team waste several man-days of time trying to find the bug in their code -- which wasn't.)

      If they wanted an improvement, they should have provided an immutable string class with a suitable set of operations,
      You mean a QConstString

      I don't think so. I mean a full-fledged immutable string class that supports the usual look-up and combination operations without the mutating ones, and a clean interface to convert between such a class and a vanilla QString. AFAICS, that's a whole world away from QConstString.

      You can [lay out dialog controls in exact positions] if you want, even with Qt Designer. But I don't see when you want to do that. Could you give an example ?

      In simple cases, I agree, an automatic layout can be very helpful. OTOH, on a program I used to work on, extensive used was made of tabbed dialogs. The layouts of most of them were fixed across all of the tabs, so that similar controls didn't jump around irritatingly as you flipped from tab to tab. I don't know if Qt's automatic layout system would handle that, but certainly no other one I've ever seen does. Automatic layout is simply not the best answer to everything, which the article seemed to be suggesting.

      A simple tr() function is not the silver bullet here, contrary to what the article seems to suggest.
      Yes it is. gettext() had it right from years. This approach allow the developer not to worry too much about translation, allow the translator not to cope with compiling stuff and get automatic update, and allow the user to add new language without hassle and to switch easily from one language to another.

      With all due respect, if you think a simple translation mechanism like that is all there is to i18n/l10n, I can't believe you've ever worked on a large-scale multi-lingual application. There are other locale-related formatting issues (date/time, currency, etc). There are languages where routine system calls don't work on some strings (try a toupper on the German word Strasse, and then try the same on the same word written with a Schaffes s, and then compare them for equality). In Japan, most machines speak MBCS, not Unicode, so you need an effective means of converting between them, preferably as soon as the MBCS enters your program and just before it leaves so you can at least use Unicode internally. Some languages read right-to-left, or top-to-bottom, or even more devious variations, and you have to adapt your UI to cope with this, particularly when laying out dialog boxes and such. It is not as simple as a tr() function. (I'm not saying Qt couldn't cope with many of these issues, just that the emphasis placed on the tr() function by the article is overstated.)

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    3. Re:A bit *too* nice about Qt by elflord · · Score: 1
      Some of the container classes there (QMap?) appear to be somewhat inferior versions of the STL equivalents, in case the C++ library

      Qt is pre-STL. Also, it makes different design tradeoffs. The containers are pointer-based, and are implement using the "inheritance from void*" container idiom which means that the "template bloat" is minimised in these classes. It makes sense in Qt, since Qt programs use pointers and not values.

      These are well-known design flaws with both approaches, relating to efficiency, thread safety, etc.

      They weren't well-known at the time Qt was written. gcc still ships with a reference counted std::String today.

      Why not use std::wstring

      It wasn't an option when Qt was written. You're writing this as though Trolltech had full benefits of the ANSI/ISO 1998 standard at the time they implemented it. Qt was written in 1996.

    4. Re:A bit *too* nice about Qt by Anonymous+Brave+Guy · · Score: 2

      Sorry, didn't mean to come across as bashing Qt. I realise it was first created pre-standard and couldn't have benefitted from the experience gained by the C++ community over the past five or so years. I was trying to highlight flaws in the evangelism of the original article by citing obvious concrete examples of false claims (containers better than STL, yada yada).

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    5. Re:A bit *too* nice about Qt by elflord · · Score: 1
      I was trying to highlight flaws in the evangelism of the original article by citing obvious concrete examples of false claims (containers better than STL, yada yada).

      I agree with the overall impression. The article comes across as cheerleading, and not a balanced comparison. I haven't used MFC, but I find it hard to believe that it's as bad as they make it sound. The containers are adequate, but the design is not as clean as STL, and there are some benign warts like "current" nodes in lists, and index based access in lists (I say bening, because one can just ignore these misfeatures).

    6. Re:A bit *too* nice about Qt by Ben+Hutchings · · Score: 2
      A simple tr() function is not the silver bullet here, contrary to what the article seems to suggest.

      Yes it is. gettext() had it right from years. This approach allow the developer not to worry too much about translation, allow the translator not to cope with compiling stuff and get automatic update, and allow the user to add new language without hassle and to switch easily from one language to another.

      A major problem with gettext() is that there can only be one translation of each of the strings in the original language. What happens when you use an English word with different meanings in different contexts, that should be translated to separate words in another languages? Usually your messages will be long enough that this doesn't happen, but in a GUI you may well use text labels with only one word in them.

    7. Re:A bit *too* nice about Qt by infiniti99 · · Score: 2

      The article also seems to praise QString, which is yet another string class with a Big Bloated Interface(TM) (doh!) that thinks using only mutable strings is the way forward (double-doh!) and reference counting/copy-on-write of a mutable string is a Good Thing (double-plus-doh!). These are well-known design flaws with both approaches, relating to efficiency, thread safety, etc.

      Can you explain these inefficiencies, or provide a URL to some analysis about them? Personally, I think the copy-on-write stuff is really cool. Not just QString, but even container classes like QValueList won't duplicate your objects unless needed. Native Unicode makes things simpler too...

  26. New != better by Anonymous+Brave+Guy · · Score: 2
    Anyone creating an app from scratch right now, or porting an app not written in MFC, should _not_ be even considering MFC.

    I assume from the rest of your post that you're advocating using .NET instead? Why on earth would any development team of sound mind do that?

    .NET has precious little in the way of genuine benefit to offer most projects. Its class library isn't much better than MFC in many places, and it introduces a whole new range of limitations and bugs that people will have to learn to work around (if they can). Please don't shout "garbage collection!" or "class library!" at me, because it will cut no ice. The use of either limits you so seriously that you might as well give up all the good things about C++ and other libraries available for it and use C# instead; "managed C++" isn't really C++ at all.

    MFC, OTOH, while kludgy and less than well-designed, has a developer base of zillions across the world who know how to work around its kludginess and get the job done. It is tried and tested, so at least you have a pretty good idea where the bugs are. There is a lot of truth to the old saying "Better the devil you know".

    If I had a new development team starting on a Windoze app, MFC certainly wouldn't be my first choice of tool -- far from it -- but it would be waaaaay ahead of anything to do with .NET.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  27. Don Box by Anonymous+Brave+Guy · · Score: 2
    According to Don Box (COM guy, now works at Microsoft) the number is 0 - zero! nil! (He mentioned it in his keynote address at Microsoft Developer Days 2001 in Copenhagen)

    Would that be the same Don Box who wrote about how COM was wonderful for years, but now says it's crap and we should all use .NET?

    You should be very careful when listening to two-faced Microsoft weenies, particularly when they're demonstrably wrong. MFC was used in writing Visual Studio itself for a long time (though never, AFAIK, in writing things like Office).

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  28. MFC by oliverthered · · Score: 2

    I agree, there's also ATL i think that's even worse!!! I found it far easier to write using straight windows API.

    Fortunatly I wrote my own Windows wrapper before MFC came along.

    MFC might look good in comparison to Visuial Studio which must be one of the worst Dev environments I've ever used, I'd never take a job where Visuial studio was a requirement.

    --
    thank God the internet isn't a human right.
    1. Re:MFC by RupW · · Score: 1

      I agree, there's also ATL i think that's even worse!!!

      There's a learning curve, agreed, but ATL is very powerful if you want a COM implementation that covers all corner-cases and configuration properly. The ATL with VS7 has been beefed up with MFC-style helper classes (CATLStringW, etc.) and is an absolute dream to use. Honest.

      MFC might look good in comparison to Visuial Studio which must be one of the worst Dev environments I've ever used

      What's wrong with it? IMO, it's a nice editor with a well-integrated (and useful!) source debugger.

  29. porting mfc apps to wxwindows by Anonymous Coward · · Score: 0
  30. Kylix 3 just released with c++ and OP by oliverthered · · Score: 2

    borland has Just released Kylix 3with C++ and Object Pascal support in one product.

    Don't know why this hasn't made it to /. yet?

    --
    thank God the internet isn't a human right.
    1. Re:Kylix 3 just released with c++ and OP by hyperstation · · Score: 1
  31. HTML help is EVIL by oliverthered · · Score: 2

    Microsofts help was ok when it was in plain help files It just got shit when monkey soft switched to HTML help forcing everyone to install IE.

    --
    thank God the internet isn't a human right.
  32. Addressing some MFC points in article by RupW · · Score: 1
    I've some experience with MFC but not QT. I don't think you've correctly understood the MFC model. (Colleages recommend Prosise's book by Microsoft Press but it's been a long time since I've seen a copy.)

    The Microsoft Foundation Class (MFC) is a graphical toolkit for the windows operating system. It is a more or less object oriented wrapper of the win32 API, which causes the API to be sometimes C, sometimes C++, and usually an awful mix.

    The only non-C++ you could complain about in MFC is the use of some Win32 API structures without containing classes/accessors. Under the circumstances (given the number of them!) I don't think this is too big a deal.

    MFC programming requires the use of Document/View model and templates.

    No, it doesn't. If you don't want Doc/View, you can just use the MFC-dialog-application template.

    I've never seen the other problems you mention:
    • you can probably ditch the document/view model (I've never tried) but you can easily bury it if you don't like it and I've never found it inflexible enough to be a hinderance. Cite an example?
    • I wouldn't be surprised if splitting a window to show two different documents probably violates the windows UI design guidelines. You can get equivalent function using an MDI app (although I think the guides have deprecated those) or implement a 'document container' class or something. You probably don't need too much imagination.
    MFC is a kind of object wrapper allowing access to the windows API,

    I'd consider this a plus - lean (or as lean C++ as you'll get), efficient (ditto) and feature-complete.

    And there are nasty tricks, without any consistency. For example, if you create a graphical object, it is not created until the Create() methods has been called. For dialogs, you must wait for OnInitDialog, for views, you wait for OnInitialUpdate, ... So if you create an object manually and call its methods, your program crashes.

    No. This *is* consistent and logical. And OO.
    1. When you create a CDialog, you create a container class for a window handle with dialog-like methods. You may set up the initial state of the dialog, member variables of the container class, etc. But because you have an empty handle you can't actually play with the dialog yet.
    2. You Create() or DoModal() your CDialog object. Now the windows is actually generated on the desktop and the window handle is filled.
    3. You're called back in the OnInit* method to set any state on the window as it is created. You may now call methods that require a window handle.
    I don't think MFC will crash - I think it'll give you a useful debug assert. But I haven't fallen into that trap for a while.

    MFC is full of these nasty tricks. And it is hard to debug.

    'nasty tricks' is a little extreme. MFC integrates very well with Visual Studio's debugger and is relatively simple to debug. You're provided with the source code to step through if you need it. I've never had any trouble.

    Qt is based upon a powerful callback mechanism based on signal emission and reception inside slots.

    This sounds exactly like the Windows message model that you've just slammed (!). I don't see any problems with the windows message model - but then I'm familiar with the API.

    The interface creation section: DDX and IMPLEMENT_DYNCREATE (why do you need that for your UI?) are relatively easy to understand - maybe try Prosise's book if you need enlightenment. You don't need to touch the message loop - it's buried in the MFC DLL and covers all cases. You can quite happily manufacture dialogs at run-time by calling Create() on control objects in the OnInitDialog() method.

    Qt designer lets you do things that are not possible in MFC, like creating a listview with pre-filled fields, or using a tab control with different views on each tab.

    Pre-filling a list view should be done in OnInitDialog(); the interface is quite simple.

    Tabs are a different matter; you need to create child dialogs for each separate pane. This closely reflects what's going on in the OS API. It's not too difficult and there are good sample applications. Alternatively, there's a very simple interface to create complex property pages already provided.

    Visual's documentation, MSDN (for which you must pay separately) is huge, on 10 CDROM.

    It's no more than 3 CDs. It's bundled with Visual Studio. It's available online at http://msdn.microsoft.com/library/. And it's very good, complete documentation.

    MFC's unicode is very easy. If you need to change the entry point of your application then you're doing it wrong; you probably need to change /D_MBCS to /D_UNICODE and it should happen automatically. The _T() is to tell the compiler to generate unicode character constants. It's a MFC/Win32API macro that emits syntax for the compiler. There must be a similar mechanism in QT or you won't be able to pass it unicode constant strings. If you build your application with the correct Unicode defines then the CString class will be Unicode internally automatically (but will still support some char* functions). If you build your application ground-up Unicode (and you should be doing this - NT is natively unicode) then you'll have no problems; Unicode converting an existing app isn't as hard as you portray.

    If you're given non-unicode third party library then the third party ought to be able to supply a unicode version by changing a few flags and rebuilding. I'd be surprised if many vendors couldn't supply Unicode libraries if you asked them.

    Resources and string-tables are part of the Win32 API. I find them useful and easy to program for. You have to try quite hard to load resources from the wrong DLL; all resources are indexed on exe/dll module handle as well as resource ID.

    Latest MFC DLL: you should always ship the one you develop and test against! Win2K+ allows you to install a copy of the DLL local for your application. Alteratively, there are simple-ish mechanisms to auto-download the latest MFC from Microsoft.

    To address some of your list of QT advantages,
    • Controls... MFC uses native OS widgets which is arguably an advantage for Win32 programs: correct look and feel and always do exactly what a Windows user would expect.
    • MFC does provide classes for network and database access
    • Memory management shouldn't be a problem; if you create controls as members of the containing dialog class then they'll be destroyed automatically too. MFC's debug memory allocator is good, too.
    I've never used CodeJock.
  33. Arcane trivia by GCP · · Score: 2

    Do people really have to look any farther to figure out why today's software is so buggy? The more subtle "gotchas" in a language, the more subtle bugs in the resulting products.

    I understand the lure of mastering reams of arcane trivia. In fields like medicine, this is valuable. But, when you have to do so just to use a man-made programming language because of how often things are not what they appear, it is a stinging indictment of the poor design of the language.

    --
    "Those who have never entered upon scientific pursuits know not a tithe of the poetry by which they are surrounded."
  34. Visuial studio by oliverthered · · Score: 2

    1st download a trial copy of CBuilder or Delphi and give there IDE a go...

    Here's my top hates....to the point of frastration.

    1: (this is trully evil) the MDI interface.
    2: Dialogues have loads of tabs but arn't resizeable.
    3: Options arn't natural, e.g. right click on a project and I get .....
    4: (part of 3) Options are hidden all over the place.
    5: MSDN HTML help is shit (not the use of HTML for help, but the way MS have used it)

    Here's a few things in CBuilder Delphi (as an example) that are farrrr superior.

    1: No evil MDI
    2: Options are quite easy to find
    3: Fully RAD
    4: Code compleation is highly typed e.g.
    int a = ...
    only lists things that can return or be cast to an int.
    5: The help is generally quite good.
    6: The api for extending CBuilder/Delphi is great and easy to use (easier than Visual Studio).

    --
    thank God the internet isn't a human right.
  35. Too dismissive of Object Pascal by NullStr · · Score: 1

    So you'd rather have a 'grown-up' but non-OO and kinda ugly language than one with a flexible and powerful object model, RTTI, inheritable message-handling framework, copy-on-write strings, etc., etc.?

    All the current hype over .NET is old hat: Delphi has had most of what .NET has to offer for years (not surprising given who wrote them both ).

    Object Pascal makes me much more productive than C++ ever did, and I'm not talking about GUI gubbins here, but the 'invisible' back-end stuff.

    1. Re:Too dismissive of Object Pascal by LOSER+*me · · Score: 1

      non-OO? I know its not 100% OO but its still OO.

    2. Re:Too dismissive of Object Pascal by NullStr · · Score: 1

      The lack of a single base class in C++ (cf. TObject) is a serious flaw in a language that is supposed to be OO; it forces C++ to jump through flaming hoops (think templates, bizarre typecasting, etc.) to simulate OO.

      I'm not claiming that Object Pasal is fully OO - it clearly isn't - but it actually has an object model whereas C++ lacks one. Much of the tantric C++ guru complexity is obviated in Object Pascal by simply casting as TObject.

  36. qt is portable to devices by calarts_nutmeg · · Score: 1

    What's interesting about qt is that its easy to get an app to run both on the desktop and then have a smaller screen version for qtopia.

    --
    Check my site out for ogg vorbis music produced with linux.
  37. But i was first by Anonymous Coward · · Score: 0

    And i got rejected
    * 2002-07-23 13:28:19 Kylix 3 out soon (articles,news) (rejected)

    grrrrrrrrrr

  38. Problems with string classes by Anonymous+Brave+Guy · · Score: 2

    The best exposition I've seen was a set of three articles on "Reference Counting" in Herb Sutter's Guru of the Week series. You can find articles 43-45 on his web site, and as he notes there, an updated version is available in one of his books. You could also search the history for the Usenet group comp.lang.c++.moderated, where GotW is posted, to see more discussion on the subject. You might also want to check out the most recent GotW (questions but no solutions on the web site, but check the newsgroup history) for a few thoughts on why string classes tend to have overbloated interfaces.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  39. QT and moc by heroine · · Score: 2

    The main problem with QT is this thing called MOC, some kind of preprocessor you need to run. Then of course, there's the license fee for use in any commercial software. Other than that, there's just the use of Expose events in X11 making it slow and ugly.