Maga D. Zandaqo published an article about high performant data structures in JavaScript. After author’s last attempt to speed up a Node.js server by replacing some JavaScript with a native addon yielded less than exciting results, he has decided to collect and share some common structures he uses to optimize my JavaScript code: structurae.
The techniques aim at performance–sensitive applications such as games or real–time data processing. They are hardly applicable to most of our Todo apps and might do more harm than good if used indiscreetly.
We can help JavasScript engines by addressing the “weak points” of JavaScript when it comes to performance: dynamic typing and garbage collection.
Recommendations summarized:
- Simplify and normalize data structures
- Be consistent with the “shapes” of objects
- Avoid creating garbage
Read more how structurae is focusing on the first item by providing a set of classes that aid in representing and operating on complex data structures using simple numbers and ArrayBuffers. Where possible, prefer simple types over objects, numbers over strings, small integers over other numbers, TypedArrays over Arrays, and dense Arrays over sparse Arrays. What a good read!
[Read More]