by jacques_chester · 14y ago · 0 comments
Then there's the library/tools situation. I did all the work for my honours dissertation in Ruby in part because the Ruby ecosystem is vast and vibrant (sometimes inconveniently so).
I imagine that the C++-for-the-web ecosystem is going to be a bit more spartan.
Since in C++ you can use STL classes for buffers where they are automatically resized as appropriate, streams for IO, etc. So you'd effectively have the same resizing and safe objects to work with as in a higher level language.
As far as I see it both C++ and Ruby have a similar amount of libraries that can be used, they both have a major web framework, Rails for Ruby and OKWS for C++, and there's probably a plethora of smaller frameworks and helpers available for each language.
Rails may seem like it would be winning (versus C++) on the ecosystem, but that's because there's so many hip gems for Rails out there, but if you take a look at all libraries it probably won't be so.
Proper use of carefully-written classes will reduce the risk of a buffer overflow -- but you will need to exercise additional vigilance ("Make sure you use STL! Why isn't this code using STL?" etc), over and above addressing the problem, to ensure string safeness is assured.
That's a dead loss that programmers in memory-safe languages simply don't have to pay for the same level of confidence.
Essentially a string is std::string, a resiable buffer is std::vector<unsigned char>, and for a string or a resiable (or unknown size) buffer to be anything else you need to provide a very good reason.
I would also be careful with Ruby since a lot of (performance specific) gems and plugins for Rails are written in C, and hence potentially suffer the same problems that one is trying to avoid by using Ruby. Or at least you end up in the same boat if you were using C or C++ to begin with.
For extremely expensive values of "free."
Claiming that some languages solve these problems for you, for free, is disingenuous.
I pointed out that languages with safe string handling and memory management have a higher security baseline. As in, what you start with, for "free".
Achieving comparable string and memory security in C/C++ is an expense. You must take active steps to prevent those exploits; and even then human error means that you will have a higher risk than the "free baseline" languages.