Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It seems you are blaming C++ as a language for the design of the libraries you are using.

I've also never seen a program actually be slow due to string manipulation (excluding grep). My guess is that if you profile, it will turn out that your performance is getting away from you in places you don't expect.



> It seems you are blaming C++ as a language for the design of the libraries you are using.

Precisely. In the same way that Java is criticized for proliferating the IAbstractFactoryVisitor design anti-pattern, C++ should be criticized for its weak standard library which causes an overproliferation of mutually-incompatible reimplementations of basic functionality.

As to whether this is or is not a performance issue depends on the specifics of the application and the underlying hardware.

This is besides the point to this discussion. Why don't C# libraries reimplement System.String like C++ libraries reimplement std::string? That's the real question here.


Because when C++ appeared, its standard library was basically C.

Then you had the early adopters that were basically the same developers that were still writing C with lots of inline Assembly.

So each developer, or team, had to write their own library, because they knew better.

It took all the way up to ANSI C++ (1998) to finally have a proper minimal library. Minimal, because C++ needed to cater to the C mentality that the OS is the runtime.

Then you had almost a decade until the C++ vendors were able to catch up the standard.

Mind you that in the mid-90's there were still quite a few C compilers that were K&R only.

This is why when Java appeared, many of us C++ devs that cared also about safety, jumped into it. As it provided a more portable experience.


Modern libraries don't reimplement std::string. The C++11-14 standard library is actually pretty solid.


I was actually curious if this is true, and it appears that Unreal Engine 4 reimplements std::string (FString) [1] I think this qualifies as a modern library.

My yardstick for "pretty solid" is actually meaningful Unicode support, so I will reserve judgement as to whether the C++11 STL qualifies.

[1] https://docs.unrealengine.com/latest/INT/Programming/UnrealA...


Unreal has been evolving for over 15 years and the engine does lots of preprocessing as well as being built for interactive C++, so I don't think it is the best example.


Death by a thousand strings is a very common performance diagnosis.


"Death by a thousand strings" I love this phrase, I hope you don't mind if I shamelessly copy it for future use!


Glad to help :)


In C++ with small string optimization or in other languages?


I'm thinking C++, but I'm sure other languages have it too.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: