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.

53 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 !

    1. Re:python with psutil by The_Dougster · · Score: 4, Insightful

      Python can sure get you up and running like yesterday with a quick and dirty prototype. Bang it out in python and then port it to C++ at your leisure, if you even need to.

      Having a working solution *right now* is pretty nice, even if your ultimate goal is a C++ binary.

      --
      Clickety Click ...
    2. Re:python with psutil by dgym · · Score: 3, Insightful

      Having a working Python implementation will also give you a better understanding of which parts are performance/memory sensitive. This may help guide you while rewriting in a different language, or you may find that you can achieve your goals just by hot spot optimizing your Python code using some of these fine tools:

      http://www.numpy.org/ can give you compact arrays of unboxed types and fast operations over them.
      http://cython.org/ is an amazing and versatile tool which allows you to compile your Python code, optionally add type information, optionally manage memory yourself, optionally interact with C/C++ code very easily.
      OpenCL/CUDA if your work can take advantage of them.


      If the standard Python runtime isn't simply too big for your project I can't recommend Cython highly enough. Only tackling the parts that need it is one of the keys to successful optimization and Cython lets you do just that even if it is just one loop in an otherwise pure Python file.

  2. If you do go with C++ by TsuruchiBrian · · Score: 5, Informative

    I would recommend using Qt for a cross platform framework. I haven't tried every C++ framework, but of the ones I have tried, Qt is by far the best.

    1. Re:If you do go with C++ by Noughmad · · Score: 5, Informative

      Agreed. Not only it makes programming easier, the code also tends to be more similar to Java and C#, which he has used before.

      --
      PlusFive Slashdot reader for Android. Can post comments.
    2. Re:If you do go with C++ by GNious · · Score: 2

      Qt5 would abstract the bits that are platform specific, while still allowing low-level control where desired.
      Unless there is some specific reason not to use Qt, it would seem to match his requirements nicely.

    3. 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...

    4. Re:If you do go with C++ by BytePusher · · Score: 2

      Also agree. I personally find the only thing more elegant/friendly about python is modules vs headers and a generally robust toolbox of libraries. Qt get's you the majority of that and you get all the control you need without awkward language bindings. As another poster points out, RAII with smart pointers is pretty much superior to garbage collection in every way.

    5. Re:If you do go with C++ by BytePusher · · Score: 4, Informative

      If you're not writing GUIs there's no need to use Qt's signal slot system. Also, since C++11 you're able to use member function pointers instead of their mocking framework(thus you get compiler errors vs printouts at run-time.) And, yes, W(here)TF is the C++ filesystem std library?!?!

    6. Re:If you do go with C++ by turbidostato · · Score: 4, Informative

      You know there's no need for a software project to be coded in any single programing language, don't you?

      You can properly modularize and then mix and match your project as different modules -or even programs, in different languages, i.e.: C for low level hardware access (and abstraction: first you say you want it multiplatform but then your message implies a monolithic approach !?), maybe C++ for the main logic, python to glue everything together, a toolkit like Qt for a GUI -maybe you don't need it now but it results in a good addition down the road, etc.

    7. Re:If you do go with C++ by narcc · · Score: 4, Insightful

      it would seem to match his requirements nicely.

      We don't even know what his requirements are!

    8. Re:If you do go with C++ by TsuruchiBrian · · Score: 2

      If done correctly signals and slots make very maintainable code. They allow you to decouple classes (remove dependencies from classes upon eachother), as opposed to mechanisms like callbacks/handlers. This leads to more modular 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.

      That's a c/c++ problem, not a Qt problem. You can't stop people from writing bad code, but you can make it harder.

      As far as memory management goes, Qt provides both QSharedPointers, which will perform reference counting and delete themselves upon the reference count reacing zero. They also provide a way to use their COW (copy on write) mechanism, so that you can treat references as values and the data is only copied when it is modified from the original (lazy copying).

      Memory management in C/C++ is error prone. Using reference counting pointers and COW makes it easy to do correctly.

      Qt also abstracts out the filesystem api as well.

  3. Not enough information. by Anonymous Coward · · Score: 2, Informative

    You haven't provided nearly enough information to make a decision here. You haven't defined what you mean by "granular level", whether you need a UI, what functionality you have to provide.

  4. C or C++ by Anonymous Coward · · Score: 5, Informative

    Decide whether your project is to be done in C or C++. Choose one and embrace it.

    There's an illusion that because these two languages share a common origin that they're somehow the same, bundled together as "C/C++". Especially since C code can often be valid in a C++ compiler.

    In reality, the good programming styles in each of these two languages differ substantially. Start wedging bits of C code inside a C++ program and you'll soon find yourself fighting the language and core libraries. Likewise, the conventions for core concepts like objects and linked lists in C are somewhat different to C++ and with their own strengths. Both are powerful languages for large projects, but not the same language.

  5. 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 SpaghettiPattern · · Score: 2
      Furthermore you should ask yourself why you would need such a low level access when low lever performance clearly isn't the main issue. Consider using available main stream OSS APIs and libraries to allow higher abstraction level. You could then contribute to improve the used library.

      Reuse components that others developed. It will most likely render you more effective and efficient. You would also pay the component developers back at least through lips service. The components will improve. Everyone will be a winner.

      --

      I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
    2. Re:If you cannot answer your own question.. by mwvdlee · · Score: 4, Insightful

      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.

      This.

      "Very high" is subjective. I've had programming tasks where every single byte of memory counted and was optimized for. But I've also had tasks where this meant I'd just have to keep memory usage down to a few MB; totally different interpretations of "very high granularity".

      Since you'll probably need to have a trade-off between memory and performance, which is more important? Can you spare a few KB to make your code run 2x faster? How about a few MB? Does code need to run as fast as possible or just fast enough to keep pace with the GUI?

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    3. Re:If you cannot answer your own question.. by rwa2 · · Score: 2

      Word.

      I've been pretty happy using python for prototyping, and it's actually fairly fast using a JIT wrapper like pypy. And the C++ bindings are there for when you have to rewrite one of your modules for performance. There's even an interface to Boost and maybe even ASIO if you want to tinker with those for some reason... I played with some Boost libs briefly years ago but found they added too much complexity and got by fine using much cleaner "pure" python modules instead.

    4. 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).

  6. What else do you need? by rippeltippel · · Score: 5, Informative

    You said nothing useful about your project

    C++ could be a good choice for all the things you've mentioned. Networking is not an issue, as there are many open source libraries (e.g. libcurl - http://curl.haxx.se/), and using Boost is often a good thing anyway. Also, there are at least two good memory allocators: tmalloc (http://goog-perftools.sourceforge.net/doc/tcmalloc.html) and jemalloc (http://www.canonware.com/jemalloc/) so you may not need to write your own. (I assume that the above open source licenses are good for you, but they are just examples...)

    However... I doubt that your project will be only Network + Memory + Disk. What else do you need? Some UI? Should it interact with the Web? Or with services in the Cloud? There's no easy answer to your question without knowing what else you need, and I wouldn't even exclude a hybrid-language approach (e.g. C++ / Python / JavaScript*).

    * Before someone starts ranting about JavaScript having to run in a browser: NO - JavaScript runs perfectly fine withouth a browser, and can easily interact with C++. Have a look at V8 or SpiderMonkey, just to name some JavaScript engines.

    1. Re:What else do you need? by mishehu · · Score: 2

      In fact, to support your comments about Javascript, in the FreeSWITCH project, we have a VoIP softswitch that can directly interact with Javascript using mod_v8 (used to be spidermonkey), and can also interact with lua, perl, and other languages - scripted, compiled, managed, etc. in a similar fashion.

    2. Re:What else do you need? by ranton · · Score: 2

      The project is very similar to writing an database management system. I didn't want to get too much into the details so people aren't commenting about the virtues of the project itself.

      There is no UI component; it could be thought of as a cloud service.

      My perfect solution would be developing it in C# while having complete control over memory allocation and release. I have done extensive testing using System.GC.Collect() to manually control garbage collection with no luck.

      I started programming with C++ in high school and began my career with the language so I'm not too worried about moving back to the language, but I realize I am far more competent with higher level languages right now.

      --
      -- All that is necessary for the triumph of evil is that good men do nothing. -- Edmund Burke
  7. Re:C++ is never the right tool by rippeltippel · · Score: 5, Funny

    Can you hear it, my son? This is the voice of ignorance.

  8. C++ with Java for networking by Zumbs · · Score: 3, Informative

    It is possible to use C++ with Java. Try to look at Java Native Interface (JNI). It comes with a performance penalty on each call across the interface, but if you are using it for networking, the penalty will be negligible.

    If you are working on Windows, it is possible to do the same with C# using a CLI interface wrapper. I have no idea if that trick works on Linux/Mac.

    --
    The truth may be out there, but lies are inside your head
    1. Re:C++ with Java for networking by Kagetsuki · · Score: 4, Informative

      JNI is the absolute most awful native interface system I have ever seen. If you absolutely must go the JNI route may I recommend using SWIG to generate things for you. It will require some additional wrapping but at least it won't make you want to end your own life.

      As for performance penalties you'll have the additional overhead of a JVM as well. The whole setup you are proposing I'm guessing you've implemented before and are comfortable with but to me it sounds messy and unnecessary - especially with so many good networking libraries available for C++.

  9. Re:Plain ol' C might a better option by Anonymous Coward · · Score: 2, Insightful

    You can treat C++ as the name implies; plain old C with some extra stuff you may or may not use.
    Nothing in C++ is forcing you to create object oriented code.

  10. Re: C++ is never the right tool by loonycyborg · · Score: 5, Insightful

    I think that using smart pointers and RAII pattern is in all respects better than garbage collection.

  11. Why not? by mrthoughtful · · Score: 3, Informative

    I love C++. It will take you a a couple of years to get good at it, but as you say - it's a personal project, and I am guessing you've had enough of Java.
    However, if you are doing any sort of front end GUI for it, then don't go there. Stay with Java. There is no unified FE GUI for C++ which I could recommend.
    Likewise, many of the suggestions above seem to have not read that you already know Java.

    --
    This comment was written with the intention to opt out of advertising.
  12. Why? by DrVxD · · Score: 3, Insightful

    The main reasons I have for this are the needs to manage memory usage and disk access at a very granular level

    And why, exactly, do you imagine you need these things?
    (You may well do - but you don't give a reason for it, so it's entirely possible that you don't need to manage those things on a granular level)

    --
    Not everything that can be measured matters; Not everything that matters can be measured.
  13. Re:There is no perfect lang by DrVxD · · Score: 5, Insightful

    C++ is often unreadable

    That's not a problem with the language, it's a problem with whoever wrote the code.
    I've been writing software for about 40 years - and one of the things I've observed in that time is that it's possible to write unreadable code in pretty much any language. I've also observed that it's possible to write readable code in pretty much any language.

    --
    Not everything that can be measured matters; Not everything that matters can be measured.
  14. Rule of thumb by DrXym · · Score: 2
    Personally I wouldn't choose C++ or C unless there was very a strong justification. If your code spends more time waiting for something to happen than actually doing something, then you shouldn't be using a low level language. If reliability is more important than raw performance then you shouldn't be using a low level language. If portability is important then you shouldn't be using a low level language. Conversely if you need to do lots of IO and / or control the file format, or interact with system / kernel services, then perhaps a low level language is suitable.

    Boost is a very powerful addition to C++ but that doesn't mean it's as easy to write code as it is in a high level language. e.g. boost's asio is extremely complex and even doing something simple with it like setting a timer is far more pain than other languages. Boost doesn't implement stuff like web sockets or other things either so it's no good on its own without other libraries. If I had to write something in C++ which was performing in a role that would more naturally fall to something like C# or Java, I'd probably use the QT library instead but only after being certain that I needed C++ to begin with.

  15. 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.

  16. Use one language by jones_supa · · Score: 4, Insightful

    I am about to start a personal project which I believe should be done in C/C++.

    I cringe when someone says "C/C++". Sort that out first by choosing one language for your project. Either write lean and clean pure C code, or fully use the proper abstractions of C++ to write memory-safe and easily-maintainable code, but don't make an unprofessional crusty mix of the languages.

  17. Re: C++ is never the right tool by Carewolf · · Score: 4, Informative

    That's because you have no clue. The problems of high-performance, incremental garbage collection was already solved in the 80s and it is ridiculous that there are still ignorants like you around who think that reference counting and incongruent OOP design patterns could replace GC.

    It has only been solved in theory, not in practice. In practice garbage collection is still garbage if you need high performance, usually because high performance usually implies low memory usage and consistent high performance.

  18. Cython by michal.slonina · · Score: 2

    Check out http://cython.org/. This project will enable you to write high level logic in python and drop to C in the performance critical sections of your code.

  19. Re:C++ is never the right tool by Anonymous Coward · · Score: 2, Insightful

    Nothing important in VS is written in C#. The compiler, linker and so on - you know the things that need to be tight with optimal performance, are all written in C++. The platform itself (WPF) is written in C++ (Visual Studio UI is WPF). .NET CLR is written in C++. Do you want me to continue or are you happy enough stewing in your own ignorance?

  20. Re: C++ is never the right tool by TheRaven64 · · Score: 2

    C++ is never the right tool for the job, but for a lot of jobs the right tool doesn't exist and C++ will work.

    --
    I am TheRaven on Soylent News
  21. Re: C++ is never the right tool by TheRaven64 · · Score: 3, Informative

    The C++11 specification was explicitly written to permit garbage collection and includes standard library functions for providing hints to a garbage collector.

    --
    I am TheRaven on Soylent News
  22. Re:C++ is never the right tool by rippeltippel · · Score: 4, Insightful

    Could you describe a project for which the choice of c++ is a good one?

    Guess what, you can easily do that:

    • 1) List ALL the software you normally use (don't forget your OS and the browser you're using now)
    • 2) Cross out the software written in C++
    • 3) Cross out the software written in a language which is itself written in C++ (e.g. Python)
    • 4) Cross out the software that rely on another software/framework written in C++
    • 5) Feel free to use the remaining items on a daily basis, knowing that C++ is not undermining your life anymore

    Oh... good luck!

  23. Re:C++ is never the right tool by rippeltippel · · Score: 2

    Edit: My statement that Python in implemented in C++ may not be entirely correct (there are C implementations) but that's not the point and shouldn't prevent you from doing the exercise.

    By the way, you're welcome to copy your final list on Slashdot, I'd be curious to see it for my own education.

  24. Re:Perl, bootstrap C++ by mangobrain · · Score: 2

    Are you trolling? For anyone not already intimately familiar with the process, the vertical learning curve of writing Perl bindings for C++ code will cause more pain, anguish, wailing and gnashing of teeth than writing in either pure Perl or pure C++. You will also gain nothing in portability: in fact you will lose, because portability will be the lowest common denominator of both Perl and C++ (I won't argue over which is lower to start with, both can be high with the right libraries), with the added headache of having to deal with two orthogonal sets of problems, in different languages.

  25. ASIO by Kagetsuki · · Score: 2

    ASIO is in fact part of Boost now and I personally like it. The thing you need to remember though is that ASIO is not an HTTP client or really any type of client at all - if you want to do HTTP you'll need to write the HTTP headers and handle chunking yourself. That's actually not so hard though. For cross platform SSL you just need to use Open SSL which is actually pretty simple in C++.

    Basically if you want really fine control of your network streams or are using things other than just HTTP then ASIO is going to be what you want. If you just want to have something handle HTTP for you then there's quite a few other libraries out there you can choose from.

  26. Re: C++ is never the right tool by jblues · · Score: 2

    Doesn't Automatic Reference Counting at the compiler level give most of the benefits of Garbage Collection (except for manually breaking retain cycles with a 'weak' modifier) at the same time as offering benefits on resource-constrained devices? A garbage collector takes CPU clicks, and therefore reduces performance and battery life.

    Languages like Swift and Vala use reference counting and have a very modern, clean feel. Objective-C also does, if you don't mind an antiquated syntax.

    --
    If it acquires resources on instantiation like a duck, then its a shared_ptr<Duck>
  27. Re:Plain ol' C might a better option by Damouze · · Score: 2

    But then you are simply programming in C.

    Nothing wrong with that, but why use a C++ compiler when a plain C compiler would spare you so much overhead?

    --
    And on the Eighth Day, Man created God.
  28. Re:Is You Father The Pope ? by Joey+Vegetables · · Score: 2

    Here is Stroustrup's take on learning C++, which includes some examples of why you might not want to start with C first.

  29. Re:C++ is never the right tool by Anonymous Coward · · Score: 2, Insightful

    So true!

    Personally I don't like to hire people that don't understand low level programming, unless it's for mundane / cheap stuff; no matter what the argument is, the guys that know C / ASM always seem to have a better understanding of problems in general.

  30. Re: C++ is never the right tool by beelsebob · · Score: 4, Insightful

    Lack of garbage collection is one of many reasons why C++ produces fast code. The entire point of using C++ is that you want to have control over how, when and where things are allocated and deallocated.

  31. Re: C++ is never the right tool by beelsebob · · Score: 4, Insightful

    In practice, single desktop class machines with 6000+ concurrent users are not typical use cases. Instead, high performance applications are likely to look more like 3D rendering engines.

    In practice, when you have 16ms to produce a frame, it really matters that the garbage collector doesn't kick in for 2ms once every second, because that'll push you past your frame window and lead to stuttering and dropped frames.

    In practice, it really matters that you can structure your code to make sure no allocations are happening during certain critical operations, because an allocation will potentially need a new page, and the kernel barrier and/or hit locks resulting again, in 1-2ms of unexpected delay, and a dropped frame.

    In practice, it really matters too that you have enough control over memory layout to guarantee that certain structures are all going to end up in cache at the same time, and that you're not going to be doing a bunch of pointer indirection fetching memory during time critical rendering code.

    In practice, modern garbage collection doesn't allow you to solve any of these problems. That is why real time rendering engines are still written in C++, and will continue to be, and why everyone writing them will continue to be glad that C++ is not garbage collected.

  32. Re:Tools and architecture by lano1106 · · Score: 2

    C and C++ mix very well. Being able to use C API straight from C++ code, was design goal #1 from day 0 when C++ got invented

    Using C++ from C, is a little less straightforward but quite doable. I wrote a small article years ago on how to do it easily. Check for yourself if you are curious

    Idioms for using C++ in C programs

    concerning OP question. Despite I'm a C++ person, I would recommand doing it in C first. Yes, there are C++ framework such as Boost but I have never liked these frameworks because it bloats your exec with a lot of code (mostly templates) and it adds a magical layer (things works magically) that has a mystical aura (I mean only few people knows how ASIO really works under the hood). Even if you become an ASIO expert after lot of time, the project will still have the potential to become bloated and inefficient as soon as a new contributor, less knowledgeable will jump in. Efficiency is the price to pay to use these type of framework.

    Do what successful projects do, start easy and simple. Use C. If down the road, this appears to not be enough for your needs, reevaluate. FFMPEG comes to mind when thinking about a project that has exactly the same requirement than your project and has been very successful with C

    Good luck and have fun with your project!

  33. Re:There is no perfect lang by frank_adrian314159 · · Score: 2

    No one denies that one can write bad code in any language, but the accusation still stands - languages can help or hinder understandability with their syntax. C++, and it's desire for backward compatibility with C, led to some really unfortunately syntactic decisions that make the code less legible. Operator overloading isn't very good for understanding of performance characteristics (Is this adding 2 ints or an array?). Memory management has provided code bulk (because not everything can be RAII) and the plethora of pointer idioms one must navigate if one has any sort of sizable codebase that has been maintained by many others over the years. Now add on features and libraries so broad and complex that organizations actually have their own dialects of C++ (or so I am told) that their employees are allowed to use. Need I go on?

    Frankly, C++ has advantages in some places, but aiding in making code legible and understandable is not one of C++'s strong suits. And I've worked on (and probably helped generate) enough crappy C++ codebases to know of which I speak.

    --
    That is all.
  34. 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

  35. C++ is great if you don't abuse it. by Codeyman · · Score: 2

    As a systems programmer, I have used both C and C++. When using C, I (and my team) needs to expressly have the discipline to embrace the tenets of C++ vis-a-vis encapsulation, maybe some facade dp thrown in. Most of the rookie mistakes are easier to spot in C, but there is a lot more code to be written in C to achieve the same effect (writing & using an object agnostic linked list for example).
    When using C++, things are hidden in plain sight, and rookie mistakes are easily overlooked, because someone found a "smarter" way to use the language. I've pulled my hair out in cases when people had overloaded operators in nonsensical ways. People would just compare a string with constant, without knowing that it is invoking a copy constructor and equals operator, which in turn is doing some form of strcmp to get the job done. C++ is great for system software if people know the ins and out of it and performance isn't of a great concern. It will give you the same performance as C if you know how to use it well.
    Also if performance is important, you'd probably need to use DPDK on intel boxes for networking, squirrel away huge pages for your memory allocator or do something like jemalloc etc, so your choices might be limited.
    If performance is not THAT important, then most of the modern libraries build on top of any high level language will give you all the tools that you need to build your project. Personally I'd try to look at Go. I don't know much about it, but it seems to have taken care of a lot of pain points in systems design (specially queuing, async processing, threads etc).

  36. Re:Plain ol' C might a better option by Darinbob · · Score: 2

    Templates I think were a mistake to add to C++. It has removed a lot of object orientation from C++ programs, and it has bloated things up tremendously because of popular styles of using them and due to STL. Templates are essentially smart macros. You end up with duplicated code for each instantiation, and with some styles even the functions themselves are inlined. This only works because this style is big on the PC where there is massive amounts of RAM and cache space to soak up the inefficiencies. The current compiler/linker technology is not capable of effectively turning template heavy code into efficient code by recognizing when there is duplicated code that could be combined into shared object code. Often what is normally a library of object code in other languages turn into a library of header files in a template-heavy C++ style.

    Now templates as a concept aren't all bad. A small template that provides type safety while sitting on top of a small tight library is great. Programmers need to learn their tools, learn how to use them well, and learn when to not use them. But most programmers don't do this, instead they learn to follow what other people do blindly until it becomes a habit.