dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Why is winapi so messy?

  1. #1
    Join Date
    Dec 2009
    Posts
    49

    Why is winapi so messy?

    I used WinSock2 a bit and it's just horrible how they can't even use types consistently. I'll bring a few examples.

    int connect(SOCKET s, const struct sockaddr *name, int namelen);
    Why is namelen an int when the ai_addrlen field of addrinfo is size_t?

    int setsockopt(SOCKET s, int level, int optname, const char *optval, int optlen);
    Why is optval char* and not void*? And again why is optlen not unsigned?

  2. #2
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: Why is winapi so messy?

    1. The winsock functions were not written by MS. They were first used back in the late 70s. For standardization sake, MS made the prototypes identical.

    2. As for the majority of the Windows API, it was built function by function over time. If you separate when a function was created into time groups, you will see a logic. For instance, over the past few years, you will see a tendancy toward convenience functions and protecting the programmer from themselves. Kind of like the user permission stuff in Windows.

    As a side note, I personally wish that MS would recognize the difference between:
    A. joe blow and his laptop purchased for email and netflix.
    B. a power user for business.
    C. a developer who knows everything inside and out.

    ==============

    -Erik

  3. #3
    Join Date
    Dec 2009
    Posts
    49

    Re: Why is winapi so messy?

    Quote Originally Posted by egawtry View Post
    1. The winsock functions were not written by MS. They were first used back in the late 70s. For standardization sake, MS made the prototypes identical.
    Are you referring to berkeley sockets? Winsock function prototypes actually differ from berkeley's prototypes. For example connect() actually uses socklen_t which is an unsigned type.

    They should fix inconsistencies.

  4. #4
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: Why is winapi so messy?

    Quote Originally Posted by Bssldr View Post
    Are you referring to berkeley sockets? Winsock function prototypes actually differ from berkeley's prototypes. For example connect() actually uses socklen_t which is an unsigned type.

    They should fix inconsistencies.
    Berkley sockets is a standardization of a what people had been using for a long time before that.

    MS made it so a program typed in identical to one from back in the late 70s/early 80s would compile and run. They adhered to the now defunct POSIX standard.

    At this point, they simply CANNOT change prototypes, half the programs on the planet would break. Every ten years or so, someone at MS tries, and makes a mess. The latest being the in and out added to the prototypes which crash all the older compilers. (They also tried to rename LPWSTR - mess there too.)

    Learn to live with casting like the rest of us.

  5. #5
    Join Date
    Nov 2007
    Posts
    613

    Re: Why is winapi so messy?

    Quote Originally Posted by egawtry View Post
    As a side note, I personally wish that MS would recognize the difference between:
    A. joe blow and his laptop purchased for email and netflix.
    B. a power user for business.
    C. a developer who knows everything inside and out.

    ==============

    -Erik
    Fully agree. It would be great if during the installation of Windows we would be able to pick one of the three options:
    -I'm a novice
    -I'm an average user
    -I'm an IT specialist

    Thanks God (and Bill Gates) that at least they removed that stupid warning "Deleting the shortcut will not uninstall the application".

  6. #6
    Join Date
    Aug 2008
    Posts
    902

    Re: Why is winapi so messy?

    Why not use a 3rd party networking library? The interface would probably be superior and your code would be more portable as well.

  7. #7
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: Why is winapi so messy?

    Quote Originally Posted by srelu View Post
    Thanks God (and Bill Gates) that at least they removed that stupid warning "Deleting the shortcut will not uninstall the application".
    My thanks to God is that they removed the warning on boot when the user checks are turned off. That was so frigging annoying! Every IT guy I know automatically turns it off nowadays.

  8. #8
    Join Date
    Jan 2004
    Location
    Near Portland, OR
    Posts
    222

    Re: Why is winapi so messy?

    Quote Originally Posted by egawtry View Post

    As a side note, I personally wish that MS would recognize the difference between:
    A. joe blow and his laptop purchased for email and netflix.
    B. a power user for business.
    C. a developer who knows everything inside and out.

    -Erik
    Probably my biggest gripe with Windows. And they didn't do all that great a job at fool proofing Windows for the low end user either. For that, Mac OS did a better job.

    Though I think the unfriendliness to users who need/want to know the OS inside and out is one reason the available software for the Mac is still much less than what is available for Windows.

    Bill

  9. #9
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: Why is winapi so messy?

    Quote Originally Posted by wdolson View Post
    Probably my biggest gripe with Windows. And they didn't do all that great a job at fool proofing Windows for the low end user either. For that, Mac OS did a better job.
    No arguments here. Dedicated hardware also makes it more stable.

    Although I do dislike the Mac desktop GUI. Always having to go to the top of the screen for the menu is annoying. I suppose with a hardware GUI it is easier to implement though.

    Quote Originally Posted by wdolson View Post
    Though I think the unfriendliness to users who need/want to know the OS inside and out is one reason the available software for the Mac is still much less than what is available for Windows.
    Again, no arguments. The main reason though is that the Mac is so expensive. That is why I don't have one.

    Also that as a game machine, Macs are harder to program. They cannot be upgraded very easily with a new fancy video card either.

    -Erik

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)