6 Ekim 2020 Salı

Alexander Stepanov

STL'in yaratıcısının amacı şöyleydi.
Alexander Stepanov worked out you could decouple container operations from the operated on data, and algorithms from the containers they operate on. All while generating code that was close to the performance of hand-crafted C.
Eğer STL veri yapılarına arayüz eklenirse sonucu şu olur.
When you add a virtual interface to an object, there is a bunch of overhead that is added.

First, a per-implementation-class virtual function table has to exist at runtime. Second, RTTI is added. Third, inlining opportunities evaporate. Forth, the implementation objects have to carry around an extra vtable pointer. Fifth, dispatch to methods requires extra layers of indirection. Sixth, knock-on types like iterators get increasingly complex.
Bu Yüzden STL Veriyapıları Interface Kullanmazlar
Açıklaması şöyle
Other languages have chosen a different path. Languages like Java and C# have almost all objects heap-allocated with inheritance and virtual tables. Objects are actually garbage collected references to objects, and memory locality is near impossible.

The cost of this is roughly a 2x to 3x performance reduction in most tasks. They can get around this in narrow cases by either using external libraries, or by very carefully writing code that their optimizer can remove all of the object overhead from.

For many people that 2x to 3x reduction in performance is a-ok. After all, investment in performance is fungible, and many tasks are much easier in Java and C#. So you can write a quicker app that hobbles along in C#/Java, then focus your work on the critical path. Doubling the performance of code is pretty typical when you put brain-sweat into it.

C++ isn't really an OO language. It has functional, OO and procedural ways of writing C++.
Bazı Oyun Motroları Neden STL Kullanmıyor?
Sebebini bilmiyorum. Örneğin Unreal Engine kullanmıyor
- Bazıları STL veri yapılarının performansından şikayet ediyor. 
- Bazıları da bu motorlar geliştirilirken STL henüz mevcut değildi diyorlar. 

Hiç yorum yok:

Yorum Gönder