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

Code duplication is an overhead. Not as bad as RTTI, but static memory footprint is still important in the embedded/systems world -- sometimes more so than runtime memory footprint!


You don't need any RTTI or code duplication for polymorphism, so long as you don't need general support for type-checked downcasts. If you do need type-checked downcasts, it can be as cheap as a single pointer on antirez's mylist->ops function table - a pointer pointing to the ancestor function table.

(Specific support for any single downcast is trivial - just write a function for the function table, typed appropriately and implemented appropriately.)




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: