3 ms·
Kind of weird how he wrote his own string class, as well as rewriting some other perfectly good standard library stuff. His version of scoped_ptr seems to fake
by asveikau 13y ago
Kind of weird how he wrote his own string class, as well as rewriting some other perfectly good standard library stuff.
His version of scoped_ptr seems to fake rvalue references without actually using rvalue references, but does so in a copy constructor. IMO this is a bit bonkers. If you're not going to use rvalue references I think move semantics is better done from a method, not a copy constructor.
Still looks like a handy library for wrapping things that are otherwise not portable.
Edit: I was mainly basing that comment from looking at juice_core... There's a crapton of other stuff too. Impressive for a one-person work.
- stinos 13y agoKind of weird how he wrote his own string class, as well as rewriting some other perfectly good standard library stuff. not that weird: Qt and others do it as well. Not sure why though, maybe because at the time they started there was a lack of a decent std::string implementation on all platforms?
- asveikau 13y agoQt does it because the library predates common availability of std::string across multiple compilers. It's been a while since I looked but there is a lot of funky stuff in Qt that would look saner if they had the benefit of starting with a recent standard.
- zokier 13y agostd::string is very low-level interface, and has eg. very little to no provisions for Unicode.
- asveikau 13y agoSo build unicode routines on top. Don't make me put all my data in a non-standard datatype where another type already exists and is more common. Users of C++ already have to deal with std::string and char * and possibly PWSTR if they are on Windows, why throw yet another type at them? This reminds me of a joke I used to tell, it starts with a problem that there are too many string types, and the solution, somehow, always ends up being another string type...
- FigBug 13y agoHe started working on it 2001/2002, at that time, C++ implementations of the standard library were poor and inconsistent across compilers. There is a reason that pretty much every library from that era redid all the basic classes - Qt, MFC, etc. When I learnt C++ it didn't have std::string.
- asveikau 13y agoQt and MFC are quite a bit older than 2001/2002. It makes sense to avoid std::string in the early or mid 90s. By 2001, though...
- icefox 13y agoEven std::string today isn't perfect and on more than one project I have replaced it. :\
- malkia 13y agoI find QByteArray and QString more useful and complete than std::string, yet we keep our interfaces to std::string or const char*, since this would reduce external dependencies for other folks that want to use the library (also the learning process, and less include files).
- julesrms 13y agoOk, the reasons are/were: 1. Back in 2001-ish, Java was cool, and I was copying the java string class. 2. I wanted more functionality than std::string offers. Yes, yes, I know all the arguments about keeping the class simple and using external methods for adding functionality, and I generally agree with that philosophy, but having used both juce::String and std::string, in practice the juce design just seemed to result in cleaner code. 3. I wanted it to be able to easily cast to utf-16 or 32, and std::string was a bit clunky for that. 4. It's a long time ago, but I vaguely remember std::string having performance issues on some platforms.. Can't remember the details, but there were definitely problems that made it perform differently on different compilers. If I was designing a string class today with hindsight, I'd probably still go for the overall design of juce::String, maybe tweaking some of the methods a bit, but I might make it wrap a std::string so that they can be interchanged efficiently.