Slashdot Mirror


Ask Slashdot: Is C++ the Right Tool For This Project?

ranton writes: I am about to start a personal project which I believe should be done in C/C++. The main reasons I have for this are the needs to manage memory usage and disk access at a very granular level and a desire to be cross-platform. Performance is also important but I am unlikely to spend enough time optimizing to be much faster than core libraries of higher level languages.

On the other hand, network access is also a critical part of the project and I am worried about the effort it takes to make cross platform code for both network and disk access. I have been working in the Java / C# world for the past decade and things like TCP/IP and SSL have just been done for me by core libraries. Do libraries like Boost or Asio do a good job of abstracting these aspects away? Or are there other options for doing granular memory and disk management with more high level languages that have better cross-platform library support? I am willing to brush up on my C/C++ skills if necessary but want to spend as much time as possible developing the unique and potentially innovative parts of my project. Thanks for any advice you can provide.

6 of 296 comments (clear)

  1. python with psutil by sandGorgons · · Score: 3, Interesting

    consider using python with py2exe, psutil and mmap. you may find what you are looking for !

  2. If you cannot answer your own question.. by thesupraman · · Score: 5, Interesting

    Then C++ is almost certainly not the language for you, unless it is a pure learning experience.

    Really.. C++ is a relatively high commitment language, and performance is one of its mainstays, however you dont feel you will spend much time optimising it?
    If you cannot look quite quickly over the descriptions of Boost/ASIO and see what they do (and dont) bring to the table, then you will be fighting a very
    uphill battle.

    The reference to TCP/IP being 'done for you' is worrying.. do you think people program raw TCP in C++?

    If you value your project at all then I would suggest C++ is not sounding like your solution.. especially if you need cross
    platform. Your reasons seem almost to be reasons NOT to use an unfamiliar language.

    As almost everything else has equal or better cross platform support, it seems to me like you need to look more closely to what you mean/need by
    'granularity' and perhaps change your mentality using familiar languages, and the solutions for problems in those areas.

    1. Re:If you cannot answer your own question.. by Kagetsuki · · Score: 4, Interesting

      I program raw TCP in C++.

      I think maybe you meant to say "do you realize people program raw TCP in C++?" or something like that.

      Also, I agree with you that the person asking the question here should probably look for something else. It sounds like they are in over their head and I don't see them optimizing multi-threaded networking applications with real time IO in valgrind any time soon (though it sounds like an interesting Friday afternoon for me).

  3. No. by viperidaenz · · Score: 3, Interesting

    If you're better at Java or C#, use that.

    Sometimes the right tool for the job is the tool you know best.

    If you're not confident at what you know, perhaps the best tool is someone else.

  4. Re:If you do go with C++ by gladish · · Score: 5, Interesting
    I think that really depends on your definition of "best". I've used Qt (and still use it sometimes) and initially I thought I liked it, but over time began disliking it a lot. For one, I've seen the signal/slot mechanism used to create really hard to understand code. I've seen memory allocated via new and then the pointer passed into emit only to be deleted on the other end of a signal/slot chain.

    Posted says, "needs to manage memory usage and disk access at a very granular level and a desire to be cross-platform". Stdio/stdlib takes care of that. I don't see any mention of GUI, so if GUI is necessary, then I'd say, ya, just use Qt, because it probably is the best and it does come with a lot of other stuff, so you when in Rome...

    Boost. What you'll get from boost is the filesystem stuff. It'll be similar in functionality as System.IO.FileInfo System.IO.Directory in .NET, but way more confusing to use. At least at first.

    It's funny, the filesystem api was proposed over 9 years ago for c++.

    http://www.open-std.org/jtc1/s...

  5. Re:C++ is never the right tool by rockmuelle · · Score: 4, Interesting

    Python is written in C. Linux is written in C. OS X is written in C (with libraries in Objective C). Most low level software is written in C, not C++. It's very important for this exercise to differentiate C from C++. They are not the same language and haven't been since C++ stopped being implemented using macros and the preprocessor and got its first compiler.

    C is a much simpler language to learn and maintain, especially if you're doing low level code. C++ has a lot of very nice features, but it's benefits really only come into play if you're willing to put the time and effort into properly learning generic programming (the foundation Boost and the STL).

    But, as most people have already pointed out, starting with Python and then migrating portions over to C or C++ as needed for performance is a much better approach. You can manage IO just as effectively from Python as you can from C or C++ and your development time will be much much shorter.

    -Chris