Multi-Thread / Concurrency in C++

vs JAVA and C#. Resources and advice?

Page 1 of 1

4 Replies - 2814 Views - Last Post: 29 January 2008 - 06:47 AM Rate Topic: -----

#1 hoofinasia  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-January 08

Multi-Thread / Concurrency in C++

Posted 27 January 2008 - 11:04 PM

Hello all, I'm new to the forums. I've been looking for a resource like this for a long time.

My question involves concurrent programming. It seems to be a hot topic lately, and I'm looking for more information. I understand the process of threads well enough (in JAVA) but I was wondering what options are available for C++. I am unfortunately partial to C++. I've been told time and again its a bad idea to get attached to a language, but I like C / C++ for its ability to "dig deep" and mess around with everything attached to the system. Of course my interest in hardware helps fuel this, but I digress.

I'm currently exploring the Intel Threaded Ap tools, but haven't started real work. I have a few books in the mail, but I thought I'd see if there are any vets floating around here that could point a noob hacker like me in the right direction. More specifically, am I looking at the wrong language? Should I focus on JAVA for multi-threaded and / or concurrent applications? C# seems to borrow a lot from JAVA, should I break my teeth on C#? I read a lot about it, only to find that the writers often have conflicting personal bias towards one language or the other.

You'll have to believe that I've been looking all I can, and excuse me if I've missed something obvious.

I have a bunch of other questions, but I would like to start with this one, then I'll ask the others.
(Enum vs Objects for data storage)
(Objects as agents)
(Controller and Minion Objects, communication thereof)

This post has been edited by hoofinasia: 27 January 2008 - 11:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Multi-Thread / Concurrency in C++

#2 jpw1991  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 13-August 07

Re: Multi-Thread / Concurrency in C++

Posted 28 January 2008 - 03:14 AM

Your post has much depth, I'll answer what I can.

Quote

am I looking at the wrong language? Should I focus on JAVA for multi-threaded and / or concurrent applications?
This depends on what you need to use a language for, C and C++ can handle threads with no problems at all. Since you're a Java person, you will probably prefer C++ to C for the object orientation. In addition, Java is descended from C++, which will make it easier for you to learn. Personally, C is my favourite language, and I would rather code something in C than anything else. I've only had small dealings with C++.

Quote

writers often have conflicting personal bias towards one language or the other.
This is common, people forget a programming language is a tool for a purpose. I suggest you choose the best tool for your situation and forget about opinions. You didn't specify whether you were seeking to do low-level programming or not in your post, if you are looking to do low-level stuff (Drivers, Operating Systems) or things that need speed (Game engines) then I would suggest you use C, or if you want object-orientation as well, C++.

Quote

C# seems to borrow a lot from JAVA, should I break my teeth on C#?
C#.. I don't know much about this language other than I've tried very hard to like it and learn it but failed. I'm unsure of the advantages it provides over Java, and vice-versa. I can best describe it as if you crossed VB with Java.

Quote

(Enum vs Objects for data storage)
(Objects as agents)
(Controller and Minion Objects, communication thereof)
You seem to have a lot of interest in objects, for this reason, I'd recommend C++ to you over C.

My reply probably hasn't been of much help to you, but since no one else had replied I thought I'd try to answer your question. I am very much a C person, with only a small amount of experience with other languages. As a result, I can't really cross-examine languages for you. My best advice, as stated above, is to choose a language that suits your needs the best.

If you're after speed and low-level control over your threads, I don't think C and C++ will disappoint you :)
Was This Post Helpful? 0
  • +
  • -

#3 hoofinasia  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-January 08

Re: Multi-Thread / Concurrency in C++

Posted 28 January 2008 - 06:57 AM

Thanks for the reassurance. I figured C++ could control threads as much as anything else, since its a lower language, but I just don't know how to approach the problem. I'll start digging into my books as soon as they arrive. I need a language that can handle a lot, so I think C++ is the way to go.

View Postjpw1991, on 28 Jan, 2008 - 03:14 AM, said:

Since you're a Java person, you will probably prefer C++ to C for the object orientation.


I'm partial to C++ actually.

Since you are a C person, maybe you can address the idea of Enums vs Objects for data storage. I know this is a loaded question, but what are the advantages of enumerations over objects? The same question could be posed towards Structs. When would I consider using a Struct in C++ as opposed to a dedicated object?

I will eventually learn to use structs as much as anything else, because most of my hardware experience is in C, if not Asm.

Here's a weird question: If I can put assembly in C, and C in C++, can I put assembly in C++? I don't know why I would want to, but I've always wondered that.
Was This Post Helpful? 0
  • +
  • -

#4 jpw1991  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 13-August 07

Re: Multi-Thread / Concurrency in C++

Posted 29 January 2008 - 03:38 AM

View Posthoofinasia, on 28 Jan, 2008 - 06:57 AM, said:

If I can put assembly in C, and C in C++, can I put assembly in C++? I don't know why I would want to, but I've always wondered that.
Should be able to, generally speaking (as far as I know), you can make higher-level languages support lower-level languages easily. However the deal swings only one way, you couldn't have bits of C++ in your assemby because the language wasn't created with support for those languages, simply because they didn't exist at the time. I could be wrong though, you'd have to verify this with someone more experienced than myself. I know for a fact you can put C and C++ code in Python code, but not the other way around.

View Posthoofinasia, on 28 Jan, 2008 - 06:57 AM, said:

maybe you can address the idea of Enums vs Objects for data storage. I know this is a loaded question, but what are the advantages of enumerations over objects?
I think the Object Orientated approach transfers from the whiteboard, or design plan, better than the procedural approach. Aside from that though, the machine doesn't care. As an example, you can take the football object from the whiteboard, and transfer it to the code by using a class. The class will store all the attributes of the football (size, weight, colour, etc) effectively, and wrap it all up nicely in the one class. As opposed to having the football broken up into little functions and variables with the procedural approach. Object Orientation just wraps it all up nicely. This makes it better for lots of different people to work on as well, as you (being the lead programmer in a team) can tell someone to work on the football class and nothing else, functions and classes you don't want them related to can be hidden with private and stuff.

Object Orientation (OO) is probably the better approach in most (if not all) situations. I believe procedural programming definately has it's place though. For some things, I don't think OO is required, and may even cripple the project. For example a driver, a program which has to be small, fast and compact, may not benefit from OO at all.

I don't consider myself very experienced in the subject, and I recommend you get the opinions of a good professor or something before you take the word of a 16 year old who's only had about 6 months experience as gold.

I hope this has helped you out :)
Was This Post Helpful? 0
  • +
  • -

#5 hoofinasia  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-January 08

Re: Multi-Thread / Concurrency in C++

Posted 29 January 2008 - 06:47 AM

View Postjpw1991, on 29 Jan, 2008 - 03:38 AM, said:

I don't consider myself very experienced in the subject, and I recommend you get the opinions of a good professor or something before you take the word of a 16 year old who's only had about 6 months experience as gold.

I hope this has helped you out :)


Thanks!

Yeah I bug my professors to no end. I noticed a thread on this forum about whether to hire an adhoc programmer vs a college educated one, I guess my $.02 is that I spent 5 years ad hoc, then went to college. The first semester felt like hell, programming the Fibonacci sequence and drawing houses. But once I realized that I had 4 r 5 PhD software engineers at my disposal at any given time of the day, I really started to learn. They have to teach curriculum, but an open office door is like the keys to the city. There just is NOT any better resource than a fully educated, experience person who wants nothing more than to teach you all they know.

I digress again.

The only reason I ask bout Enums is that I have noticed a lot of embedded software is designed without objects, even without if / else statements (favoring switch / case) . Mostly this is because of the lower language requirements, but some embedded systems fully support C and C++, and even then, objects are lacking, even frowned upon. This led me to believe that there is some additional strain to the system that is associated with Objects and their ease of use. This strain is probably absorbed by the massive processing power of the modern PC (see Free Lunch).

Just a side note.

Thanks for your help, all.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1