Can we do multithreading without relying on Win32 programming?

Started by
9 comments, last by keltor2243 12 years, 3 months ago
If I were given a choice between Java and C++ to do multiprogramming, I would always choose Java, for its simplicity in multithreading. I would not choose C++ to do multithreading, because of Win32. But, if I'm forced to use one of the languages, then I will not complain.

A little while ago, I read something about C++1x, a standard of C++. I know all of this new standard and whatnots. Then I see that there will be a <thread.h> standard template library header in the C++0x (somehow jumped to C++1x for being too slow).

If <thread.h> are to be included in C++ STL, I won't be needing Win32 to create multithreading applications. From here, it becomes a chain of memories.

I imagine myself creating non-Win32 C++ programs with multithreading, drawing non-Win32 frames (similar to Java JFrames), using STLs to create a window frame in C++, etc. Then dreams of me wishing for C++ and Java to be alike (C++ with an universal STL that is just like Java SDK).

God, help me.

Do you think we can do multithreading without doing Win32 programming in the future?
Advertisement
Why are you so against Win32? It seems strange to dismiss an entire language because of that. Win32 will make up a tiny fraction of the boilerplate stuff for a game project, the majority of the game code is not dependent on anything.

Java still uses win32 under the hood. There are application toolkits and libraries for C++ like wxWidgets and Qt which allow you to do the things you want to do without having to touch Win32, but you will never see such a thing in the STL/standard library
[size="1"]
A little while ago, I read something about C++1x, a standard of C++. I know all of this new standard and whatnots. Then I see that there will be a <thread.h> standard template library header in the C++0x (somehow jumped to C++1x for being too slow).
Do you think we can do multithreading without doing Win32 programming in the future?
Yes, as you just said, the new version of C++ includes threads in it's standard library.

At the moment though, you're not at all forced to use Win32 threads; you could be using pthreads, or boost::threads, etc...
I imagine myself creating non-Win32 C++ programs, drawing non-Win32 frames (similar to Java JFrames), using STLs to create a window frame in C++, etc. Then dreams of me wishing for C++ and Java to be alike (C++ with an universal STL that is just like Java SDK).[/quote]Features such as windows/layouts will likely never be a part of the standard C++ library.

However, as with the above threading libraries, there's plenty of C++ GUI libraries, such as Wx or Qt, etc...

Do you think we can do multithreading without doing Win32 programming in the future?

As was mentioned you can already do this with Pthreads, etc. so I don't get what you're trying to get at?
[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
Intel Threading Building Blocks


As was mentioned you can already do this with Pthreads, etc. so I don't get what you're trying to get at?


I was more keen on having a standard thread library for C++ embedded in the STL, and no having to rely on downloading additional libraries and have to do the include/lib setup in each C++ project settings.

Unlike C++, Java has them entirely bundled up upon initial startup. The only thing I like more than C++ is the ability to have all the libraries (SDK) bundled up, ready for use. What C++ lacks in the STL is some things Java had covered, like threading, networking, some multimedia stuffs, etc.

Or I may have mistaken something and obviously saw what Java had, but haven't seen what C++ had evidently. That's the only thing I have when comparing Java and C++. It's not like I choose a language over Win32 or holding onto a grudge with one of the languages.

[quote name='daviangel' timestamp='1326672048' post='4903077']
As was mentioned you can already do this with Pthreads, etc. so I don't get what you're trying to get at?


I was more keen on having a standard thread library for C++ embedded in the STL, and no having to rely on downloading additional libraries and have to do the include/lib setup in each C++ project settings.

Unlike C++, Java has them entirely bundled up upon initial startup. The only thing I like more than C++ is the ability to have all the libraries (SDK) bundled up, ready for use. What C++ lacks in the STL is some things Java had covered, like threading, networking, some multimedia stuffs, etc.

Or I may have mistaken something and obviously saw what Java had, but haven't seen what C++ had evidently. That's the only thing I have when comparing Java and C++. It's not like I choose a language over Win32 or holding onto a grudge with one of the languages.
[/quote]

Your mistake is to think that Win32 is part of C and C++, and Java libraries (networking, multimedia, etc.) are part of Java. They are not.

C and C++ does not come with all the fancy libraries because a lot of them are platform specific. If you want to make an application in Windows, then you should create application in the way that Windows like it. If you create for Mac OS X, then use Mac OS X libraries. Maybe one day there's a new embedded OS which runs in an entirely different platform and hardware that the concept of GUI no longer existed, so then you had to use what the platform had to offer.

Java comes with it because of JVM. .NET is the same story. If there is a VM to C++ like JVM to Java, you would probably get the consistency you get in Java.

Your mistake is to think that Win32 is part of C and C++, and Java libraries (networking, multimedia, etc.) are part of Java. They are not.

C and C++ does not come with all the fancy libraries because a lot of them are platform specific. If you want to make an application in Windows, then you should create application in the way that Windows like it. If you create for Mac OS X, then use Mac OS X libraries. Maybe one day there's a new embedded OS which runs in an entirely different platform and hardware that the concept of GUI no longer existed, so then you had to use what the platform had to offer.

Java comes with it because of JVM. .NET is the same story. If there is a VM to C++ like JVM to Java, you would probably get the consistency you get in Java.



This is actually no longer true, C++11 includes threading as part of the STL. As has been mentioned earlier, 3rd party cross platform threading libraries have been available for a while, basically they deal with the nitty gritty of threads so you don't have to. I think I disagree with your suggestion to go native whenever possible. Frankly if you don't make significant gains, writing separate code for different OSes is just a waste of your time and resources. Platforms such as Java or .NET, or frameworks such as Qt or wxWindows, make it so you don't have to roll your own for each platform, and generally, you should take advantage.



Also, the concept of threading is a bit muddied, as there are hardware threads, software threads, WIn32 threads, Java threads, .NET threads, etc... and these aren't all the same thing, although in some cases they are. Often times, when you peel back all the layers, you will discover the JVM or .NET runtime are calling CreateThread or a similar ilk from the Win32 subsystem ( when running on Windows that is ). Throw in mutli-processor machines and it gets even more confusing ( as a hardware thread is tied to a single core ).
I swear, once Microsoft updates their compiler to be compatible with C++1x completely, it will be in year 2020...


Java comes with it because of JVM. .NET is the same story. If there is a VM to C++ like JVM to Java, you would probably get the consistency you get in Java.


EXACTLY how you described my thought! But yeah... If there's a VM for all platforms to C++, then maybe I don't have to worry a thing about this at all. If only Microsoft would create .NET for all platforms available, then I'm in heavens!

I swear, once Microsoft updates their compiler to be compatible with C++1x completely, it will be in year 2020...

[quote name='alnite' timestamp='1326800998' post='4903584']
Java comes with it because of JVM. .NET is the same story. If there is a VM to C++ like JVM to Java, you would probably get the consistency you get in Java.


EXACTLY how you described my thought! But yeah... If there's a VM for all platforms to C++, then maybe I don't have to worry a thing about this at all. If only Microsoft would create .NET for all platforms available, then I'm in heavens!
[/quote]

You shouldn't compare Java to C++. As far as programming languages go, you really couldn't get more apples to oranges than that. C++ is a native compiled language. If you want a VM language, then just stick to Java.

This topic is closed to new replies.

Advertisement