I have repeatedly updated some of the built-in data structures, functions, and language classes. As an embedded developer, the main reason I will do this is speed or efficiency. Standard libraries and types have been designed to be useful in a variety of situations, but there are many examples where I can create a more specialized version specifically designed to take advantage of the capabilities and limitations of my current platform. If the language does not provide a way to open and modify existing classes (for example, you can in Ruby, for example), reimplementing the class / function / structure may be the only way.
For example, one system I was working on used the MIPS processor, which was fast when working with 32-bit numbers, but slower when working with smaller ones. I re-wrote several data structures and functions to use 32-bit integers instead of 16-bit integers, and also indicated that the fields will be aligned with 32-bit boundaries. The result was a noticeable speedup in the code section, which was the bottleneck of other pieces of software.
So this was not a trivial process. In the end, I had to change every function that used this structure, and I had to rewrite several standard library functions. In this particular case, the benefits outweighed the work. In the general case, however, this is usually not worth the trouble. There is great potential for hard-to-debug problems, and it almost always works more than it seems. If you do not have specific requirements or restrictions that do not correspond to existing structures / classes, I would recommend not reinstalling them.
As Michael notes, itβs really useful to know how to reimplement structures, even if you donβt. In the future, you may find a problem that can be solved by applying the principles and methods used in existing data structures.
bta
source share