Question about ROOT structure

Dear @Axel @brun @bellenot @rdm ,

I have studying root and just interesting - why do you have plenty of your owns data structures…
Ok, TString has some nice extended methods compared to std::string, but e.g. TArray. What is advantage of usage TArrayD instead std::vector<Double_t>? Also what is strange - TH1D::GetArray returns Double_t *, instead TArrayD, why is it so? Some historical reasons? :slight_smile:

Regards,
Boris


_ROOT Version: 6.15/01
Platform: Mac OS X 10.13.6
Compiler: clang


Hi Boris,
ROOT development started in '94, the STL was not in good shape at the time, so I guess most of these quirks are indeed for “historical reasons”. And the strong need for backwards compatibility makes it hard to modernize interfaces. I can’t comment on the specific examples, I was barely born :slight_smile:

Cheers,
Enrico

1 Like

Hi,
another important reason for the serveral classes of root is the introduction of the master class TObject which all classes except a few exception like TString inherit from. This allows casting all of these objects to TObject. In a TList for example you can store every object that inherits from TObject even several different classes are possible while a std::vector can only store objects of the class declared in the template argument. This gives root an extraordinary amount of flexibility and furthermore allows to use functions declared in TObject. If you look at https://root.cern.ch/doc/v608/classTObject.html you realize how helpful this master class can be.
I was programming in JAVA earlier where there is also a master class and I was really missing this when I switched to C++.

But there is one thing I really hate about root: There are like a billion typedefs as if every programmer had his own naming convention and tried to force it with typedefs, but for reading and understanding how several classes work together this is pure horror! :rage:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.